Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1278)

Unified Diff: chrome/browser/local_discovery/privet_http_impl.h

Issue 320683002: Extracted PrivetV1HTTPClient with Privet v1 specific operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/local_discovery/privet_http_impl.h
diff --git a/chrome/browser/local_discovery/privet_http_impl.h b/chrome/browser/local_discovery/privet_http_impl.h
index 1fcde73cd50b64993c5130d69c439ef86385a3de..2ef4776e830266c86b91f62c4d5828a8eff09fbc 100644
--- a/chrome/browser/local_discovery/privet_http_impl.h
+++ b/chrome/browser/local_discovery/privet_http_impl.h
@@ -21,12 +21,12 @@ struct PwgRasterSettings;
namespace local_discovery {
-class PrivetHTTPClientImpl;
+class PrivetHTTPClient;
class PrivetInfoOperationImpl : public PrivetJSONOperation,
public PrivetURLFetcher::Delegate {
public:
- PrivetInfoOperationImpl(PrivetHTTPClientImpl* privet_client,
+ PrivetInfoOperationImpl(PrivetHTTPClient* privet_client,
const PrivetJSONOperation::ResultCallback& callback);
virtual ~PrivetInfoOperationImpl();
@@ -41,7 +41,7 @@ class PrivetInfoOperationImpl : public PrivetJSONOperation,
bool has_error) OVERRIDE;
private:
- PrivetHTTPClientImpl* privet_client_;
+ PrivetHTTPClient* privet_client_;
PrivetJSONOperation::ResultCallback callback_;
scoped_ptr<PrivetURLFetcher> url_fetcher_;
};
@@ -51,7 +51,7 @@ class PrivetRegisterOperationImpl
public PrivetURLFetcher::Delegate,
public base::SupportsWeakPtr<PrivetRegisterOperationImpl> {
public:
- PrivetRegisterOperationImpl(PrivetHTTPClientImpl* privet_client,
+ PrivetRegisterOperationImpl(PrivetHTTPClient* privet_client,
const std::string& user,
PrivetRegisterOperation::Delegate* delegate);
virtual ~PrivetRegisterOperationImpl();
@@ -75,8 +75,7 @@ class PrivetRegisterOperationImpl
private:
class Cancelation : public PrivetURLFetcher::Delegate {
public:
- Cancelation(PrivetHTTPClientImpl* privet_client,
- const std::string& user);
+ Cancelation(PrivetHTTPClient* privet_client, const std::string& user);
virtual ~Cancelation();
virtual void OnError(PrivetURLFetcher* fetcher,
@@ -109,7 +108,7 @@ class PrivetRegisterOperationImpl
std::string current_action_;
scoped_ptr<PrivetURLFetcher> url_fetcher_;
PrivetRegisterOperation::Delegate* delegate_;
- PrivetHTTPClientImpl* privet_client_;
+ PrivetHTTPClient* privet_client_;
ResponseHandler next_response_handler_;
// Required to ensure destroying completed register operations doesn't cause
// extraneous cancelations.
@@ -122,11 +121,10 @@ class PrivetRegisterOperationImpl
class PrivetJSONOperationImpl : public PrivetJSONOperation,
public PrivetURLFetcher::Delegate {
public:
- PrivetJSONOperationImpl(
- PrivetHTTPClientImpl* privet_client,
- const std::string& path,
- const std::string& query_params,
- const PrivetJSONOperation::ResultCallback& callback);
+ PrivetJSONOperationImpl(PrivetHTTPClient* privet_client,
+ const std::string& path,
+ const std::string& query_params,
+ const PrivetJSONOperation::ResultCallback& callback);
virtual ~PrivetJSONOperationImpl();
virtual void Start() OVERRIDE;
@@ -142,7 +140,7 @@ class PrivetJSONOperationImpl : public PrivetJSONOperation,
const PrivetURLFetcher::TokenCallback& callback) OVERRIDE;
private:
- PrivetHTTPClientImpl* privet_client_;
+ PrivetHTTPClient* privet_client_;
std::string path_;
std::string query_params_;
PrivetJSONOperation::ResultCallback callback_;
@@ -154,7 +152,7 @@ class PrivetDataReadOperationImpl : public PrivetDataReadOperation,
public PrivetURLFetcher::Delegate {
public:
PrivetDataReadOperationImpl(
- PrivetHTTPClientImpl* privet_client,
+ PrivetHTTPClient* privet_client,
const std::string& path,
const std::string& query_params,
const PrivetDataReadOperation::ResultCallback& callback);
@@ -182,7 +180,7 @@ class PrivetDataReadOperationImpl : public PrivetDataReadOperation,
const base::FilePath& file_path) OVERRIDE;
private:
- PrivetHTTPClientImpl* privet_client_;
+ PrivetHTTPClient* privet_client_;
std::string path_;
std::string query_params_;
int range_start_;
@@ -199,9 +197,8 @@ class PrivetLocalPrintOperationImpl
: public PrivetLocalPrintOperation,
public PrivetURLFetcher::Delegate {
public:
- PrivetLocalPrintOperationImpl(
- PrivetHTTPClientImpl* privet_client,
- PrivetLocalPrintOperation::Delegate* delegate);
+ PrivetLocalPrintOperationImpl(PrivetHTTPClient* privet_client,
+ PrivetLocalPrintOperation::Delegate* delegate);
virtual ~PrivetLocalPrintOperationImpl();
virtual void Start() OVERRIDE;
@@ -253,7 +250,7 @@ class PrivetLocalPrintOperationImpl
void OnPWGRasterConverted(bool success, const base::FilePath& pwg_file_path);
void FillPwgRasterSettings(printing::PwgRasterSettings* transfrom_settings);
- PrivetHTTPClientImpl* privet_client_;
+ PrivetHTTPClient* privet_client_;
PrivetLocalPrintOperation::Delegate* delegate_;
ResponseCallback current_response_;
@@ -293,48 +290,60 @@ class PrivetHTTPClientImpl : public PrivetHTTPClient {
net::URLRequestContextGetter* request_context);
virtual ~PrivetHTTPClientImpl();
- virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation(
- const std::string& user,
- PrivetRegisterOperation::Delegate* delegate) OVERRIDE;
-
+ // PrivetHTTPClient implementation.
+ virtual const std::string& GetName() OVERRIDE;
virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation(
const PrivetJSONOperation::ResultCallback& callback) OVERRIDE;
+ virtual scoped_ptr<PrivetURLFetcher> CreateURLFetcher(
+ const GURL& url,
+ net::URLFetcher::RequestType request_type,
+ PrivetURLFetcher::Delegate* delegate) OVERRIDE;
+ virtual void RefreshPrivetToken(
+ const PrivetURLFetcher::TokenCallback& token_callback) OVERRIDE;
+
+ private:
+ typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector;
+ void OnPrivetInfoDone(const base::DictionaryValue* value);
+
+ std::string name_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_;
+ net::HostPortPair host_port_;
+
+ scoped_ptr<PrivetJSONOperation> info_operation_;
+ TokenCallbackVector token_callbacks_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrivetHTTPClientImpl);
+};
+
+class PrivetV1HTTPClientImpl : public PrivetV1HTTPClient {
+ public:
+ explicit PrivetV1HTTPClientImpl(scoped_ptr<PrivetHTTPClient> info_client);
+ virtual ~PrivetV1HTTPClientImpl();
+
+ virtual const std::string& GetName() OVERRIDE;
+ virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation(
+ const PrivetJSONOperation::ResultCallback& callback) OVERRIDE;
+ virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation(
+ const std::string& user,
+ PrivetRegisterOperation::Delegate* delegate) OVERRIDE;
virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation(
const PrivetJSONOperation::ResultCallback& callback) OVERRIDE;
-
virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation(
PrivetLocalPrintOperation::Delegate* delegate) OVERRIDE;
-
virtual scoped_ptr<PrivetJSONOperation> CreateStorageListOperation(
const std::string& path,
const PrivetJSONOperation::ResultCallback& callback) OVERRIDE;
-
virtual scoped_ptr<PrivetDataReadOperation> CreateStorageReadOperation(
const std::string& path,
const PrivetDataReadOperation::ResultCallback& callback) OVERRIDE;
- virtual const std::string& GetName() OVERRIDE;
-
- scoped_ptr<PrivetURLFetcher> CreateURLFetcher(
- const GURL& url,
- net::URLFetcher::RequestType request_type,
- PrivetURLFetcher::Delegate* delegate) const;
-
- void RefreshPrivetToken(
- const PrivetURLFetcher::TokenCallback& token_callback);
-
private:
- typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector;
-
- void OnPrivetInfoDone(const base::DictionaryValue* value);
+ PrivetHTTPClient* info_client() { return info_client_.get(); }
- std::string name_;
- scoped_refptr<net::URLRequestContextGetter> request_context_;
- net::HostPortPair host_port_;
+ scoped_ptr<PrivetHTTPClient> info_client_;
- scoped_ptr<PrivetJSONOperation> info_operation_;
- TokenCallbackVector token_callbacks_;
+ DISALLOW_COPY_AND_ASSIGN(PrivetV1HTTPClientImpl);
};
} // namespace local_discovery

Powered by Google App Engine
This is Rietveld 408576698