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

Unified Diff: components/update_client/request_sender.h

Issue 1685323002: Implement CUP signing in UpdateClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and remove duplicated code comment. Created 4 years, 10 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
« no previous file with comments | « components/update_client/ping_manager.cc ('k') | components/update_client/request_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/request_sender.h
diff --git a/components/update_client/request_sender.h b/components/update_client/request_sender.h
index b6ec23b714c77a9cec1793c0dc53ef9cacd847aa..71b41ee538dc56f4d92b74fff9e0a5dc620d1e05 100644
--- a/components/update_client/request_sender.h
+++ b/components/update_client/request_sender.h
@@ -22,39 +22,69 @@ class URLFetcher;
namespace update_client {
+class ClientUpdateProtocolEcdsa;
class Configurator;
// Sends a request to one of the urls provided. The class implements a chain
// of responsibility design pattern, where the urls are tried in the order they
// are specified, until the request to one of them succeeds or all have failed.
+// CUP signing is optional.
class RequestSender : public net::URLFetcherDelegate {
public:
- // The |source| refers to the fetcher object used to make the request. This
- // parameter can be NULL in some error cases.
- typedef base::Callback<void(const net::URLFetcher* source)>
- RequestSenderCallback;
+ // If |error| is 0, then the response is provided in the |response| parameter.
+ using RequestSenderCallback =
+ base::Callback<void(int error, const std::string& response)>;
+
+ static int kErrorResponseNotTrusted;
explicit RequestSender(const scoped_refptr<Configurator>& config);
~RequestSender() override;
- void Send(const std::string& request_string,
+ // |use_signing| enables CUP signing of protocol messages exchanged using
+ // this class.
+ void Send(bool use_signing,
+ const std::string& request_body,
const std::vector<GURL>& urls,
const RequestSenderCallback& request_sender_callback);
private:
- void SendInternal();
+ // Combines the |url| and |query_params| parameters.
+ static GURL BuildUpdateUrl(const GURL& url, const std::string& query_params);
+
+ // Decodes and returns the public key used by CUP.
+ static std::string GetKey(const char* key_bytes_base64);
+
+ // Returns the Etag of the server response or an empty string if the
+ // Etag is not available.
+ static std::string GetServerETag(const net::URLFetcher* source);
// Overrides for URLFetcherDelegate.
void OnURLFetchComplete(const net::URLFetcher* source) override;
+ // Implements the error handling and url fallback mechanism.
+ void SendInternal();
+
+ // Called when SendInternal complets. |response_body|and |response_etag|
+ // contain the body and the etag associated with the HTTP response.
+ void SendInternalComplete(int error,
+ const std::string& response_body,
+ const std::string& response_etag);
+
+ // Helper function to handle a non-continuable error in Send.
+ void HandleSendError(int error);
+
+ base::ThreadChecker thread_checker_;
+
const scoped_refptr<Configurator> config_;
+ bool use_signing_;
std::vector<GURL> urls_;
- std::vector<GURL>::const_iterator cur_url_;
- scoped_ptr<net::URLFetcher> url_fetcher_;
- std::string request_string_;
+ std::string request_body_;
RequestSenderCallback request_sender_callback_;
- base::ThreadChecker thread_checker_;
+ std::string public_key_;
+ std::vector<GURL>::const_iterator cur_url_;
+ scoped_ptr<net::URLFetcher> url_fetcher_;
+ scoped_ptr<ClientUpdateProtocolEcdsa> signer_;
DISALLOW_COPY_AND_ASSIGN(RequestSender);
};
« no previous file with comments | « components/update_client/ping_manager.cc ('k') | components/update_client/request_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698