Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / net / url_request / url_fetcher_impl.h
blobf0a57afa179314a6154e5715884a95f1a3bdb0e9
1 // Copyright (c) 2012 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 // This file contains URLFetcher, a wrapper around URLRequest that handles
6 // low-level details like thread safety, ref counting, and incremental buffer
7 // reading. This is useful for callers who simply want to get the data from a
8 // URL and don't care about all the nitty-gritty details.
9 //
10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a
11 // temporary situation. We will work on allowing support for multiple "io"
12 // threads per process.
14 #ifndef NET_URL_REQUEST_URL_FETCHER_IMPL_H_
15 #define NET_URL_REQUEST_URL_FETCHER_IMPL_H_
17 #include <string>
19 #include "base/basictypes.h"
20 #include "base/compiler_specific.h"
21 #include "net/base/net_export.h"
22 #include "net/url_request/url_fetcher.h"
24 namespace net {
25 class URLFetcherCore;
26 class URLFetcherDelegate;
27 class URLFetcherFactory;
29 class NET_EXPORT_PRIVATE URLFetcherImpl : public URLFetcher {
30 public:
31 // |url| is the URL to send the request to.
32 // |request_type| is the type of request to make.
33 // |d| the object that will receive the callback on fetch completion.
34 URLFetcherImpl(const GURL& url,
35 RequestType request_type,
36 URLFetcherDelegate* d);
37 ~URLFetcherImpl() override;
39 // URLFetcher implementation:
40 void SetUploadData(const std::string& upload_content_type,
41 const std::string& upload_content) override;
42 void SetUploadFilePath(
43 const std::string& upload_content_type,
44 const base::FilePath& file_path,
45 uint64 range_offset,
46 uint64 range_length,
47 scoped_refptr<base::TaskRunner> file_task_runner) override;
48 void SetChunkedUpload(const std::string& upload_content_type) override;
49 void AppendChunkToUpload(const std::string& data,
50 bool is_last_chunk) override;
51 void SetLoadFlags(int load_flags) override;
52 int GetLoadFlags() const override;
53 void SetReferrer(const std::string& referrer) override;
54 void SetReferrerPolicy(URLRequest::ReferrerPolicy referrer_policy) override;
55 void SetExtraRequestHeaders(
56 const std::string& extra_request_headers) override;
57 void AddExtraRequestHeader(const std::string& header_line) override;
58 void SetRequestContext(
59 URLRequestContextGetter* request_context_getter) override;
60 void SetFirstPartyForCookies(const GURL& first_party_for_cookies) override;
61 void SetURLRequestUserData(
62 const void* key,
63 const CreateDataCallback& create_data_callback) override;
64 void SetStopOnRedirect(bool stop_on_redirect) override;
65 void SetAutomaticallyRetryOn5xx(bool retry) override;
66 void SetMaxRetriesOn5xx(int max_retries) override;
67 int GetMaxRetriesOn5xx() const override;
68 base::TimeDelta GetBackoffDelay() const override;
69 void SetAutomaticallyRetryOnNetworkChanges(int max_retries) override;
70 void SaveResponseToFileAtPath(
71 const base::FilePath& file_path,
72 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override;
73 void SaveResponseToTemporaryFile(
74 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override;
75 void SaveResponseWithWriter(
76 scoped_ptr<URLFetcherResponseWriter> response_writer) override;
77 HttpResponseHeaders* GetResponseHeaders() const override;
78 HostPortPair GetSocketAddress() const override;
79 bool WasFetchedViaProxy() const override;
80 void Start() override;
81 const GURL& GetOriginalURL() const override;
82 const GURL& GetURL() const override;
83 const URLRequestStatus& GetStatus() const override;
84 int GetResponseCode() const override;
85 const ResponseCookies& GetCookies() const override;
86 void ReceivedContentWasMalformed() override;
87 bool GetResponseAsString(std::string* out_response_string) const override;
88 bool GetResponseAsFilePath(bool take_ownership,
89 base::FilePath* out_response_path) const override;
91 static void CancelAll();
93 static void SetIgnoreCertificateRequests(bool ignored);
95 // TODO(akalin): Make these private again once URLFetcher::Create()
96 // is in net/.
98 static URLFetcherFactory* factory();
100 // Sets the factory used by the static method Create to create a URLFetcher.
101 // URLFetcher does not take ownership of |factory|. A value of NULL results
102 // in a URLFetcher being created directly.
104 // NOTE: for safety, this should only be used through ScopedURLFetcherFactory!
105 static void set_factory(URLFetcherFactory* factory);
107 protected:
108 // Returns the delegate.
109 URLFetcherDelegate* delegate() const;
111 private:
112 friend class URLFetcherTest;
114 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects
115 // actively running.
116 static int GetNumFetcherCores();
118 const scoped_refptr<URLFetcherCore> core_;
120 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl);
123 } // namespace net
125 #endif // NET_URL_REQUEST_URL_FETCHER_IMPL_H_