CLOUD: Refactor ConnectionManager/Requests system

ConnectionManager now storages Request * (not generates ids for it),
Requests have control on their RequestState, RequestIdPair is now called
Response and storages Request * with some response together.

All related classes are changed to use it in more clean and
understandable way.

Request, RequestState and Response are carefully commented/documented.
This commit is contained in:
Alexander Tkachev 2016-05-27 15:21:06 +06:00
parent 83b349a033
commit 98150beb38
20 changed files with 325 additions and 239 deletions

View file

@ -24,7 +24,6 @@
#define BACKENDS_NETWORKING_CURL_CURLREQUEST_H
#include "backends/networking/curl/request.h"
#include "backends/cloud/storage.h"
#include "common/str.h"
#include "common/array.h"
@ -34,6 +33,9 @@ namespace Networking {
class NetworkReadStream;
typedef Response<NetworkReadStream *> NetworkReadStreamResponse;
typedef Common::BaseCallback<NetworkReadStreamResponse> *NetworkReadStreamCallback;
class CurlRequest: public Request {
protected:
Common::String _url;
@ -48,12 +50,20 @@ public:
virtual void handle();
virtual void restart();
/** Replaces all headers with the passed array of headers. */
virtual void setHeaders(Common::Array<Common::String> &headers);
/** Adds a header into headers list. */
virtual void addHeader(Common::String header);
/** Adds a post field (key=value pair). */
virtual void addPostField(Common::String field);
/** Start this Request with ConnMan. Returns its ReadStream and request id. */
virtual Cloud::Storage::RequestReadStreamPair execute();
/**
* Starts this Request with ConnMan.
* @return its NetworkReadStream in NetworkReadStreamResponse.
*/
virtual NetworkReadStreamResponse execute();
};
} //end of namespace Networking