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

Side by Side Diff: chrome/browser/chromeos/gdata/operations_base.h

Issue 10855034: Drive: Remove gdata_params.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review (#16) fix & rebase Created 8 years, 4 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 | « chrome/browser/chromeos/gdata/mock_gdata_file_system.h ('k') | chrome/chrome_browser.gypi » ('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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h"
12 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
11 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" 13 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
12 #include "chrome/browser/chromeos/gdata/gdata_params.h"
13 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h" 14 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h"
15 #include "googleurl/src/gurl.h"
14 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
15 #include "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
16 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
17 19
18 class OAuth2AccessTokenFetcher; 20 class OAuth2AccessTokenFetcher;
19 21
20 namespace gdata { 22 namespace gdata {
21 23
22 //================================ AuthOperation =============================== 24 //================================ AuthOperation ===============================
23 25
26 // Callback type for authentication related DocumentService calls.
27 typedef base::Callback<void(GDataErrorCode error,
28 const std::string& token)> AuthStatusCallback;
29
24 // OAuth2 authorization token retrieval operation. 30 // OAuth2 authorization token retrieval operation.
25 class AuthOperation : public GDataOperationRegistry::Operation, 31 class AuthOperation : public GDataOperationRegistry::Operation,
26 public OAuth2AccessTokenConsumer { 32 public OAuth2AccessTokenConsumer {
27 public: 33 public:
28 AuthOperation(GDataOperationRegistry* registry, 34 AuthOperation(GDataOperationRegistry* registry,
29 const AuthStatusCallback& callback, 35 const AuthStatusCallback& callback,
30 const std::string& refresh_token); 36 const std::string& refresh_token);
31 virtual ~AuthOperation(); 37 virtual ~AuthOperation();
32 void Start(); 38 void Start();
33 39
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 virtual void OnAuthFailed(GDataErrorCode code) = 0; 72 virtual void OnAuthFailed(GDataErrorCode code) = 0;
67 73
68 // Sets the callback to DocumentsService when the operation restarts due to 74 // Sets the callback to DocumentsService when the operation restarts due to
69 // an authentication failure. 75 // an authentication failure.
70 virtual void SetReAuthenticateCallback( 76 virtual void SetReAuthenticateCallback(
71 const ReAuthenticateCallback& callback) = 0; 77 const ReAuthenticateCallback& callback) = 0;
72 }; 78 };
73 79
74 //============================ UrlFetchOperationBase =========================== 80 //============================ UrlFetchOperationBase ===========================
75 81
82 // Callback type for getting the content from URLFetcher::GetResponseAsString().
83 typedef base::Callback<void(
84 GDataErrorCode error,
85 scoped_ptr<std::string> content)> GetContentCallback;
86
76 // Base class for operations that are fetching URLs. 87 // Base class for operations that are fetching URLs.
77 class UrlFetchOperationBase : public GDataOperationInterface, 88 class UrlFetchOperationBase : public GDataOperationInterface,
78 public GDataOperationRegistry::Operation, 89 public GDataOperationRegistry::Operation,
79 public net::URLFetcherDelegate { 90 public net::URLFetcherDelegate {
80 public: 91 public:
81 // Overridden from GDataOperationInterface. 92 // Overridden from GDataOperationInterface.
82 virtual void Start(const std::string& auth_token) OVERRIDE; 93 virtual void Start(const std::string& auth_token) OVERRIDE;
83 94
84 // Overridden from GDataOperationInterface. 95 // Overridden from GDataOperationInterface.
85 virtual void SetReAuthenticateCallback( 96 virtual void SetReAuthenticateCallback(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ReAuthenticateCallback re_authenticate_callback_; 153 ReAuthenticateCallback re_authenticate_callback_;
143 int re_authenticate_count_; 154 int re_authenticate_count_;
144 bool save_temp_file_; 155 bool save_temp_file_;
145 FilePath output_file_path_; 156 FilePath output_file_path_;
146 scoped_ptr<net::URLFetcher> url_fetcher_; 157 scoped_ptr<net::URLFetcher> url_fetcher_;
147 bool started_; 158 bool started_;
148 }; 159 };
149 160
150 //============================ EntryActionOperation ============================ 161 //============================ EntryActionOperation ============================
151 162
163 // Callback type for Delete/Move DocumentServiceInterface calls.
164 typedef base::Callback<void(GDataErrorCode error,
165 const GURL& document_url)> EntryActionCallback;
166
152 // This class performs a simple action over a given entry (document/file). 167 // This class performs a simple action over a given entry (document/file).
153 // It is meant to be used for operations that return no JSON blobs. 168 // It is meant to be used for operations that return no JSON blobs.
154 class EntryActionOperation : public UrlFetchOperationBase { 169 class EntryActionOperation : public UrlFetchOperationBase {
155 public: 170 public:
156 EntryActionOperation(GDataOperationRegistry* registry, 171 EntryActionOperation(GDataOperationRegistry* registry,
157 const EntryActionCallback& callback, 172 const EntryActionCallback& callback,
158 const GURL& document_url); 173 const GURL& document_url);
159 virtual ~EntryActionOperation(); 174 virtual ~EntryActionOperation();
160 175
161 protected: 176 protected:
162 // Overridden from UrlFetchOperationBase. 177 // Overridden from UrlFetchOperationBase.
163 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; 178 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
164 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; 179 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
165 180
166 const GURL& document_url() const { return document_url_; } 181 const GURL& document_url() const { return document_url_; }
167 182
168 private: 183 private:
169 EntryActionCallback callback_; 184 EntryActionCallback callback_;
170 GURL document_url_; 185 GURL document_url_;
171 186
172 DISALLOW_COPY_AND_ASSIGN(EntryActionOperation); 187 DISALLOW_COPY_AND_ASSIGN(EntryActionOperation);
173 }; 188 };
174 189
175 //============================== GetDataOperation ============================== 190 //============================== GetDataOperation ==============================
176 191
192 // Callback type for DocumentServiceInterface::GetDocuments.
193 // Note: feed_data argument should be passed using base::Passed(&feed_data), not
194 // feed_data.Pass().
195 typedef base::Callback<void(GDataErrorCode error,
196 scoped_ptr<base::Value> feed_data)> GetDataCallback;
197
177 // This class performs the operation for fetching and parsing JSON data content. 198 // This class performs the operation for fetching and parsing JSON data content.
178 class GetDataOperation : public UrlFetchOperationBase { 199 class GetDataOperation : public UrlFetchOperationBase {
179 public: 200 public:
180 GetDataOperation(GDataOperationRegistry* registry, 201 GetDataOperation(GDataOperationRegistry* registry,
181 const GetDataCallback& callback); 202 const GetDataCallback& callback);
182 virtual ~GetDataOperation(); 203 virtual ~GetDataOperation();
183 204
184 // Parse GData JSON response. 205 // Parse GData JSON response.
185 virtual void ParseResponse(GDataErrorCode fetch_error_code, 206 virtual void ParseResponse(GDataErrorCode fetch_error_code,
186 const std::string& data); 207 const std::string& data);
(...skipping 15 matching lines...) Expand all
202 223
203 // Note: This should remain the last member so it'll be destroyed and 224 // Note: This should remain the last member so it'll be destroyed and
204 // invalidate its weak pointers before any other members are destroyed. 225 // invalidate its weak pointers before any other members are destroyed.
205 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; 226 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_;
206 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); 227 DISALLOW_COPY_AND_ASSIGN(GetDataOperation);
207 }; 228 };
208 229
209 } // namespace gdata 230 } // namespace gdata
210 231
211 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 232 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/mock_gdata_file_system.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698