Remove extraneous code changes; remove QUrlAncestry code; remove extra logging

This commit is contained in:
Zach Fox 2018-10-19 11:32:31 -07:00 committed by Kerry Ivan Kurian
parent 55c1a88404
commit 493262052c
30 changed files with 210 additions and 345 deletions

View file

@ -37,7 +37,6 @@
#include "AssignmentFactory.h"
#include "ResourceRequestObserver.h"
const QString ASSIGNMENT_CLIENT_TARGET_NAME = "assignment-client";
const long long ASSIGNMENT_REQUEST_INTERVAL_MSECS = 1 * 1000;

View file

@ -170,7 +170,6 @@
#include "ModelPackager.h"
#include "scripting/Audio.h"
#include "networking/CloseEventSender.h"
#include "QUrlAncestry.h"
#include "scripting/TestScriptingInterface.h"
#include "scripting/AssetMappingsScriptingInterface.h"
#include "scripting/ClipboardScriptingInterface.h"
@ -947,6 +946,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<Ledger>();
DependencyManager::set<Wallet>();
DependencyManager::set<WalletScriptingInterface>();
DependencyManager::set<FadeEffect>();
DependencyManager::set<ResourceRequestObserver>();
@ -5029,7 +5029,8 @@ bool Application::importEntities(const QString& urlOrFilename, const bool isObse
bool success = false;
_entityClipboard->withWriteLock([&] {
_entityClipboard->eraseAllOctreeElements();
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId, QUrlAncestry());
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId);
if (success) {
_entityClipboard->reaverageOctreeElements();
}

View file

@ -61,7 +61,6 @@
#include "AboutUtil.h"
#include "ResourceRequestObserver.h"
static int MAX_WINDOW_SIZE = 4096;
static const float METERS_TO_INCHES = 39.3701f;
static const float OPAQUE_ALPHA_THRESHOLD = 0.99f;

View file

@ -2163,7 +2163,7 @@ void AvatarData::updateJointMappings() {
if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) {
////
// TODO: Should we rely upon HTTPResourceRequest instead?
// TODO: Should we rely upon HTTPResourceRequest for ResourceRequestObserver instead?
// HTTPResourceRequest::doSend() covers all of the following and
// then some. It doesn't cover the connect() call, so we may
// want to add a HTTPResourceRequest::doSend() method that does

View file

@ -38,8 +38,6 @@
#include "LogHandler.h"
#include "EntityEditFilters.h"
#include "EntityDynamicFactoryInterface.h"
#include "QUrlAncestry.h"
static const quint64 DELETED_ENTITIES_EXTRA_USECS_TO_CONSIDER = USECS_PER_MSEC * 50;
const float EntityTree::DEFAULT_MAX_TMP_ENTITY_LIFETIME = 60 * 60; // 1 hour
@ -2495,7 +2493,7 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer
return true;
}
bool EntityTree::readFromMap(QVariantMap& map, const QUrlAncestry& ancestry) {
bool EntityTree::readFromMap(QVariantMap& map) {
// These are needed to deal with older content (before adding inheritance modes)
int contentVersion = map["Version"].toInt();
bool needsConversion = (contentVersion < (int)EntityVersion::ZoneLightInheritModes);

View file

@ -22,8 +22,6 @@
#include "EntityTreeElement.h"
#include "DeleteEntityOperator.h"
#include "MovingEntitiesOperator.h"
#include "QUrlAncestry.h"
class EntityTree;
using EntityTreePointer = std::shared_ptr<EntityTree>;
@ -225,7 +223,7 @@ public:
virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues,
bool skipThoseWithBadParents) override;
virtual bool readFromMap(QVariantMap& entityDescription, const QUrlAncestry& ancestry = {}) override;
virtual bool readFromMap(QVariantMap& entityDescription) override;
glm::vec3 getContentsDimensions();
float getContentsLargestDimension();

View file

@ -12,19 +12,19 @@
#ifndef hifi_FileResourceRequest_h
#define hifi_FileResourceRequest_h
#include "ResourceRequest.h"
#include "QUrlAncestry.h"
#include <QUrl>
#include "ResourceRequest.h"
class FileResourceRequest : public ResourceRequest {
Q_OBJECT
public:
FileResourceRequest(
const QUrlAncestry& urlAncestry,
const QUrl& url,
const bool isObservable = true,
const qint64 callerId = -1,
const QString& extra = ""
) : ResourceRequest(urlAncestry, isObservable, callerId, extra) { }
) : ResourceRequest(url, isObservable, callerId, extra) { }
protected:
virtual void doSend() override;

View file

@ -13,21 +13,20 @@
#define hifi_HTTPResourceRequest_h
#include <QNetworkReply>
#include <QUrl>
#include <QTimer>
#include "ResourceRequest.h"
#include "QUrlAncestry.h"
class HTTPResourceRequest : public ResourceRequest {
Q_OBJECT
public:
HTTPResourceRequest(
const QUrlAncestry& urlAncestry,
const QUrl& url,
const bool isObservable = true,
const qint64 callerId = -1,
const QString& = ""
) : ResourceRequest(urlAncestry, isObservable, callerId) { }
) : ResourceRequest(url, isObservable, callerId) { }
~HTTPResourceRequest();
protected:

View file

@ -337,7 +337,6 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
QReadLocker locker(&_resourcesLock);
resource = _resources.value(url).lock();
}
if (resource) {
removeUnusedResource(resource);
}

View file

@ -26,7 +26,6 @@
#include "NetworkAccessManager.h"
#include "NetworkLogging.h"
ResourceManager::ResourceManager(bool atpSupportEnabled) : _atpSupportEnabled(atpSupportEnabled) {
_thread.setObjectName("Resource Manager Thread");
@ -125,7 +124,6 @@ ResourceRequest* ResourceManager::createResourceRequest(
ResourceRequest* request = nullptr;
qDebug() << "!!!! in createResourceRequest " << callerId;
if (scheme == URL_SCHEME_FILE || scheme == URL_SCHEME_QRC) {
request = new FileResourceRequest(normalizedURL, isObservable, callerId, extra);
} else if (scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP) {
@ -146,7 +144,6 @@ ResourceRequest* ResourceManager::createResourceRequest(
QObject::connect(parent, &QObject::destroyed, request, &QObject::deleteLater);
}
request->moveToThread(&_thread);
return request;
}

View file

@ -21,9 +21,8 @@
void ResourceRequest::send() {
if (_isObservable) {
DependencyManager::get<ResourceRequestObserver>()->update(
_urlAncestry, _callerId, _extra + " => ResourceRequest::send" );
_url, _callerId, _extra + " => ResourceRequest::send" );
}
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "send", Qt::QueuedConnection);
return;

View file

@ -18,8 +18,6 @@
#include <cstdint>
#include "ByteRange.h"
#include "QUrlAncestry.h"
const QString STAT_ATP_REQUEST_STARTED = "StartedATPRequest";
const QString STAT_HTTP_REQUEST_STARTED = "StartedHTTPRequest";
@ -46,15 +44,14 @@ public:
static const bool IS_NOT_OBSERVABLE = false;
ResourceRequest(
const QUrlAncestry& urlAncestry,
const QUrl& url,
const bool isObservable = IS_OBSERVABLE,
const qint64 callerId = -1,
const QString& extra = ""
) : _urlAncestry(urlAncestry),
) : _url(url),
_isObservable(isObservable),
_callerId(callerId),
_extra(extra),
_url(urlAncestry.last())
_extra(extra)
{ }
virtual ~ResourceRequest() = default;
@ -103,7 +100,6 @@ protected:
virtual void doSend() = 0;
void recordBytesDownloadedInStats(const QString& statName, int64_t bytesReceived);
QUrl _url;
QUrl _relativePathURL;
State _state { NotStarted };
@ -119,7 +115,6 @@ protected:
bool _isObservable;
qint64 _callerId;
QString _extra;
QUrlAncestry _urlAncestry;
};
#endif

View file

@ -669,7 +669,7 @@ OctreeElementPointer Octree::getElementEnclosingPoint(const glm::vec3& point, Oc
return args.element;
}
bool Octree::readFromFile(const char* fileName, const QUrlAncestry& urlAncestry) {
bool Octree::readFromFile(const char* fileName) {
QString qFileName = findMostRecentFileExtension(fileName, PERSIST_EXTENSIONS);
if (qFileName.endsWith(".json.gz")) {
@ -689,7 +689,7 @@ bool Octree::readFromFile(const char* fileName, const QUrlAncestry& urlAncestry)
qCDebug(octree) << "Loading file" << qFileName << "...";
bool success = readFromStream(fileLength, fileInputStream, "", urlAncestry);
bool success = readFromStream(fileLength, fileInputStream, "");
file.close();
@ -737,8 +737,7 @@ QString getMarketplaceID(const QString& urlString) {
bool Octree::readFromURL(
const QString& urlString,
const bool isObservable,
const qint64 callerId,
const QUrlAncestry& urlAncestry
const qint64 callerId
) {
QString trimmedUrl = urlString.trimmed();
QString marketplaceID = getMarketplaceID(trimmedUrl);
@ -767,19 +766,18 @@ bool Octree::readFromURL(
if (wasCompressed) {
QDataStream inputStream(uncompressedJsonData);
return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID, urlAncestry);
return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID);
}
QDataStream inputStream(data);
return readFromStream(data.size(), inputStream, marketplaceID, urlAncestry);
return readFromStream(data.size(), inputStream, marketplaceID);
}
bool Octree::readFromStream(
uint64_t streamLength,
QDataStream& inputStream,
const QString& marketplaceID,
const QUrlAncestry& urlAncestry
const QString& marketplaceID
) {
// decide if this is binary SVO or JSON-formatted SVO
QIODevice *device = inputStream.device();
@ -792,7 +790,7 @@ bool Octree::readFromStream(
return false;
} else {
qCDebug(octree) << "Reading from JSON SVO Stream length:" << streamLength;
return readJSONFromStream(streamLength, inputStream, marketplaceID, urlAncestry);
return readJSONFromStream(streamLength, inputStream, marketplaceID);
}
}
@ -824,8 +822,7 @@ const int READ_JSON_BUFFER_SIZE = 2048;
bool Octree::readJSONFromStream(
uint64_t streamLength,
QDataStream& inputStream,
const QString& marketplaceID, /*=""*/
const QUrlAncestry& urlAncestry
const QString& marketplaceID /*=""*/
) {
// if the data is gzipped we may not have a useful bytesAvailable() result, so just keep reading until
// we get an eof. Leave streamLength parameter for consistency.
@ -851,7 +848,7 @@ bool Octree::readJSONFromStream(
}
QVariant asVariant = asDocument.toVariant();
QVariantMap asMap = asVariant.toMap();
bool success = readFromMap(asMap, urlAncestry);
bool success = readFromMap(asMap);
delete[] rawData;
return success;
}

View file

@ -29,7 +29,6 @@
#include "OctreePacketData.h"
#include "OctreeSceneStats.h"
#include "OctreeUtils.h"
#include "QUrlAncestry.h"
class ReadBitstreamToTreeParams;
class Octree;
@ -210,13 +209,13 @@ public:
bool skipThoseWithBadParents) = 0;
// Octree importers
bool readFromFile(const char* filename, const QUrlAncestry& urlAncestry = {});
bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1, const QUrlAncestry& urlAncestry = {}); // will support file urls as well...
bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const QUrlAncestry& urlAncestry = {});
bool readFromFile(const char* filename);
bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1); // will support file urls as well...
bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
bool readSVOFromStream(uint64_t streamLength, QDataStream& inputStream);
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const QUrlAncestry& urlAncestry = {});
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
bool readJSONFromGzippedFile(QString qFileName);
virtual bool readFromMap(QVariantMap& entityDescription, const QUrlAncestry& urlAncestry = {}) = 0;
virtual bool readFromMap(QVariantMap& entityDescription) = 0;
uint64_t getOctreeElementsCount();

View file

@ -258,29 +258,24 @@ void OffscreenSurface::setMaxFps(uint8_t maxFps) {
}
void OffscreenSurface::load(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) {
qDebug() << "Here 1";
loadInternal(qmlSource, false, parent, [callback](QQmlContext* context, QQuickItem* newItem) {
QJSValue(callback).call(QJSValueList() << context->engine()->newQObject(newItem));
});
}
void OffscreenSurface::load(const QUrl& qmlSource, bool createNewContext, const QmlContextObjectCallback& callback) {
qDebug() << "Here 2";
loadInternal(qmlSource, createNewContext, nullptr, callback);
}
void OffscreenSurface::loadInNewContext(const QUrl& qmlSource, const QmlContextObjectCallback& callback, const QmlContextCallback& contextCallback) {
qDebug() << "Here 3";
loadInternal(qmlSource, true, nullptr, callback, contextCallback);
}
void OffscreenSurface::load(const QUrl& qmlSource, const QmlContextObjectCallback& callback) {
qDebug() << "Here 4";
load(qmlSource, false, callback);
}
void OffscreenSurface::load(const QString& qmlSourceFile, const QmlContextObjectCallback& callback) {
qDebug() << "Here 5";
return load(QUrl(qmlSourceFile), callback);
}

View file

@ -1,31 +0,0 @@
//
// EntityItemWeakPointerWithUrlAncestry.h
// libraries/shared/src/
//
// Created by Kerry Ivan Kurian 10/15/18
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_EntityItemWeakPointerWithUrlAncestry_h
#define hifi_EntityItemWeakPointerWithUrlAncestry_h
#include "EntityTypes.h"
#include "QUrlAncestry.h"
struct EntityItemWeakPointerWithUrlAncestry {
EntityItemWeakPointerWithUrlAncestry(
const EntityItemWeakPointer& a,
const QUrlAncestry& b
) : entityItemWeakPointer(a), urlAncestry(b) {}
EntityItemWeakPointer entityItemWeakPointer;
QUrlAncestry urlAncestry;
};
#endif // hifi_EntityItemWeakPointerWithUrlAncestry_h

View file

@ -1,35 +0,0 @@
//
// QUrlAncestry.cpp
// libraries/shared/src/
//
// Created by Kerry Ivan Kurian on 10/12/18.
// Copyright (c) 2018 High Fidelity, Inc. All rights reserved.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "QUrlAncestry.h"
QUrlAncestry::QUrlAncestry(const QUrl& resource, const QUrl& referrer) {
this->append(referrer);
this->append(resource);
}
QUrlAncestry::QUrlAncestry(
const QUrl& resource,
const QUrlAncestry& ancestors) : QVector<QUrl>(ancestors)
{
this->append(resource);
}
void QUrlAncestry::toJson(QJsonArray& array) const {
for (auto const& qurl : *this) {
array.append(qurl.toDisplayString());
}
}
const QUrl QUrlAncestry::url() const {
return this->last();
}

View file

@ -1,32 +0,0 @@
//
// QUrlAncestry.h
// libraries/shared/src/
//
// Created by Kerry Ivan Kurian on 10/12/18.
// Copyright (c) 2018 High Fidelity, Inc. All rights reserved.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_QUrlAncestry_H
#define hifi_QUrlAncestry_H
#include <QJsonArray>
#include <QUrl>
#include <QVector>
class QUrlAncestry : public QVector<QUrl> {
public:
QUrlAncestry() {}
QUrlAncestry(const QUrl& resource, const QUrl& referrer = QUrl("__NONE__"));
QUrlAncestry(const QUrl& resource, const QUrlAncestry& ancestors);
void toJson(QJsonArray& array) const;
const QUrl url() const;
};
#endif // hifi_QUrlVector_H

View file

@ -15,22 +15,12 @@
#include <QString>
#include <QUrl>
#include "ResourceRequestObserver.h"
#include "QUrlAncestry.h"
// void ResourceRequestObserver::update(const QNetworkRequest& request, const qint64 callerId, const QString& extra) {
// update(QUrlAncestry(request.url()), callerId, extra);
// }
void ResourceRequestObserver::update(
const QUrlAncestry& urlAncestry,
void ResourceRequestObserver::update(const QUrl& requestUrl,
const qint64 callerId,
const QString& extra
) {
const QString& extra) {
QJsonArray array;
urlAncestry.toJson(array);
QJsonObject data {
{ "url", array },
QJsonObject data { { "url", requestUrl.toString() },
{ "callerId", callerId },
{ "extra", extra }
};

View file

@ -15,7 +15,6 @@
#include <QNetworkRequest>
#include "DependencyManager.h"
#include "QUrlAncestry.h"
class ResourceRequestObserver : public QObject, public Dependency {
@ -23,8 +22,7 @@ class ResourceRequestObserver : public QObject, public Dependency {
SINGLETON_DEPENDENCY
public:
// void update(const QNetworkRequest& request, const qint64 callerId = -1, const QString& extra = "");
void update(const QUrlAncestry& urlAncestry, const qint64 callerId = -1, const QString& extra = "");
void update(const QUrl& requestUrl, const qint64 callerId = -1, const QString& extra = "");
signals:
void resourceRequestEvent(QVariantMap result);