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

Side by Side Diff: chrome/browser/google_apis/base_requests.h

Issue 17175017: Get rid of RequestRegistry (part 6): get rid of RequestRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_requests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file provides base classes used to issue HTTP requests for Google 5 // This file provides base classes used to issue HTTP requests for Google
6 // APIs. 6 // APIs.
7 7
8 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ 8 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_
9 #define CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ 9 #define CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "chrome/browser/google_apis/gdata_errorcode.h" 17 #include "chrome/browser/google_apis/gdata_errorcode.h"
18 #include "chrome/browser/google_apis/request_registry.h"
19 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
20 #include "net/url_request/url_fetcher.h" 19 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
22 21
23 namespace base { 22 namespace base {
24 class Value; 23 class Value;
25 } // namespace base 24 } // namespace base
26 25
27 namespace net { 26 namespace net {
28 class URLRequestContextGetter; 27 class URLRequestContextGetter;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 const std::string& custom_user_agent, 67 const std::string& custom_user_agent,
69 const ReAuthenticateCallback& callback) = 0; 68 const ReAuthenticateCallback& callback) = 0;
70 69
71 // Invoked when the authentication failed with an error code |code|. 70 // Invoked when the authentication failed with an error code |code|.
72 virtual void OnAuthFailed(GDataErrorCode code) = 0; 71 virtual void OnAuthFailed(GDataErrorCode code) = 0;
73 72
74 // Gets a weak pointer to this request object. Since requests may be 73 // Gets a weak pointer to this request object. Since requests may be
75 // deleted when it is canceled by user action, for posting asynchronous tasks 74 // deleted when it is canceled by user action, for posting asynchronous tasks
76 // on the authentication request object, weak pointers have to be used. 75 // on the authentication request object, weak pointers have to be used.
77 // TODO(kinaba): crbug.com/134814 use more clean life time management than 76 // TODO(kinaba): crbug.com/134814 use more clean life time management than
78 // using weak pointers, while deprecating RequestRegistry. 77 // using weak pointers, while deprecating RequestRegistry.
hashimoto 2013/06/21 08:31:54 nit: Please fix this comment.
kinaba 2013/06/21 09:12:31 Removed the part.
79 virtual base::WeakPtr<AuthenticatedRequestInterface> GetWeakPtr() = 0; 78 virtual base::WeakPtr<AuthenticatedRequestInterface> GetWeakPtr() = 0;
80 79
81 // Cancels the request. It will invoke the callback object passed in 80 // Cancels the request. It will invoke the callback object passed in
82 // each request's constructor with error code GDATA_CANCELLED. 81 // each request's constructor with error code GDATA_CANCELLED.
83 virtual void Cancel() = 0; 82 virtual void Cancel() = 0;
84 }; 83 };
85 84
86 //============================ UrlFetchRequestBase =========================== 85 //============================ UrlFetchRequestBase ===========================
87 86
88 // Base class for requests that are fetching URLs. 87 // Base class for requests that are fetching URLs.
89 class UrlFetchRequestBase : public AuthenticatedRequestInterface, 88 class UrlFetchRequestBase : public AuthenticatedRequestInterface,
90 public RequestRegistry::Request,
91 public net::URLFetcherDelegate { 89 public net::URLFetcherDelegate {
92 public: 90 public:
93 // AuthenticatedRequestInterface overrides. 91 // AuthenticatedRequestInterface overrides.
94 virtual void Start(const std::string& access_token, 92 virtual void Start(const std::string& access_token,
95 const std::string& custom_user_agent, 93 const std::string& custom_user_agent,
96 const ReAuthenticateCallback& callback) OVERRIDE; 94 const ReAuthenticateCallback& callback) OVERRIDE;
97 virtual base::WeakPtr<AuthenticatedRequestInterface> GetWeakPtr() OVERRIDE; 95 virtual base::WeakPtr<AuthenticatedRequestInterface> GetWeakPtr() OVERRIDE;
98 virtual void Cancel() OVERRIDE; 96 virtual void Cancel() OVERRIDE;
99 97
100 protected: 98 protected:
101 UrlFetchRequestBase(RequestSender* runner, 99 UrlFetchRequestBase(RequestSender* sender,
102 net::URLRequestContextGetter* url_request_context_getter); 100 net::URLRequestContextGetter* url_request_context_getter);
103 virtual ~UrlFetchRequestBase(); 101 virtual ~UrlFetchRequestBase();
104 102
105 // Gets URL for the request. 103 // Gets URL for the request.
106 virtual GURL GetURL() const = 0; 104 virtual GURL GetURL() const = 0;
107 105
108 // Returns the request type. A derived class should override this method 106 // Returns the request type. A derived class should override this method
109 // for a request type other than HTTP GET. 107 // for a request type other than HTTP GET.
110 virtual net::URLFetcher::RequestType GetRequestType() const; 108 virtual net::URLFetcher::RequestType GetRequestType() const;
111 109
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // URLFetcherDelegate overrides. 161 // URLFetcherDelegate overrides.
164 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 162 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
165 163
166 // AuthenticatedRequestInterface overrides. 164 // AuthenticatedRequestInterface overrides.
167 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE; 165 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE;
168 166
169 net::URLRequestContextGetter* url_request_context_getter_; 167 net::URLRequestContextGetter* url_request_context_getter_;
170 ReAuthenticateCallback re_authenticate_callback_; 168 ReAuthenticateCallback re_authenticate_callback_;
171 int re_authenticate_count_; 169 int re_authenticate_count_;
172 scoped_ptr<net::URLFetcher> url_fetcher_; 170 scoped_ptr<net::URLFetcher> url_fetcher_;
173 bool started_; 171 RequestSender* sender_;
174 172
175 bool save_temp_file_; 173 bool save_temp_file_;
176 base::FilePath output_file_path_; 174 base::FilePath output_file_path_;
177 175
178 // Note: This should remain the last member so it'll be destroyed and 176 // Note: This should remain the last member so it'll be destroyed and
179 // invalidate its weak pointers before any other members are destroyed. 177 // invalidate its weak pointers before any other members are destroyed.
180 base::WeakPtrFactory<UrlFetchRequestBase> weak_ptr_factory_; 178 base::WeakPtrFactory<UrlFetchRequestBase> weak_ptr_factory_;
181 }; 179 };
182 180
183 //============================ EntryActionRequest ============================ 181 //============================ EntryActionRequest ============================
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 const GetContentCallback get_content_callback_; 509 const GetContentCallback get_content_callback_;
512 const ProgressCallback progress_callback_; 510 const ProgressCallback progress_callback_;
513 const GURL download_url_; 511 const GURL download_url_;
514 512
515 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); 513 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest);
516 }; 514 };
517 515
518 } // namespace google_apis 516 } // namespace google_apis
519 517
520 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ 518 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698