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

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

Issue 10828385: Rename DocumentsServiceInterface to DriveServiceInterface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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/documents_service_interface.h" 10 #include "chrome/browser/chromeos/gdata/drive_service_interface.h"
11 #include "chrome/browser/chromeos/gdata/gdata.pb.h" 11 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
12 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" 12 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h"
13 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 13 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
14 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" 14 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h"
15 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" 15 #include "chrome/browser/chromeos/gdata/gdata_uploader.h"
16 #include "chrome/browser/chromeos/gdata/gdata_util.h" 16 #include "chrome/browser/chromeos/gdata/gdata_util.h"
17 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" 17 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
18 #include "chrome/browser/chromeos/gdata/gdata_wapi_service.h"
kochi 2012/08/21 02:34:51 Looks like an unnecessary header sneaked in. Remov
18 #include "chrome/browser/download/download_completion_blocker.h" 19 #include "chrome/browser/download/download_completion_blocker.h"
19 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
23 using content::DownloadManager; 24 using content::DownloadManager;
24 using content::DownloadItem; 25 using content::DownloadItem;
25 26
26 namespace gdata { 27 namespace gdata {
27 namespace { 28 namespace {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 gdata_dir_path, is_exclusive, is_recursive, 145 gdata_dir_path, is_exclusive, is_recursive,
145 base::Bind(&OnCreateDirectory, substitute_callback)); 146 base::Bind(&OnCreateDirectory, substitute_callback));
146 } else if (error == GDATA_FILE_OK) { 147 } else if (error == GDATA_FILE_OK) {
147 substitute_callback.Run(); 148 substitute_callback.Run();
148 } else { 149 } else {
149 // TODO(achuith): Handle this. 150 // TODO(achuith): Handle this.
150 NOTREACHED(); 151 NOTREACHED();
151 } 152 }
152 } 153 }
153 154
154 // Callback for DocumentsServiceInterface::Authenticate. 155 // Callback for DriveServiceInterface::Authenticate.
155 void OnAuthenticate(Profile* profile, 156 void OnAuthenticate(Profile* profile,
156 const FilePath& gdata_path, 157 const FilePath& gdata_path,
157 const base::Closure& substitute_callback, 158 const base::Closure& substitute_callback,
158 GDataErrorCode error, 159 GDataErrorCode error,
159 const std::string& token) { 160 const std::string& token) {
160 DVLOG(1) << "OnAuthenticate"; 161 DVLOG(1) << "OnAuthenticate";
161 162
162 if (error == HTTP_SUCCESS) { 163 if (error == HTTP_SUCCESS) {
163 const FilePath gdata_dir_path = 164 const FilePath gdata_dir_path =
164 util::ExtractGDataPath(gdata_path.DirName()); 165 util::ExtractGDataPath(gdata_path.DirName());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void GDataDownloadObserver::SubstituteGDataDownloadPath(Profile* profile, 210 void GDataDownloadObserver::SubstituteGDataDownloadPath(Profile* profile,
210 const FilePath& gdata_path, content::DownloadItem* download, 211 const FilePath& gdata_path, content::DownloadItem* download,
211 const SubstituteGDataDownloadPathCallback& callback) { 212 const SubstituteGDataDownloadPathCallback& callback) {
212 DVLOG(1) << "SubstituteGDataDownloadPath " << gdata_path.value(); 213 DVLOG(1) << "SubstituteGDataDownloadPath " << gdata_path.value();
213 214
214 SetDownloadParams(gdata_path, download); 215 SetDownloadParams(gdata_path, download);
215 216
216 if (util::IsUnderGDataMountPoint(gdata_path)) { 217 if (util::IsUnderGDataMountPoint(gdata_path)) {
217 // Can't access drive if we're not authenticated. 218 // Can't access drive if we're not authenticated.
218 // We set off a chain of callbacks as follows: 219 // We set off a chain of callbacks as follows:
219 // DocumentsServiceInterface::Authenticate 220 // DriveServiceInterface::Authenticate
220 // OnAuthenticate calls GDataFileSystem::GetEntryInfoByPath 221 // OnAuthenticate calls GDataFileSystem::GetEntryInfoByPath
221 // OnEntryFound calls GDataFileSystem::CreateDirectory (if necessary) 222 // OnEntryFound calls GDataFileSystem::CreateDirectory (if necessary)
222 // OnCreateDirectory calls SubstituteGDataDownloadPathInternal 223 // OnCreateDirectory calls SubstituteGDataDownloadPathInternal
223 GetSystemService(profile)->docs_service()->Authenticate( 224 GetSystemService(profile)->drive_service()->Authenticate(
224 base::Bind(&OnAuthenticate, profile, gdata_path, 225 base::Bind(&OnAuthenticate, profile, gdata_path,
225 base::Bind(&SubstituteGDataDownloadPathInternal, 226 base::Bind(&SubstituteGDataDownloadPathInternal,
226 profile, callback))); 227 profile, callback)));
227 } else { 228 } else {
228 callback.Run(gdata_path); 229 callback.Run(gdata_path);
229 } 230 }
230 } 231 }
231 232
232 // static 233 // static
233 void GDataDownloadObserver::SetDownloadParams(const FilePath& gdata_path, 234 void GDataDownloadObserver::SetDownloadParams(const FilePath& gdata_path,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // use the final target path when the download item is in COMPLETE state. 577 // use the final target path when the download item is in COMPLETE state.
577 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, 578 file_system_->AddUploadedFile(UPLOAD_NEW_FILE,
578 upload_data->virtual_dir_path(), 579 upload_data->virtual_dir_path(),
579 entry.Pass(), 580 entry.Pass(),
580 download->GetTargetFilePath(), 581 download->GetTargetFilePath(),
581 GDataCache::FILE_OPERATION_MOVE, 582 GDataCache::FILE_OPERATION_MOVE,
582 base::Bind(&base::DoNothing)); 583 base::Bind(&base::DoNothing));
583 } 584 }
584 585
585 } // namespace gdata 586 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698