OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_COMPONENT_UPDATER_REQUEST_SENDER_H_ | |
6 #define COMPONENTS_COMPONENT_UPDATER_REQUEST_SENDER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #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.
| |
12 #include "base/callback.h" | |
13 #include "base/compiler_specific.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #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.
| |
16 #include "net/url_request/url_fetcher_delegate.h" | |
17 #include "url/gurl.h" | |
18 | |
19 namespace component_updater { | |
20 | |
21 class Configurator; | |
22 | |
23 // Sends a request to one of the urls provided. The class implements a chain | |
24 // of responsibility design pattern, where the urls are tried in the order they | |
25 // are specified, until the request to one of them succeeds or all have failed. | |
26 class RequestSender : public net::URLFetcherDelegate { | |
27 public: | |
28 // The |source| refers to the fetcher object used to make the request. This | |
29 // parameter can be NULL in some error cases. | |
30 typedef base::Callback<void(const net::URLFetcher* source)> | |
31 RequestSenderCallback; | |
32 | |
33 explicit RequestSender(const Configurator& config); | |
34 virtual ~RequestSender(); | |
35 | |
36 void Send(const std::string& request_string, | |
37 const std::vector<GURL>& urls, | |
38 const RequestSenderCallback& request_sender_callback); | |
39 | |
40 private: | |
41 void SendInternal(); | |
42 | |
43 // Overrides for URLFetcherDelegate. | |
44 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
45 | |
46 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.
| |
47 std::vector<GURL> urls_; | |
48 std::vector<GURL>::const_iterator cur_url_; | |
49 scoped_ptr<net::URLFetcher> url_fetcher_; | |
50 std::string request_string_; | |
51 RequestSenderCallback request_sender_callback_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(RequestSender); | |
54 }; | |
55 | |
56 } // namespace component_updater | |
57 | |
58 #endif // COMPONENTS_COMPONENT_UPDATER_REQUEST_SENDER_H_ | |
OLD | NEW |