Esempio n. 1
0
	virtual void getData(const RemoteFileId &downloadFileId,
			const Range &requestedRange,
			const TransferCallback &callback) {

		RequestInfo info(downloadFileId, requestedRange, callback);
		SILOG(transfer,error,"NetworkCacheLayer: "<<downloadFileId.uri()<<" range "<<requestedRange);
		std::list<RequestInfo>::iterator infoIter;
		{
			boost::unique_lock<boost::mutex> transfer_lock(mActiveTransferLock);
			infoIter = mActiveTransfers.insert(mActiveTransfers.end(), info);
		}

		mService->lookupService(downloadFileId.uri().context(),
				std::tr1::bind(&NetworkCacheLayer::gotServices, this, infoIter, _1));
	}
Esempio n. 2
0
	void doNameLookup(const Callback &cb, const URI &origNamedUri, ServiceIterator *services, ServiceIterator::ErrorType reason) {
		URI lookupUri;
		ServiceParams params;
		std::tr1::shared_ptr<NameLookupHandler> handler;
		if (mNameServ->getNextProtocol(services,reason,origNamedUri,lookupUri,params,handler)) {
			/// FIXME: Need a way of aborting a name lookup that is taking too long.
			handler->nameLookup(NULL, lookupUri,
				std::tr1::bind(&NameLookupManager::gotNameLookup, this, cb, origNamedUri, services, _1, _2, _3));
		} else {
			SILOG(transfer,warn,"None of the services registered for " <<
					origNamedUri << " were successful for NameLookup.");
			/// Hashed download.
			if (mDownloadServ) {
				mDownloadServ->lookupService(origNamedUri.context(),
					std::tr1::bind(&NameLookupManager::hashedDownload, this, cb, origNamedUri, _1));
			} else {
				cb(origNamedUri, NULL);
			}
			return;
		}
	}
Esempio n. 3
0
	/** Takes a URI, and tries to lookup the hash and download URI from it.
	 *
	 * @param namedUri A ServiceURI or a regular URI (depending on if serviceLookup is NULL)
	 * @param cb       The Callback to be called either on success or failure. */
	virtual void lookupHash(const URI &namedUri, const Callback &cb) {
		mNameServ->lookupService(namedUri.context(), std::tr1::bind(&NameLookupManager::doNameLookup,
			this, cb, namedUri, _1, ServiceIterator::SUCCESS));
	}