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

Side by Side Diff: net/url_request/test_url_fetcher_factory.h

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo unwanted change in comment Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 5 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 virtual void OnRequestEnd(int fetcher_id) = 0; 81 virtual void OnRequestEnd(int fetcher_id) = 0;
82 }; 82 };
83 83
84 TestURLFetcher(int id, 84 TestURLFetcher(int id,
85 const GURL& url, 85 const GURL& url,
86 URLFetcherDelegate* d); 86 URLFetcherDelegate* d);
87 virtual ~TestURLFetcher(); 87 virtual ~TestURLFetcher();
88 88
89 // URLFetcher implementation 89 // URLFetcher implementation
90 virtual void SetUploadData(const std::string& upload_content_type, 90 virtual void SetUploadData(const std::string& upload_content_type,
91 const std::string& upload_content) OVERRIDE; 91 const std::string& upload_content) override;
92 virtual void SetUploadFilePath( 92 virtual void SetUploadFilePath(
93 const std::string& upload_content_type, 93 const std::string& upload_content_type,
94 const base::FilePath& file_path, 94 const base::FilePath& file_path,
95 uint64 range_offset, 95 uint64 range_offset,
96 uint64 range_length, 96 uint64 range_length,
97 scoped_refptr<base::TaskRunner> file_task_runner) OVERRIDE; 97 scoped_refptr<base::TaskRunner> file_task_runner) override;
98 virtual void SetChunkedUpload( 98 virtual void SetChunkedUpload(
99 const std::string& upload_content_type) OVERRIDE; 99 const std::string& upload_content_type) override;
100 // Overriden to cache the chunks uploaded. Caller can read back the uploaded 100 // Overriden to cache the chunks uploaded. Caller can read back the uploaded
101 // chunks with the upload_chunks() accessor. 101 // chunks with the upload_chunks() accessor.
102 virtual void AppendChunkToUpload(const std::string& data, 102 virtual void AppendChunkToUpload(const std::string& data,
103 bool is_last_chunk) OVERRIDE; 103 bool is_last_chunk) override;
104 virtual void SetLoadFlags(int load_flags) OVERRIDE; 104 virtual void SetLoadFlags(int load_flags) override;
105 virtual int GetLoadFlags() const OVERRIDE; 105 virtual int GetLoadFlags() const override;
106 virtual void SetReferrer(const std::string& referrer) OVERRIDE; 106 virtual void SetReferrer(const std::string& referrer) override;
107 virtual void SetReferrerPolicy( 107 virtual void SetReferrerPolicy(
108 URLRequest::ReferrerPolicy referrer_policy) OVERRIDE; 108 URLRequest::ReferrerPolicy referrer_policy) override;
109 virtual void SetExtraRequestHeaders( 109 virtual void SetExtraRequestHeaders(
110 const std::string& extra_request_headers) OVERRIDE; 110 const std::string& extra_request_headers) override;
111 virtual void AddExtraRequestHeader(const std::string& header_line) OVERRIDE; 111 virtual void AddExtraRequestHeader(const std::string& header_line) override;
112 virtual void SetRequestContext( 112 virtual void SetRequestContext(
113 URLRequestContextGetter* request_context_getter) OVERRIDE; 113 URLRequestContextGetter* request_context_getter) override;
114 virtual void SetFirstPartyForCookies( 114 virtual void SetFirstPartyForCookies(
115 const GURL& first_party_for_cookies) OVERRIDE; 115 const GURL& first_party_for_cookies) override;
116 virtual void SetURLRequestUserData( 116 virtual void SetURLRequestUserData(
117 const void* key, 117 const void* key,
118 const CreateDataCallback& create_data_callback) OVERRIDE; 118 const CreateDataCallback& create_data_callback) override;
119 virtual void SetStopOnRedirect(bool stop_on_redirect) OVERRIDE; 119 virtual void SetStopOnRedirect(bool stop_on_redirect) override;
120 virtual void SetAutomaticallyRetryOn5xx(bool retry) OVERRIDE; 120 virtual void SetAutomaticallyRetryOn5xx(bool retry) override;
121 virtual void SetMaxRetriesOn5xx(int max_retries) OVERRIDE; 121 virtual void SetMaxRetriesOn5xx(int max_retries) override;
122 virtual int GetMaxRetriesOn5xx() const OVERRIDE; 122 virtual int GetMaxRetriesOn5xx() const override;
123 virtual base::TimeDelta GetBackoffDelay() const OVERRIDE; 123 virtual base::TimeDelta GetBackoffDelay() const override;
124 virtual void SetAutomaticallyRetryOnNetworkChanges(int max_retries) OVERRIDE; 124 virtual void SetAutomaticallyRetryOnNetworkChanges(int max_retries) override;
125 virtual void SaveResponseToFileAtPath( 125 virtual void SaveResponseToFileAtPath(
126 const base::FilePath& file_path, 126 const base::FilePath& file_path,
127 scoped_refptr<base::SequencedTaskRunner> file_task_runner) OVERRIDE; 127 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override;
128 virtual void SaveResponseToTemporaryFile( 128 virtual void SaveResponseToTemporaryFile(
129 scoped_refptr<base::SequencedTaskRunner> file_task_runner) OVERRIDE; 129 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override;
130 virtual void SaveResponseWithWriter( 130 virtual void SaveResponseWithWriter(
131 scoped_ptr<URLFetcherResponseWriter> response_writer) OVERRIDE; 131 scoped_ptr<URLFetcherResponseWriter> response_writer) override;
132 virtual HttpResponseHeaders* GetResponseHeaders() const OVERRIDE; 132 virtual HttpResponseHeaders* GetResponseHeaders() const override;
133 virtual HostPortPair GetSocketAddress() const OVERRIDE; 133 virtual HostPortPair GetSocketAddress() const override;
134 virtual bool WasFetchedViaProxy() const OVERRIDE; 134 virtual bool WasFetchedViaProxy() const override;
135 virtual void Start() OVERRIDE; 135 virtual void Start() override;
136 136
137 // URL we were created with. Because of how we're using URLFetcher GetURL() 137 // URL we were created with. Because of how we're using URLFetcher GetURL()
138 // always returns an empty URL. Chances are you'll want to use 138 // always returns an empty URL. Chances are you'll want to use
139 // GetOriginalURL() in your tests. 139 // GetOriginalURL() in your tests.
140 virtual const GURL& GetOriginalURL() const OVERRIDE; 140 virtual const GURL& GetOriginalURL() const override;
141 virtual const GURL& GetURL() const OVERRIDE; 141 virtual const GURL& GetURL() const override;
142 virtual const URLRequestStatus& GetStatus() const OVERRIDE; 142 virtual const URLRequestStatus& GetStatus() const override;
143 virtual int GetResponseCode() const OVERRIDE; 143 virtual int GetResponseCode() const override;
144 virtual const ResponseCookies& GetCookies() const OVERRIDE; 144 virtual const ResponseCookies& GetCookies() const override;
145 virtual void ReceivedContentWasMalformed() OVERRIDE; 145 virtual void ReceivedContentWasMalformed() override;
146 // Override response access functions to return fake data. 146 // Override response access functions to return fake data.
147 virtual bool GetResponseAsString( 147 virtual bool GetResponseAsString(
148 std::string* out_response_string) const OVERRIDE; 148 std::string* out_response_string) const override;
149 virtual bool GetResponseAsFilePath( 149 virtual bool GetResponseAsFilePath(
150 bool take_ownership, base::FilePath* out_response_path) const OVERRIDE; 150 bool take_ownership, base::FilePath* out_response_path) const override;
151 151
152 void GetExtraRequestHeaders(HttpRequestHeaders* headers) const; 152 void GetExtraRequestHeaders(HttpRequestHeaders* headers) const;
153 153
154 // Sets owner of this class. Set it to a non-NULL value if you want 154 // Sets owner of this class. Set it to a non-NULL value if you want
155 // to automatically unregister this fetcher from the owning factory 155 // to automatically unregister this fetcher from the owning factory
156 // upon destruction. 156 // upon destruction.
157 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; } 157 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; }
158 158
159 // Unique ID in our factory. 159 // Unique ID in our factory.
160 int id() const { return id_; } 160 int id() const { return id_; }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 class TestURLFetcherFactory : public URLFetcherFactory, 240 class TestURLFetcherFactory : public URLFetcherFactory,
241 public ScopedURLFetcherFactory { 241 public ScopedURLFetcherFactory {
242 public: 242 public:
243 TestURLFetcherFactory(); 243 TestURLFetcherFactory();
244 virtual ~TestURLFetcherFactory(); 244 virtual ~TestURLFetcherFactory();
245 245
246 virtual URLFetcher* CreateURLFetcher( 246 virtual URLFetcher* CreateURLFetcher(
247 int id, 247 int id,
248 const GURL& url, 248 const GURL& url,
249 URLFetcher::RequestType request_type, 249 URLFetcher::RequestType request_type,
250 URLFetcherDelegate* d) OVERRIDE; 250 URLFetcherDelegate* d) override;
251 TestURLFetcher* GetFetcherByID(int id) const; 251 TestURLFetcher* GetFetcherByID(int id) const;
252 void RemoveFetcherFromMap(int id); 252 void RemoveFetcherFromMap(int id);
253 void SetDelegateForTests(TestURLFetcherDelegateForTests* delegate_for_tests); 253 void SetDelegateForTests(TestURLFetcherDelegateForTests* delegate_for_tests);
254 void set_remove_fetcher_on_delete(bool remove_fetcher_on_delete) { 254 void set_remove_fetcher_on_delete(bool remove_fetcher_on_delete) {
255 remove_fetcher_on_delete_ = remove_fetcher_on_delete; 255 remove_fetcher_on_delete_ = remove_fetcher_on_delete;
256 } 256 }
257 257
258 private: 258 private:
259 // Maps from id passed to create to the returned URLFetcher. 259 // Maps from id passed to create to the returned URLFetcher.
260 typedef std::map<int, TestURLFetcher*> Fetchers; 260 typedef std::map<int, TestURLFetcher*> Fetchers;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 public: 292 public:
293 // Normal URL fetcher constructor but also takes in a pre-baked response. 293 // Normal URL fetcher constructor but also takes in a pre-baked response.
294 FakeURLFetcher(const GURL& url, 294 FakeURLFetcher(const GURL& url,
295 URLFetcherDelegate* d, 295 URLFetcherDelegate* d,
296 const std::string& response_data, 296 const std::string& response_data,
297 HttpStatusCode response_code, 297 HttpStatusCode response_code,
298 URLRequestStatus::Status status); 298 URLRequestStatus::Status status);
299 299
300 // Start the request. This will call the given delegate asynchronously 300 // Start the request. This will call the given delegate asynchronously
301 // with the pre-baked response as parameter. 301 // with the pre-baked response as parameter.
302 virtual void Start() OVERRIDE; 302 virtual void Start() override;
303 303
304 virtual const GURL& GetURL() const OVERRIDE; 304 virtual const GURL& GetURL() const override;
305 305
306 virtual ~FakeURLFetcher(); 306 virtual ~FakeURLFetcher();
307 307
308 private: 308 private:
309 // This is the method which actually calls the delegate that is passed in the 309 // This is the method which actually calls the delegate that is passed in the
310 // constructor. 310 // constructor.
311 void RunDelegate(); 311 void RunDelegate();
312 312
313 base::WeakPtrFactory<FakeURLFetcher> weak_factory_; 313 base::WeakPtrFactory<FakeURLFetcher> weak_factory_;
314 314
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 // If no fake response is set for the given URL this method will delegate the 401 // If no fake response is set for the given URL this method will delegate the
402 // call to |default_factory_| if it is not NULL, or return NULL if it is 402 // call to |default_factory_| if it is not NULL, or return NULL if it is
403 // NULL. 403 // NULL.
404 // Otherwise, it will return a URLFetcher object which will respond with the 404 // Otherwise, it will return a URLFetcher object which will respond with the
405 // pre-baked response that the client has set by calling SetFakeResponse(). 405 // pre-baked response that the client has set by calling SetFakeResponse().
406 virtual URLFetcher* CreateURLFetcher( 406 virtual URLFetcher* CreateURLFetcher(
407 int id, 407 int id,
408 const GURL& url, 408 const GURL& url,
409 URLFetcher::RequestType request_type, 409 URLFetcher::RequestType request_type,
410 URLFetcherDelegate* d) OVERRIDE; 410 URLFetcherDelegate* d) override;
411 411
412 // Sets the fake response for a given URL. The |response_data| may be empty. 412 // Sets the fake response for a given URL. The |response_data| may be empty.
413 // The |response_code| may be any HttpStatusCode. For instance, HTTP_OK will 413 // The |response_code| may be any HttpStatusCode. For instance, HTTP_OK will
414 // return an HTTP/200 and HTTP_INTERNAL_SERVER_ERROR will return an HTTP/500. 414 // return an HTTP/200 and HTTP_INTERNAL_SERVER_ERROR will return an HTTP/500.
415 // The |status| argument may be any URLRequestStatus::Status value. Typically, 415 // The |status| argument may be any URLRequestStatus::Status value. Typically,
416 // requests that return a valid HttpStatusCode have the SUCCESS status, while 416 // requests that return a valid HttpStatusCode have the SUCCESS status, while
417 // requests that indicate a failure to connect to the server have the FAILED 417 // requests that indicate a failure to connect to the server have the FAILED
418 // status. 418 // status.
419 void SetFakeResponse(const GURL& url, 419 void SetFakeResponse(const GURL& url,
420 const std::string& response_data, 420 const std::string& response_data,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 class URLFetcherImplFactory : public URLFetcherFactory { 453 class URLFetcherImplFactory : public URLFetcherFactory {
454 public: 454 public:
455 URLFetcherImplFactory(); 455 URLFetcherImplFactory();
456 virtual ~URLFetcherImplFactory(); 456 virtual ~URLFetcherImplFactory();
457 457
458 // This method will create a real URLFetcher. 458 // This method will create a real URLFetcher.
459 virtual URLFetcher* CreateURLFetcher( 459 virtual URLFetcher* CreateURLFetcher(
460 int id, 460 int id,
461 const GURL& url, 461 const GURL& url,
462 URLFetcher::RequestType request_type, 462 URLFetcher::RequestType request_type,
463 URLFetcherDelegate* d) OVERRIDE; 463 URLFetcherDelegate* d) override;
464 }; 464 };
465 465
466 } // namespace net 466 } // namespace net
467 467
468 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 468 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « net/url_request/static_http_user_agent_settings.h ('k') | net/url_request/test_url_request_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698