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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_download_observer.cc

Issue 10831363: Remove unnecessary gdata::, fix typos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" 5 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/supports_user_data.h" 9 #include "base/supports_user_data.h"
10 #include "chrome/browser/chromeos/gdata/gdata.pb.h" 10 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return static_cast<GDataUserData*>( 82 return static_cast<GDataUserData*>(
83 download->GetUserData(&kGDataPathKey)); 83 download->GetUserData(&kGDataPathKey));
84 } 84 }
85 85
86 void RunSubstituteGDataDownloadCallback( 86 void RunSubstituteGDataDownloadCallback(
87 const GDataDownloadObserver::SubstituteGDataDownloadPathCallback& callback, 87 const GDataDownloadObserver::SubstituteGDataDownloadPathCallback& callback,
88 const FilePath* file_path) { 88 const FilePath* file_path) {
89 callback.Run(*file_path); 89 callback.Run(*file_path);
90 } 90 }
91 91
92 gdata::GDataSystemService* GetSystemService(Profile* profile) { 92 GDataSystemService* GetSystemService(Profile* profile) {
93 gdata::GDataSystemService* system_service = 93 GDataSystemService* system_service =
94 gdata::GDataSystemServiceFactory::GetForProfile( 94 GDataSystemServiceFactory::GetForProfile(
95 profile ? profile : ProfileManager::GetDefaultProfile()); 95 profile ? profile : ProfileManager::GetDefaultProfile());
96 DCHECK(system_service); 96 DCHECK(system_service);
97 return system_service; 97 return system_service;
98 } 98 }
99 99
100 // Substitutes virtual gdata path for local temporary path. 100 // Substitutes virtual gdata path for local temporary path.
101 void SubstituteGDataDownloadPathInternal(Profile* profile, 101 void SubstituteGDataDownloadPathInternal(Profile* profile,
102 const GDataDownloadObserver::SubstituteGDataDownloadPathCallback& 102 const GDataDownloadObserver::SubstituteGDataDownloadPathCallback&
103 callback) { 103 callback) {
104 DVLOG(1) << "SubstituteGDataDownloadPathInternal"; 104 DVLOG(1) << "SubstituteGDataDownloadPathInternal";
105 105
106 const FilePath gdata_tmp_download_dir = GetSystemService(profile)->cache()-> 106 const FilePath gdata_tmp_download_dir = GetSystemService(profile)->cache()->
107 GetCacheDirectoryPath(gdata::GDataCache::CACHE_TYPE_TMP_DOWNLOADS); 107 GetCacheDirectoryPath(GDataCache::CACHE_TYPE_TMP_DOWNLOADS);
108 108
109 // Swap the gdata path with a local path. Local path must be created 109 // Swap the gdata path with a local path. Local path must be created
110 // on a blocking thread. 110 // on a blocking thread.
111 FilePath* gdata_tmp_download_path(new FilePath()); 111 FilePath* gdata_tmp_download_path(new FilePath());
112 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE, 112 BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE,
hashimoto 2012/08/17 08:07:02 nit: base::Bind should have the same indent as FRO
kochi 2012/08/17 08:37:12 Done.
113 base::Bind(&gdata::GDataDownloadObserver::GetGDataTempDownloadPath, 113 base::Bind(&GDataDownloadObserver::GetGDataTempDownloadPath,
114 gdata_tmp_download_dir, 114 gdata_tmp_download_dir,
115 gdata_tmp_download_path), 115 gdata_tmp_download_path),
116 base::Bind(&RunSubstituteGDataDownloadCallback, 116 base::Bind(&RunSubstituteGDataDownloadCallback,
117 callback, 117 callback,
118 base::Owned(gdata_tmp_download_path))); 118 base::Owned(gdata_tmp_download_path)));
119 } 119 }
120 120
121 // Callback for GDataFileSystem::CreateDirectory. 121 // Callback for GDataFileSystem::CreateDirectory.
122 void OnCreateDirectory(const base::Closure& substitute_callback, 122 void OnCreateDirectory(const base::Closure& substitute_callback,
123 GDataFileError error) { 123 GDataFileError error) {
124 DVLOG(1) << "OnCreateDirectory " << error; 124 DVLOG(1) << "OnCreateDirectory " << error;
125 if (error == GDATA_FILE_OK) { 125 if (error == GDATA_FILE_OK) {
126 substitute_callback.Run(); 126 substitute_callback.Run();
127 } else { 127 } else {
128 // TODO(achuith): Handle this. 128 // TODO(achuith): Handle this.
129 NOTREACHED(); 129 NOTREACHED();
130 } 130 }
131 } 131 }
132 132
133 // Callback for GDataFileSystem::GetEntryInfoByPath. 133 // Callback for GDataFileSystem::GetEntryInfoByPath.
134 void OnEntryFound(Profile* profile, 134 void OnEntryFound(Profile* profile,
135 const FilePath& gdata_dir_path, 135 const FilePath& gdata_dir_path,
136 const base::Closure& substitute_callback, 136 const base::Closure& substitute_callback,
137 GDataFileError error, 137 GDataFileError error,
138 scoped_ptr<gdata::GDataEntryProto> entry_proto) { 138 scoped_ptr<GDataEntryProto> entry_proto) {
139 if (error == GDATA_FILE_ERROR_NOT_FOUND) { 139 if (error == GDATA_FILE_ERROR_NOT_FOUND) {
140 // Destination gdata directory doesn't exist, so create it. 140 // Destination gdata directory doesn't exist, so create it.
141 const bool is_exclusive = false, is_recursive = true; 141 const bool is_exclusive = false, is_recursive = true;
142 GetSystemService(profile)->file_system()->CreateDirectory( 142 GetSystemService(profile)->file_system()->CreateDirectory(
143 gdata_dir_path, is_exclusive, is_recursive, 143 gdata_dir_path, is_exclusive, is_recursive,
144 base::Bind(&OnCreateDirectory, substitute_callback)); 144 base::Bind(&OnCreateDirectory, substitute_callback));
145 } else if (error == GDATA_FILE_OK) { 145 } else if (error == GDATA_FILE_OK) {
146 substitute_callback.Run(); 146 substitute_callback.Run();
147 } else { 147 } else {
148 // TODO(achuith): Handle this. 148 // TODO(achuith): Handle this.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 // static 207 // static
208 void GDataDownloadObserver::SubstituteGDataDownloadPath(Profile* profile, 208 void GDataDownloadObserver::SubstituteGDataDownloadPath(Profile* profile,
209 const FilePath& gdata_path, content::DownloadItem* download, 209 const FilePath& gdata_path, content::DownloadItem* download,
210 const SubstituteGDataDownloadPathCallback& callback) { 210 const SubstituteGDataDownloadPathCallback& callback) {
211 DVLOG(1) << "SubstituteGDataDownloadPath " << gdata_path.value(); 211 DVLOG(1) << "SubstituteGDataDownloadPath " << gdata_path.value();
212 212
213 SetDownloadParams(gdata_path, download); 213 SetDownloadParams(gdata_path, download);
214 214
215 if (gdata::util::IsUnderGDataMountPoint(gdata_path)) { 215 if (util::IsUnderGDataMountPoint(gdata_path)) {
216 // Can't access drive if we're not authenticated. 216 // Can't access drive if we're not authenticated.
217 // We set off a chain of callbacks as follows: 217 // We set off a chain of callbacks as follows:
218 // DocumentsService::Authenticate 218 // DocumentsService::Authenticate
219 // OnAuthenticate calls GDataFileSystem::GetEntryInfoByPath 219 // OnAuthenticate calls GDataFileSystem::GetEntryInfoByPath
220 // OnEntryFound calls GDataFileSystem::CreateDirectory (if necessary) 220 // OnEntryFound calls GDataFileSystem::CreateDirectory (if necessary)
221 // OnCreateDirectory calls SubstituteGDataDownloadPathInternal 221 // OnCreateDirectory calls SubstituteGDataDownloadPathInternal
222 GetSystemService(profile)->docs_service()->Authenticate( 222 GetSystemService(profile)->docs_service()->Authenticate(
223 base::Bind(&OnAuthenticate, profile, gdata_path, 223 base::Bind(&OnAuthenticate, profile, gdata_path,
224 base::Bind(&SubstituteGDataDownloadPathInternal, 224 base::Bind(&SubstituteGDataDownloadPathInternal,
225 profile, callback))); 225 profile, callback)));
226 } else { 226 } else {
227 callback.Run(gdata_path); 227 callback.Run(gdata_path);
228 } 228 }
229 } 229 }
230 230
231 // static 231 // static
232 void GDataDownloadObserver::SetDownloadParams(const FilePath& gdata_path, 232 void GDataDownloadObserver::SetDownloadParams(const FilePath& gdata_path,
233 DownloadItem* download) { 233 DownloadItem* download) {
234 if (!download) 234 if (!download)
235 return; 235 return;
236 236
237 if (gdata::util::IsUnderGDataMountPoint(gdata_path)) { 237 if (util::IsUnderGDataMountPoint(gdata_path)) {
238 download->SetUserData(&kGDataPathKey, 238 download->SetUserData(&kGDataPathKey,
239 new GDataUserData(gdata_path)); 239 new GDataUserData(gdata_path));
240 download->SetDisplayName(gdata_path.BaseName()); 240 download->SetDisplayName(gdata_path.BaseName());
241 download->SetIsTemporary(true); 241 download->SetIsTemporary(true);
242 } else if (IsGDataDownload(download)) { 242 } else if (IsGDataDownload(download)) {
243 // This may have been previously set if the default download folder is 243 // This may have been previously set if the default download folder is
244 // /drive, and the user has now changed the download target to a local 244 // /drive, and the user has now changed the download target to a local
245 // folder. 245 // folder.
246 download->SetUserData(&kGDataPathKey, NULL); 246 download->SetUserData(&kGDataPathKey, NULL);
247 download->SetDisplayName(gdata_path); 247 download->SetDisplayName(gdata_path);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 // use the final target path when the download item is in COMPLETE state. 575 // use the final target path when the download item is in COMPLETE state.
576 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, 576 file_system_->AddUploadedFile(UPLOAD_NEW_FILE,
577 upload_data->virtual_dir_path(), 577 upload_data->virtual_dir_path(),
578 entry.Pass(), 578 entry.Pass(),
579 download->GetTargetFilePath(), 579 download->GetTargetFilePath(),
580 GDataCache::FILE_OPERATION_MOVE, 580 GDataCache::FILE_OPERATION_MOVE,
581 base::Bind(&base::DoNothing)); 581 base::Bind(&base::DoNothing));
582 } 582 }
583 583
584 } // namespace gdata 584 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_task_executor.cc ('k') | chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698