ExtensionInstallDialogView: fix scrolling behavior on Views (Win,Linux)
[chromium-blink-merge.git] / components / update_client / request_sender.h
blob5c05350df74e6fdbc638546b0eb3f34026900658
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.
5 #ifndef COMPONENTS_UPDATE_CLIENT_REQUEST_SENDER_H_
6 #define COMPONENTS_UPDATE_CLIENT_REQUEST_SENDER_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/threading/thread_checker.h"
16 #include "net/url_request/url_fetcher_delegate.h"
17 #include "url/gurl.h"
19 namespace net {
20 class URLFetcher;
23 namespace update_client {
25 class Configurator;
27 // Sends a request to one of the urls provided. The class implements a chain
28 // of responsibility design pattern, where the urls are tried in the order they
29 // are specified, until the request to one of them succeeds or all have failed.
30 class RequestSender : public net::URLFetcherDelegate {
31 public:
32 // The |source| refers to the fetcher object used to make the request. This
33 // parameter can be NULL in some error cases.
34 typedef base::Callback<void(const net::URLFetcher* source)>
35 RequestSenderCallback;
37 explicit RequestSender(const Configurator& config);
38 ~RequestSender() override;
40 void Send(const std::string& request_string,
41 const std::vector<GURL>& urls,
42 const RequestSenderCallback& request_sender_callback);
44 private:
45 void SendInternal();
47 // Overrides for URLFetcherDelegate.
48 void OnURLFetchComplete(const net::URLFetcher* source) override;
50 const Configurator& config_;
51 std::vector<GURL> urls_;
52 std::vector<GURL>::const_iterator cur_url_;
53 scoped_ptr<net::URLFetcher> url_fetcher_;
54 std::string request_string_;
55 RequestSenderCallback request_sender_callback_;
57 base::ThreadChecker thread_checker_;
59 DISALLOW_COPY_AND_ASSIGN(RequestSender);
62 } // namespace update_client
64 #endif // COMPONENTS_UPDATE_CLIENT_REQUEST_SENDER_H_