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

Unified Diff: components/component_updater/request_sender.h

Issue 565363002: Implement support for fallback update check urls in the component updater (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 3 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: components/component_updater/request_sender.h
diff --git a/components/component_updater/request_sender.h b/components/component_updater/request_sender.h
new file mode 100644
index 0000000000000000000000000000000000000000..3cf7f33a16f340722092911291ec6369e316a10a
--- /dev/null
+++ b/components/component_updater/request_sender.h
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_COMPONENT_UPDATER_REQUEST_SENDER_H_
+#define COMPONENTS_COMPONENT_UPDATER_REQUEST_SENDER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
erikwright (departed) 2014/09/15 18:37:11 I believe "base/macros.h" is preferred over "base/
Sorin Jianu 2014/09/15 22:17:57 Thank you. Fixed here and I will fix the rest of t
erikwright (departed) 2014/09/16 17:38:11 I wouldn't worry about fixing files you aren't alr
Sorin Jianu 2014/09/16 19:53:31 Acknowledged.
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/url_request/url_fetcher.h"
erikwright (departed) 2014/09/15 18:37:11 can be forward-decl.
Sorin Jianu 2014/09/15 22:17:57 Done.
+#include "net/url_request/url_fetcher_delegate.h"
+#include "url/gurl.h"
+
+namespace component_updater {
+
+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.
+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;
+
+ explicit RequestSender(const Configurator& config);
+ virtual ~RequestSender();
+
+ void Send(const std::string& request_string,
+ const std::vector<GURL>& urls,
+ const RequestSenderCallback& request_sender_callback);
+
+ private:
+ void SendInternal();
+
+ // Overrides for URLFetcherDelegate.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ const Configurator& config_;
erikwright (departed) 2014/09/15 18:37:11 reference members are not that common in the Chrom
Sorin Jianu 2014/09/15 22:17:57 Acknowledged.
+ std::vector<GURL> urls_;
+ std::vector<GURL>::const_iterator cur_url_;
+ scoped_ptr<net::URLFetcher> url_fetcher_;
+ std::string request_string_;
+ RequestSenderCallback request_sender_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(RequestSender);
+};
+
+} // namespace component_updater
+
+#endif // COMPONENTS_COMPONENT_UPDATER_REQUEST_SENDER_H_

Powered by Google App Engine
This is Rietveld 408576698