Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 26 #include "extensions/common/constants.h" | |
| 25 #include "net/base/escape.h" | 27 #include "net/base/escape.h" |
|
nhiroki
2012/11/30 09:17:54
No longer unused?
tzik
2012/12/03 08:12:08
Done.
| |
| 26 #include "webkit/fileapi/file_system_url.h" | 28 #include "webkit/fileapi/file_system_url.h" |
| 27 #include "webkit/fileapi/syncable/sync_file_metadata.h" | 29 #include "webkit/fileapi/syncable/sync_file_metadata.h" |
| 28 #include "webkit/fileapi/syncable/sync_file_type.h" | 30 #include "webkit/fileapi/syncable/sync_file_type.h" |
| 29 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 31 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
| 30 | 32 |
| 31 namespace sync_file_system { | 33 namespace sync_file_system { |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 35 const FilePath::CharType kTempDirName[] = FILE_PATH_LITERAL("tmp"); | 37 const FilePath::CharType kTempDirName[] = FILE_PATH_LITERAL("tmp"); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 observers_.AddObserver(observer); | 243 observers_.AddObserver(observer); |
| 242 } | 244 } |
| 243 | 245 |
| 244 void DriveFileSyncService::RemoveObserver(Observer* observer) { | 246 void DriveFileSyncService::RemoveObserver(Observer* observer) { |
| 245 observers_.RemoveObserver(observer); | 247 observers_.RemoveObserver(observer); |
| 246 } | 248 } |
| 247 | 249 |
| 248 void DriveFileSyncService::RegisterOriginForTrackingChanges( | 250 void DriveFileSyncService::RegisterOriginForTrackingChanges( |
| 249 const GURL& origin, | 251 const GURL& origin, |
| 250 const fileapi::SyncStatusCallback& callback) { | 252 const fileapi::SyncStatusCallback& callback) { |
| 253 DCHECK(origin.SchemeIs(extensions::kExtensionScheme)); | |
| 251 scoped_ptr<TaskToken> token(GetToken( | 254 scoped_ptr<TaskToken> token(GetToken( |
| 252 FROM_HERE, TASK_TYPE_DRIVE, "Retrieving origin metadata")); | 255 FROM_HERE, TASK_TYPE_DRIVE, "Retrieving origin metadata")); |
| 253 if (!token) { | 256 if (!token) { |
| 254 pending_tasks_.push_back(base::Bind( | 257 pending_tasks_.push_back(base::Bind( |
| 255 &DriveFileSyncService::RegisterOriginForTrackingChanges, | 258 &DriveFileSyncService::RegisterOriginForTrackingChanges, |
| 256 AsWeakPtr(), origin, callback)); | 259 AsWeakPtr(), origin, callback)); |
| 257 return; | 260 return; |
| 258 } | 261 } |
| 259 | 262 |
| 260 if (state_ == REMOTE_SERVICE_DISABLED) { | 263 if (state_ == REMOTE_SERVICE_DISABLED) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 | 419 |
| 417 DVLOG(1) << "ApplyLocalChange for " << url.DebugString() | 420 DVLOG(1) << "ApplyLocalChange for " << url.DebugString() |
| 418 << " local_change:" << local_file_change.DebugString() | 421 << " local_change:" << local_file_change.DebugString() |
| 419 << " ==> operation:" << operation; | 422 << " ==> operation:" << operation; |
| 420 | 423 |
| 421 switch (operation) { | 424 switch (operation) { |
| 422 case SYNC_OPERATION_UPLOAD_NEW_FILE: { | 425 case SYNC_OPERATION_UPLOAD_NEW_FILE: { |
| 423 sync_client_->UploadNewFile( | 426 sync_client_->UploadNewFile( |
| 424 metadata_store_->GetResourceIdForOrigin(url.origin()), | 427 metadata_store_->GetResourceIdForOrigin(url.origin()), |
| 425 local_file_path, | 428 local_file_path, |
| 426 net::EscapePath(url.path().AsUTF8Unsafe()), | 429 url.path().AsUTF8Unsafe(), |
| 427 local_file_metadata.size, | 430 local_file_metadata.size, |
| 428 base::Bind(&DriveFileSyncService::DidUploadNewFile, | 431 base::Bind(&DriveFileSyncService::DidUploadNewFile, |
| 429 AsWeakPtr(), base::Passed(&token), url, callback)); | 432 AsWeakPtr(), base::Passed(&token), url, callback)); |
| 430 return; | 433 return; |
| 431 } | 434 } |
| 432 case SYNC_OPERATION_UPLOAD_EXISTING_FILE: { | 435 case SYNC_OPERATION_UPLOAD_EXISTING_FILE: { |
| 433 DriveMetadata metadata; | 436 DriveMetadata metadata; |
| 434 const fileapi::SyncStatusCode status = | 437 const fileapi::SyncStatusCode status = |
| 435 metadata_store_->ReadEntry(url, &metadata); | 438 metadata_store_->ReadEntry(url, &metadata); |
| 436 DCHECK_EQ(fileapi::SYNC_STATUS_OK, status); | 439 DCHECK_EQ(fileapi::SYNC_STATUS_OK, status); |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1318 return false; | 1321 return false; |
| 1319 const PathToChange& path_to_change = found_url->second; | 1322 const PathToChange& path_to_change = found_url->second; |
| 1320 PathToChange::const_iterator found_path = path_to_change.find(url.path()); | 1323 PathToChange::const_iterator found_path = path_to_change.find(url.path()); |
| 1321 if (found_path == path_to_change.end()) | 1324 if (found_path == path_to_change.end()) |
| 1322 return false; | 1325 return false; |
| 1323 *change = found_path->second; | 1326 *change = found_path->second; |
| 1324 return true; | 1327 return true; |
| 1325 } | 1328 } |
| 1326 | 1329 |
| 1327 } // namespace sync_file_system | 1330 } // namespace sync_file_system |
| OLD | NEW |