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

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

Issue 12088104: Move DownloadFileOperation to base_operations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148627_download_file_3_test_util
Patch Set: Rebase Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_operations.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 implement operations for Google APIs. 5 // This file provides base classes used to implement operations for Google APIs.
6 6
7 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
8 #define CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ 8 #define CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 scoped_ptr<base::Value> value); 251 scoped_ptr<base::Value> value);
252 252
253 const GetDataCallback callback_; 253 const GetDataCallback callback_;
254 254
255 // Note: This should remain the last member so it'll be destroyed and 255 // Note: This should remain the last member so it'll be destroyed and
256 // invalidate its weak pointers before any other members are destroyed. 256 // invalidate its weak pointers before any other members are destroyed.
257 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; 257 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_;
258 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); 258 DISALLOW_COPY_AND_ASSIGN(GetDataOperation);
259 }; 259 };
260 260
261 //============================ DownloadFileOperation ===========================
262
263 // Callback type for DownloadHostedDocument/DownloadFile
264 // DocumentServiceInterface calls.
265 typedef base::Callback<void(GDataErrorCode error,
266 const FilePath& temp_file)> DownloadActionCallback;
267
268 // This class performs the operation for downloading of a given document/file.
269 class DownloadFileOperation : public UrlFetchOperationBase {
270 public:
271 // download_action_callback:
272 // This callback is called when the download is complete. Must not be null.
273 //
274 // get_content_callback:
275 // This callback is called when some part of the content is
276 // read. Used to read the download content progressively. May be null.
277 //
278 // download_url:
279 // Specifies the target file to download.
280 //
281 // drive_file_path:
282 // Specifies the drive path of the target file. Shown in UI.
283 // TODO(satorux): Remove the drive file path hack. crbug.com/163296
284 //
285 // output_file_path:
286 // Specifies the file path to save the downloaded file.
287 //
288 DownloadFileOperation(
289 OperationRegistry* registry,
290 net::URLRequestContextGetter* url_request_context_getter,
291 const DownloadActionCallback& download_action_callback,
292 const GetContentCallback& get_content_callback,
293 const GURL& download_url,
294 const FilePath& drive_file_path,
295 const FilePath& output_file_path);
296 virtual ~DownloadFileOperation();
297
298 protected:
299 // UrlFetchOperationBase overrides.
300 virtual GURL GetURL() const OVERRIDE;
301 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
302 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
303
304 // net::URLFetcherDelegate overrides.
305 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
306 int64 current, int64 total) OVERRIDE;
307 virtual bool ShouldSendDownloadData() OVERRIDE;
308 virtual void OnURLFetchDownloadData(
309 const net::URLFetcher* source,
310 scoped_ptr<std::string> download_data) OVERRIDE;
311
312 private:
313 const DownloadActionCallback download_action_callback_;
314 const GetContentCallback get_content_callback_;
315 const GURL download_url_;
316
317 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation);
318 };
319
261 } // namespace google_apis 320 } // namespace google_apis
262 321
263 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ 322 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698