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

Side by Side Diff: chrome/browser/chromeos/drive/drive_download_observer.h

Issue 11369019: chromeos: Stop exposing DriveDownloadObserver::GetDriveTempDownloadPath (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/chromeos/drive/drive_download_observer.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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_DOWNLOAD_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_DOWNLOAD_OBSERVER_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_DOWNLOAD_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_DOWNLOAD_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/drive_file_error.h" 12 #include "chrome/browser/chromeos/drive/drive_file_error.h"
13 #include "chrome/browser/google_apis/drive_uploader.h" 13 #include "chrome/browser/google_apis/drive_uploader.h"
14 #include "chrome/browser/google_apis/gdata_errorcode.h" 14 #include "chrome/browser/google_apis/gdata_errorcode.h"
15 #include "content/public/browser/download_item.h" 15 #include "content/public/browser/download_item.h"
16 #include "content/public/browser/download_manager.h" 16 #include "content/public/browser/download_manager.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 class Profile; 19 class Profile;
20 20
21 namespace google_apis { 21 namespace google_apis {
22 class DocumentEntry; 22 class DocumentEntry;
23 class DriveUploader;
24 } 23 }
25 24
26 namespace drive { 25 namespace drive {
27 26
28 class DriveEntryProto; 27 class DriveEntryProto;
29 class DriveFileSystemInterface; 28 class DriveFileSystemInterface;
30 29
31 // Observes downloads to temporary local drive folder. Schedules these 30 // Observes downloads to temporary local drive folder. Schedules these
32 // downloads for upload to drive service. 31 // downloads for upload to drive service.
33 class DriveDownloadObserver : public content::DownloadManager::Observer, 32 class DriveDownloadObserver : public content::DownloadManager::Observer,
34 public content::DownloadItem::Observer { 33 public content::DownloadItem::Observer {
35 public: 34 public:
36 DriveDownloadObserver(google_apis::DriveUploader* uploader, 35 DriveDownloadObserver(google_apis::DriveUploader* uploader,
37 DriveFileSystemInterface* file_system); 36 DriveFileSystemInterface* file_system);
38 virtual ~DriveDownloadObserver(); 37 virtual ~DriveDownloadObserver();
39 38
40 // Become an observer of DownloadManager. 39 // Become an observer of DownloadManager.
41 void Initialize(content::DownloadManager* download_manager, 40 void Initialize(content::DownloadManager* download_manager,
42 const FilePath& drive_tmp_download_path); 41 const FilePath& drive_tmp_download_path);
43 42
44 typedef base::Callback<void(const FilePath&)> 43 typedef base::Callback<void(const FilePath&)>
45 SubstituteDriveDownloadPathCallback; 44 SubstituteDriveDownloadPathCallback;
46 static void SubstituteDriveDownloadPath(Profile* profile, 45 static void SubstituteDriveDownloadPath(
47 const FilePath& drive_path, content::DownloadItem* download, 46 Profile* profile,
47 const FilePath& drive_path,
48 content::DownloadItem* download,
48 const SubstituteDriveDownloadPathCallback& callback); 49 const SubstituteDriveDownloadPathCallback& callback);
49 50
50 // Sets drive path, for example, '/special/drive/MyFolder/MyFile', 51 // Sets drive path, for example, '/special/drive/MyFolder/MyFile',
51 // to external data in |download|. Also sets display name and 52 // to external data in |download|. Also sets display name and
52 // makes |download| a temporary. 53 // makes |download| a temporary.
53 static void SetDownloadParams(const FilePath& drive_path, 54 static void SetDownloadParams(const FilePath& drive_path,
54 content::DownloadItem* download); 55 content::DownloadItem* download);
55 56
56 // Gets the drive_path from external data in |download|. 57 // Gets the drive_path from external data in |download|.
57 // GetDrivePath may return an empty path in case SetDrivePath was not 58 // GetDrivePath may return an empty path in case SetDrivePath was not
58 // previously called or there was some other internal error 59 // previously called or there was some other internal error
59 // (there is a DCHECK for this). 60 // (there is a DCHECK for this).
60 static FilePath GetDrivePath(const content::DownloadItem* download); 61 static FilePath GetDrivePath(const content::DownloadItem* download);
61 62
62 // Checks if there is a Drive upload associated with |download| 63 // Checks if there is a Drive upload associated with |download|
63 static bool IsDriveDownload(const content::DownloadItem* download); 64 static bool IsDriveDownload(const content::DownloadItem* download);
64 65
65 // Checks if |download| is ready to complete. Returns true if |download| has 66 // Checks if |download| is ready to complete. Returns true if |download| has
66 // no Drive upload associated with it or if the Drive upload has already 67 // no Drive upload associated with it or if the Drive upload has already
67 // completed. This method is called by the ChromeDownloadManagerDelegate to 68 // completed. This method is called by the ChromeDownloadManagerDelegate to
68 // check if the download is ready to complete. If the download is not yet 69 // check if the download is ready to complete. If the download is not yet
69 // ready to complete and |complete_callback| is not null, then 70 // ready to complete and |complete_callback| is not null, then
70 // |complete_callback| will be called on the UI thread when the download 71 // |complete_callback| will be called on the UI thread when the download
71 // becomes ready to complete. If this method is called multiple times with 72 // becomes ready to complete. If this method is called multiple times with
72 // the download not ready to complete, only the last |complete_callback| 73 // the download not ready to complete, only the last |complete_callback|
73 // passed to this method for |download| will be called. 74 // passed to this method for |download| will be called.
74 static bool IsReadyToComplete( 75 static bool IsReadyToComplete(content::DownloadItem* download,
75 content::DownloadItem* download, 76 const base::Closure& complete_callback);
76 const base::Closure& complete_callback);
77 77
78 // Returns the count of bytes confirmed as uploaded so far for |download|. 78 // Returns the count of bytes confirmed as uploaded so far for |download|.
79 static int64 GetUploadedBytes(const content::DownloadItem* download); 79 static int64 GetUploadedBytes(const content::DownloadItem* download);
80 80
81 // Returns the progress of the upload of |download| as a percentage. If the 81 // Returns the progress of the upload of |download| as a percentage. If the
82 // progress is unknown, returns -1. 82 // progress is unknown, returns -1.
83 static int PercentComplete(const content::DownloadItem* download); 83 static int PercentComplete(const content::DownloadItem* download);
84 84
85 // Create a temporary file |drive_tmp_download_path| in
86 // |drive_tmp_download_dir|. Must be called on a thread that allows file
87 // operations.
88 static void GetDriveTempDownloadPath(const FilePath& drive_tmp_download_dir,
89 FilePath* drive_tmp_download_path);
90
91 private: 85 private:
92 // Structure containing arguments required to process uploading. 86 // Structure containing arguments required to process uploading.
93 // For internal use, to avoid passing all of the parameters every time 87 // For internal use, to avoid passing all of the parameters every time
94 // separately. 88 // separately.
95 struct UploaderParams { 89 struct UploaderParams {
96 UploaderParams(); 90 UploaderParams();
97 ~UploaderParams(); 91 ~UploaderParams();
98 92
99 // Useful for printf debugging. 93 // Useful for printf debugging.
100 std::string DebugString() const; 94 std::string DebugString() const;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Note: This should remain the last member so it'll be destroyed and 213 // Note: This should remain the last member so it'll be destroyed and
220 // invalidate its weak pointers before any other members are destroyed. 214 // invalidate its weak pointers before any other members are destroyed.
221 base::WeakPtrFactory<DriveDownloadObserver> weak_ptr_factory_; 215 base::WeakPtrFactory<DriveDownloadObserver> weak_ptr_factory_;
222 216
223 DISALLOW_COPY_AND_ASSIGN(DriveDownloadObserver); 217 DISALLOW_COPY_AND_ASSIGN(DriveDownloadObserver);
224 }; 218 };
225 219
226 } // namespace drive 220 } // namespace drive
227 221
228 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_DOWNLOAD_OBSERVER_H_ 222 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_DOWNLOAD_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_download_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698