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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service.cc

Issue 11411280: Sync FileSystem: Use app id part of the URL for its directory title. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testfix Created 8 years 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/sync_file_system/drive_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop_proxy.h" 14 #include "base/message_loop_proxy.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/google_apis/gdata_wapi_service.h" 17 #include "chrome/browser/google_apis/gdata_wapi_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/sync_file_system/drive_file_sync_client.h" 19 #include "chrome/browser/sync_file_system/drive_file_sync_client.h"
20 #include "chrome/browser/sync_file_system/drive_file_sync_util.h" 20 #include "chrome/browser/sync_file_system/drive_file_sync_util.h"
21 #include "chrome/browser/sync_file_system/drive_metadata_store.h" 21 #include "chrome/browser/sync_file_system/drive_metadata_store.h"
22 #include "chrome/browser/sync_file_system/remote_change_processor.h" 22 #include "chrome/browser/sync_file_system/remote_change_processor.h"
23 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" 23 #include "chrome/browser/sync_file_system/sync_file_system.pb.h"
24 #include "chrome/common/extensions/extension.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "net/base/escape.h" 26 #include "extensions/common/constants.h"
26 #include "webkit/fileapi/file_system_url.h" 27 #include "webkit/fileapi/file_system_url.h"
27 #include "webkit/fileapi/syncable/sync_file_metadata.h" 28 #include "webkit/fileapi/syncable/sync_file_metadata.h"
28 #include "webkit/fileapi/syncable/sync_file_type.h" 29 #include "webkit/fileapi/syncable/sync_file_type.h"
29 #include "webkit/fileapi/syncable/syncable_file_system_util.h" 30 #include "webkit/fileapi/syncable/syncable_file_system_util.h"
30 31
31 namespace sync_file_system { 32 namespace sync_file_system {
32 33
33 namespace { 34 namespace {
34 35
35 const FilePath::CharType kTempDirName[] = FILE_PATH_LITERAL("tmp"); 36 const FilePath::CharType kTempDirName[] = FILE_PATH_LITERAL("tmp");
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 observers_.AddObserver(observer); 242 observers_.AddObserver(observer);
242 } 243 }
243 244
244 void DriveFileSyncService::RemoveObserver(Observer* observer) { 245 void DriveFileSyncService::RemoveObserver(Observer* observer) {
245 observers_.RemoveObserver(observer); 246 observers_.RemoveObserver(observer);
246 } 247 }
247 248
248 void DriveFileSyncService::RegisterOriginForTrackingChanges( 249 void DriveFileSyncService::RegisterOriginForTrackingChanges(
249 const GURL& origin, 250 const GURL& origin,
250 const fileapi::SyncStatusCallback& callback) { 251 const fileapi::SyncStatusCallback& callback) {
252 DCHECK(origin.SchemeIs(extensions::kExtensionScheme));
251 scoped_ptr<TaskToken> token(GetToken( 253 scoped_ptr<TaskToken> token(GetToken(
252 FROM_HERE, TASK_TYPE_DRIVE, "Retrieving origin metadata")); 254 FROM_HERE, TASK_TYPE_DRIVE, "Retrieving origin metadata"));
253 if (!token) { 255 if (!token) {
254 pending_tasks_.push_back(base::Bind( 256 pending_tasks_.push_back(base::Bind(
255 &DriveFileSyncService::RegisterOriginForTrackingChanges, 257 &DriveFileSyncService::RegisterOriginForTrackingChanges,
256 AsWeakPtr(), origin, callback)); 258 AsWeakPtr(), origin, callback));
257 return; 259 return;
258 } 260 }
259 261
260 if (state_ == REMOTE_SERVICE_DISABLED) { 262 if (state_ == REMOTE_SERVICE_DISABLED) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 418
417 DVLOG(1) << "ApplyLocalChange for " << url.DebugString() 419 DVLOG(1) << "ApplyLocalChange for " << url.DebugString()
418 << " local_change:" << local_file_change.DebugString() 420 << " local_change:" << local_file_change.DebugString()
419 << " ==> operation:" << operation; 421 << " ==> operation:" << operation;
420 422
421 switch (operation) { 423 switch (operation) {
422 case SYNC_OPERATION_UPLOAD_NEW_FILE: { 424 case SYNC_OPERATION_UPLOAD_NEW_FILE: {
423 sync_client_->UploadNewFile( 425 sync_client_->UploadNewFile(
424 metadata_store_->GetResourceIdForOrigin(url.origin()), 426 metadata_store_->GetResourceIdForOrigin(url.origin()),
425 local_file_path, 427 local_file_path,
426 net::EscapePath(url.path().AsUTF8Unsafe()), 428 url.path().AsUTF8Unsafe(),
427 local_file_metadata.size, 429 local_file_metadata.size,
428 base::Bind(&DriveFileSyncService::DidUploadNewFile, 430 base::Bind(&DriveFileSyncService::DidUploadNewFile,
429 AsWeakPtr(), base::Passed(&token), url, callback)); 431 AsWeakPtr(), base::Passed(&token), url, callback));
430 return; 432 return;
431 } 433 }
432 case SYNC_OPERATION_UPLOAD_EXISTING_FILE: { 434 case SYNC_OPERATION_UPLOAD_EXISTING_FILE: {
433 DriveMetadata metadata; 435 DriveMetadata metadata;
434 const fileapi::SyncStatusCode status = 436 const fileapi::SyncStatusCode status =
435 metadata_store_->ReadEntry(url, &metadata); 437 metadata_store_->ReadEntry(url, &metadata);
436 DCHECK_EQ(fileapi::SYNC_STATUS_OK, status); 438 DCHECK_EQ(fileapi::SYNC_STATUS_OK, status);
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 fileapi::SyncStatusCode 1331 fileapi::SyncStatusCode
1330 DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper( 1332 DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper(
1331 google_apis::GDataErrorCode error) const { 1333 google_apis::GDataErrorCode error) const {
1332 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); 1334 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
1333 if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated()) 1335 if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated())
1334 return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED; 1336 return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED;
1335 return status; 1337 return status;
1336 } 1338 }
1337 1339
1338 } // namespace sync_file_system 1340 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698