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/chromeos/gdata/gdata_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
| 30 #include "chrome/common/chrome_paths_internal.h" | 30 #include "chrome/common/chrome_paths_internal.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "net/base/mime_util.h" | 32 #include "net/base/mime_util.h" |
| 33 #include "webkit/fileapi/file_system_file_util_proxy.h" | 33 #include "webkit/fileapi/file_system_file_util_proxy.h" |
| 34 #include "webkit/fileapi/file_system_types.h" | 34 #include "webkit/fileapi/file_system_types.h" |
| 35 #include "webkit/fileapi/file_system_util.h" | 35 #include "webkit/fileapi/file_system_util.h" |
| 36 | 36 |
| 37 using content::BrowserThread; | 37 using content::BrowserThread; |
| 38 | 38 |
| 39 namespace gdata { | |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 const char kMimeTypeJson[] = "application/json"; | 42 const char kMimeTypeJson[] = "application/json"; |
| 42 const char kMimeTypeOctetStream[] = "application/octet-stream"; | 43 const char kMimeTypeOctetStream[] = "application/octet-stream"; |
| 43 | 44 |
| 44 const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("gdata"); | 45 const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("gdata"); |
| 45 const char kFeedField[] = "feed"; | 46 const char kFeedField[] = "feed"; |
| 46 const char kWildCard[] = "*"; | 47 const char kWildCard[] = "*"; |
| 47 const char kLocallyModifiedFileExtension[] = "local"; | 48 const char kLocallyModifiedFileExtension[] = "local"; |
| 48 | 49 |
| 49 const FilePath::CharType kGDataCacheVersionDir[] = FILE_PATH_LITERAL("v1"); | 50 const FilePath::CharType kGDataCacheVersionDir[] = FILE_PATH_LITERAL("v1"); |
| 50 const FilePath::CharType kGDataCacheMetaDir[] = FILE_PATH_LITERAL("meta"); | 51 const FilePath::CharType kGDataCacheMetaDir[] = FILE_PATH_LITERAL("meta"); |
| 51 const FilePath::CharType kGDataCachePinnedDir[] = FILE_PATH_LITERAL("pinned"); | 52 const FilePath::CharType kGDataCachePinnedDir[] = FILE_PATH_LITERAL("pinned"); |
| 52 const FilePath::CharType kGDataCacheOutgoingDir[] = | 53 const FilePath::CharType kGDataCacheOutgoingDir[] = |
| 53 FILE_PATH_LITERAL("outgoing"); | 54 FILE_PATH_LITERAL("outgoing"); |
| 54 const FilePath::CharType kGDataCachePersistentDir[] = | 55 const FilePath::CharType kGDataCachePersistentDir[] = |
| 55 FILE_PATH_LITERAL("persistent"); | 56 FILE_PATH_LITERAL("persistent"); |
| 56 const FilePath::CharType kGDataCacheTmpDir[] = FILE_PATH_LITERAL("tmp"); | 57 const FilePath::CharType kGDataCacheTmpDir[] = FILE_PATH_LITERAL("tmp"); |
| 57 const FilePath::CharType kGDataCacheTmpDownloadsDir[] = | 58 const FilePath::CharType kGDataCacheTmpDownloadsDir[] = |
| 58 FILE_PATH_LITERAL("tmp/downloads"); | 59 FILE_PATH_LITERAL("tmp/downloads"); |
| 59 const FilePath::CharType kGDataCacheTmpDocumentsDir[] = | 60 const FilePath::CharType kGDataCacheTmpDocumentsDir[] = |
| 60 FILE_PATH_LITERAL("tmp/documents"); | 61 FILE_PATH_LITERAL("tmp/documents"); |
| 61 const FilePath::CharType kLastFeedFile[] = FILE_PATH_LITERAL("last_feed.json"); | 62 const FilePath::CharType kLastFeedFile[] = FILE_PATH_LITERAL("last_feed.json"); |
| 62 const char kGDataFileSystemToken[] = "GDataFileSystemToken"; | 63 const char kGDataFileSystemToken[] = "GDataFileSystemToken"; |
| 63 const FilePath::CharType kAccountMetadataFile[] = | 64 const FilePath::CharType kAccountMetadataFile[] = |
| 64 FILE_PATH_LITERAL("account_metadata.json"); | 65 FILE_PATH_LITERAL("account_metadata.json"); |
| 65 const FilePath::CharType kSymLinkToDevNull[] = FILE_PATH_LITERAL("/dev/null"); | 66 const FilePath::CharType kSymLinkToDevNull[] = FILE_PATH_LITERAL("/dev/null"); |
| 66 | 67 |
| 67 // Converts gdata error code into file platform error code. | 68 // Converts gdata error code into file platform error code. |
| 68 base::PlatformFileError GDataToPlatformError(gdata::GDataErrorCode status) { | 69 base::PlatformFileError GDataToPlatformError(GDataErrorCode status) { |
| 69 switch (status) { | 70 switch (status) { |
| 70 case gdata::HTTP_SUCCESS: | 71 case HTTP_SUCCESS: |
| 71 case gdata::HTTP_CREATED: | 72 case HTTP_CREATED: |
| 72 return base::PLATFORM_FILE_OK; | 73 return base::PLATFORM_FILE_OK; |
| 73 case gdata::HTTP_UNAUTHORIZED: | 74 case HTTP_UNAUTHORIZED: |
| 74 case gdata::HTTP_FORBIDDEN: | 75 case HTTP_FORBIDDEN: |
| 75 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; | 76 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; |
| 76 case gdata::HTTP_NOT_FOUND: | 77 case HTTP_NOT_FOUND: |
| 77 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 78 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 78 case gdata::GDATA_PARSE_ERROR: | 79 case GDATA_PARSE_ERROR: |
| 79 case gdata::GDATA_FILE_ERROR: | 80 case GDATA_FILE_ERROR: |
| 80 return base::PLATFORM_FILE_ERROR_ABORT; | 81 return base::PLATFORM_FILE_ERROR_ABORT; |
| 81 default: | 82 default: |
| 82 return base::PLATFORM_FILE_ERROR_FAILED; | 83 return base::PLATFORM_FILE_ERROR_FAILED; |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 | 86 |
| 86 // Converts system error to file platform error code. | 87 // Converts system error to file platform error code. |
| 87 // This is copied and modified from base/platform_file_posix.cc. | 88 // This is copied and modified from base/platform_file_posix.cc. |
| 88 // TODO(kuan): base/platform.h should probably export this. | 89 // TODO(kuan): base/platform.h should probably export this. |
| 89 base::PlatformFileError SystemToPlatformError(int error) { | 90 base::PlatformFileError SystemToPlatformError(int error) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 | 147 |
| 147 // Modifies cache state of file on IO thread pool, which involves: | 148 // Modifies cache state of file on IO thread pool, which involves: |
| 148 // - moving or copying file (per |file_operation_type|) from |source_path| to | 149 // - moving or copying file (per |file_operation_type|) from |source_path| to |
| 149 // |dest_path| if they're different | 150 // |dest_path| if they're different |
| 150 // - deleting symlink if |symlink_path| is not empty | 151 // - deleting symlink if |symlink_path| is not empty |
| 151 // - creating symlink if |symlink_path| is not empty and |create_symlink| is | 152 // - creating symlink if |symlink_path| is not empty and |create_symlink| is |
| 152 // true. | 153 // true. |
| 153 base::PlatformFileError ModifyCacheState( | 154 base::PlatformFileError ModifyCacheState( |
| 154 const FilePath& source_path, | 155 const FilePath& source_path, |
| 155 const FilePath& dest_path, | 156 const FilePath& dest_path, |
| 156 gdata::GDataFileSystem::FileOperationType file_operation_type, | 157 GDataFileSystem::FileOperationType file_operation_type, |
| 157 const FilePath& symlink_path, | 158 const FilePath& symlink_path, |
| 158 bool create_symlink) { | 159 bool create_symlink) { |
| 159 // Move or copy |source_path| to |dest_path| if they are different. | 160 // Move or copy |source_path| to |dest_path| if they are different. |
| 160 if (source_path != dest_path) { | 161 if (source_path != dest_path) { |
| 161 bool success = false; | 162 bool success = false; |
| 162 if (file_operation_type == gdata::GDataFileSystem::FILE_OPERATION_MOVE) | 163 if (file_operation_type == GDataFileSystem::FILE_OPERATION_MOVE) |
| 163 success = file_util::Move(source_path, dest_path); | 164 success = file_util::Move(source_path, dest_path); |
| 164 else if (file_operation_type == gdata::GDataFileSystem::FILE_OPERATION_COPY) | 165 else if (file_operation_type == |
| 166 GDataFileSystem::FILE_OPERATION_COPY) | |
| 165 success = file_util::CopyFile(source_path, dest_path); | 167 success = file_util::CopyFile(source_path, dest_path); |
| 166 if (!success) { | 168 if (!success) { |
| 167 base::PlatformFileError error = SystemToPlatformError(errno); | 169 base::PlatformFileError error = SystemToPlatformError(errno); |
| 168 LOG(ERROR) << "Error " | 170 LOG(ERROR) << "Error " |
| 169 << (file_operation_type == | 171 << (file_operation_type == |
| 170 gdata::GDataFileSystem::FILE_OPERATION_MOVE ? | 172 GDataFileSystem::FILE_OPERATION_MOVE ? |
| 171 "moving " : "copying ") | 173 "moving " : "copying ") |
| 172 << source_path.value() | 174 << source_path.value() |
| 173 << " to " << dest_path.value() | 175 << " to " << dest_path.value() |
| 174 << ": " << strerror(errno); | 176 << ": " << strerror(errno); |
| 175 return error; | 177 return error; |
| 176 } else { | 178 } else { |
| 177 DVLOG(1) << (file_operation_type == | 179 DVLOG(1) << (file_operation_type == |
| 178 gdata::GDataFileSystem::FILE_OPERATION_MOVE ? | 180 GDataFileSystem::FILE_OPERATION_MOVE ? |
| 179 "Moved " : "Copied ") | 181 "Moved " : "Copied ") |
| 180 << source_path.value() | 182 << source_path.value() |
| 181 << " to " << dest_path.value(); | 183 << " to " << dest_path.value(); |
| 182 } | 184 } |
| 183 } else { | 185 } else { |
| 184 DVLOG(1) << "No need to move file: source = destination"; | 186 DVLOG(1) << "No need to move file: source = destination"; |
| 185 } | 187 } |
| 186 | 188 |
| 187 if (symlink_path.empty()) | 189 if (symlink_path.empty()) |
| 188 return base::PLATFORM_FILE_OK; | 190 return base::PLATFORM_FILE_OK; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 DVLOG(1) << "Error deleting " << current.value(); | 272 DVLOG(1) << "Error deleting " << current.value(); |
| 271 else | 273 else |
| 272 DVLOG(1) << "Deleted " << current.value(); | 274 DVLOG(1) << "Deleted " << current.value(); |
| 273 } | 275 } |
| 274 } | 276 } |
| 275 | 277 |
| 276 // Invoked upon completion of TransferRegularFile initiated by Copy. | 278 // Invoked upon completion of TransferRegularFile initiated by Copy. |
| 277 // | 279 // |
| 278 // |callback| is run on the thread represented by |relay_proxy|. | 280 // |callback| is run on the thread represented by |relay_proxy|. |
| 279 void OnTransferRegularFileCompleteForCopy( | 281 void OnTransferRegularFileCompleteForCopy( |
| 280 const gdata::FileOperationCallback& callback, | 282 const FileOperationCallback& callback, |
| 281 scoped_refptr<base::MessageLoopProxy> relay_proxy, | 283 scoped_refptr<base::MessageLoopProxy> relay_proxy, |
| 282 base::PlatformFileError error) { | 284 base::PlatformFileError error) { |
| 283 if (!callback.is_null()) | 285 if (!callback.is_null()) |
| 284 relay_proxy->PostTask(FROM_HERE, base::Bind(callback, error)); | 286 relay_proxy->PostTask(FROM_HERE, base::Bind(callback, error)); |
| 285 } | 287 } |
| 286 | 288 |
| 287 // Runs GetFileCallback with pointers dereferenced. | 289 // Runs GetFileCallback with pointers dereferenced. |
| 288 // Used for PostTaskAndReply(). | 290 // Used for PostTaskAndReply(). |
| 289 void RunGetFileCallbackHelper(const gdata::GetFileCallback& callback, | 291 void RunGetFileCallbackHelper(const GetFileCallback& callback, |
| 290 base::PlatformFileError* error, | 292 base::PlatformFileError* error, |
| 291 FilePath* file_path, | 293 FilePath* file_path, |
| 292 std::string* mime_type, | 294 std::string* mime_type, |
| 293 gdata::GDataFileType* file_type) { | 295 GDataFileType* file_type) { |
| 294 DCHECK(error); | 296 DCHECK(error); |
| 295 DCHECK(file_path); | 297 DCHECK(file_path); |
| 296 DCHECK(mime_type); | 298 DCHECK(mime_type); |
| 297 DCHECK(file_type); | 299 DCHECK(file_type); |
| 298 | 300 |
| 299 if (!callback.is_null()) | 301 if (!callback.is_null()) |
| 300 callback.Run(*error, *file_path, *mime_type, *file_type); | 302 callback.Run(*error, *file_path, *mime_type, *file_type); |
| 301 } | 303 } |
| 302 | 304 |
| 303 // Ditto for CacheOperationCallback. | 305 // Ditto for CacheOperationCallback. |
| 304 void RunCacheOperationCallbackHelper( | 306 void RunCacheOperationCallbackHelper( |
| 305 const gdata::CacheOperationCallback& callback, | 307 const CacheOperationCallback& callback, |
| 306 base::PlatformFileError* error, | 308 base::PlatformFileError* error, |
| 307 const std::string& resource_id, | 309 const std::string& resource_id, |
| 308 const std::string& md5) { | 310 const std::string& md5) { |
| 309 DCHECK(error); | 311 DCHECK(error); |
| 310 | 312 |
| 311 if (!callback.is_null()) | 313 if (!callback.is_null()) |
| 312 callback.Run(*error, resource_id, md5); | 314 callback.Run(*error, resource_id, md5); |
| 313 } | 315 } |
| 314 | 316 |
| 315 // Ditto for GetFromCacheCallback. | 317 // Ditto for GetFromCacheCallback. |
| 316 void RunGetFromCacheCallbackHelper( | 318 void RunGetFromCacheCallbackHelper( |
| 317 const gdata::GetFromCacheCallback& callback, | 319 const GetFromCacheCallback& callback, |
| 318 base::PlatformFileError* error, | 320 base::PlatformFileError* error, |
| 319 const std::string& resource_id, | 321 const std::string& resource_id, |
| 320 const std::string& md5, | 322 const std::string& md5, |
| 321 const FilePath& gdata_file_path, | 323 const FilePath& gdata_file_path, |
| 322 FilePath* cache_file_path) { | 324 FilePath* cache_file_path) { |
| 323 DCHECK(error); | 325 DCHECK(error); |
| 324 DCHECK(cache_file_path); | 326 DCHECK(cache_file_path); |
| 325 | 327 |
| 326 if (!callback.is_null()) | 328 if (!callback.is_null()) |
| 327 callback.Run(*error, resource_id, md5, gdata_file_path, *cache_file_path); | 329 callback.Run(*error, resource_id, md5, gdata_file_path, *cache_file_path); |
| 328 } | 330 } |
| 329 | 331 |
| 330 void RunGetCacheStateCallbackHelper( | 332 void RunGetCacheStateCallbackHelper( |
| 331 const gdata::GetCacheStateCallback& callback, | 333 const GetCacheStateCallback& callback, |
| 332 base::PlatformFileError* error, | 334 base::PlatformFileError* error, |
| 333 int* cache_state) { | 335 int* cache_state) { |
| 334 DCHECK(error); | 336 DCHECK(error); |
| 335 DCHECK(cache_state); | 337 DCHECK(cache_state); |
| 336 | 338 |
| 337 if (!callback.is_null()) | 339 if (!callback.is_null()) |
| 338 callback.Run(*error, *cache_state); | 340 callback.Run(*error, *cache_state); |
| 339 } | 341 } |
| 340 | 342 |
| 341 } // namespace | 343 } // namespace |
| 342 | 344 |
| 343 namespace gdata { | |
| 344 | |
| 345 // FindFileDelegate class implementation. | 345 // FindFileDelegate class implementation. |
| 346 | 346 |
| 347 FindFileDelegate::~FindFileDelegate() { | 347 FindFileDelegate::~FindFileDelegate() { |
| 348 } | 348 } |
| 349 | 349 |
| 350 // FindFileCallbackRelayDelegate class implementation. | 350 // FindFileCallbackRelayDelegate class implementation. |
| 351 // This class is used to relay calls between sync and async versions | 351 // This class is used to relay calls between sync and async versions |
| 352 // of FindFileByPath(Sync|Async) calls. | 352 // of FindFileByPath(Sync|Async) calls. |
| 353 class FindFileCallbackRelayDelegate : public FindFileDelegate { | 353 class FindFileCallbackRelayDelegate : public FindFileDelegate { |
| 354 public: | 354 public: |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 JSONFileValueSerializer serializer(local_file_path); | 711 JSONFileValueSerializer serializer(local_file_path); |
| 712 scoped_ptr<Value> value(serializer.Deserialize(NULL, &error)); | 712 scoped_ptr<Value> value(serializer.Deserialize(NULL, &error)); |
| 713 if (value.get() && value->GetAsDictionary(&dict_value)) | 713 if (value.get() && value->GetAsDictionary(&dict_value)) |
| 714 dict_value->GetString("resource_id", resource_id); | 714 dict_value->GetString("resource_id", resource_id); |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 void GDataFileSystem::StartFileUploadOnUIThread( | 718 void GDataFileSystem::StartFileUploadOnUIThread( |
| 719 const FileOperationCallback& callback, | 719 const FileOperationCallback& callback, |
| 720 base::PlatformFileError* error, | 720 base::PlatformFileError* error, |
| 721 UploadFileInfo* upload_file_info) { | 721 UploadFileInfo* upload_file_info) { |
|
asanka
2012/03/28 22:02:33
Nit: Might be clearer if this took a scoped_ptr<>
achuithb
2012/03/28 23:27:11
scoped_ptr can't be used with PostTaskAndReply pro
| |
| 722 // This method needs to run on the UI thread as required by | 722 // This method needs to run on the UI thread as required by |
| 723 // GDataUploader::UploadFile(). | 723 // GDataUploader::UploadFile(). |
| 724 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 724 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 725 DCHECK(error); | 725 DCHECK(error); |
| 726 DCHECK(upload_file_info); | 726 DCHECK(upload_file_info); |
| 727 | 727 |
| 728 GDataSystemService* service = | 728 GDataSystemService* service = |
| 729 GDataSystemServiceFactory::GetForProfile(profile_); | 729 GDataSystemServiceFactory::GetForProfile(profile_); |
| 730 | 730 |
| 731 if (*error == base::PLATFORM_FILE_OK) { | 731 if (*error == base::PLATFORM_FILE_OK) { |
| 732 if (!service) | 732 if (!service) |
| 733 *error = base::PLATFORM_FILE_ERROR_FAILED; | 733 *error = base::PLATFORM_FILE_ERROR_FAILED; |
| 734 } | 734 } |
| 735 | 735 |
| 736 if (*error != base::PLATFORM_FILE_OK) { | 736 if (*error != base::PLATFORM_FILE_OK) { |
| 737 if (!callback.is_null()) | 737 if (!callback.is_null()) |
| 738 callback.Run(*error); | 738 callback.Run(*error); |
| 739 | 739 |
| 740 return; | 740 return; |
| 741 } | 741 } |
| 742 | 742 |
| 743 upload_file_info->completion_callback = | 743 upload_file_info->completion_callback = |
| 744 base::Bind(&GDataFileSystem::OnTransferCompleted, | 744 base::Bind(&GDataFileSystem::OnTransferCompleted, |
| 745 GetWeakPtrForCurrentThread(), | 745 GetWeakPtrForCurrentThread(), |
| 746 upload_file_info->file_path, | |
| 747 upload_file_info->gdata_path, | |
| 748 callback); | 746 callback); |
| 749 | 747 |
| 750 service->uploader()->UploadFile(upload_file_info); | 748 service->uploader()->UploadFile(scoped_ptr<UploadFileInfo>(upload_file_info)); |
| 751 } | 749 } |
| 752 | 750 |
| 753 void GDataFileSystem::OnTransferCompleted( | 751 void GDataFileSystem::OnTransferCompleted( |
| 754 const FilePath& local_file_path, | |
| 755 const FilePath& remote_dest_file_path, | |
| 756 const FileOperationCallback& callback, | 752 const FileOperationCallback& callback, |
| 757 base::PlatformFileError error, | 753 base::PlatformFileError error, |
| 758 DocumentEntry* entry) { | 754 UploadFileInfo* upload_file_info) { |
| 759 if (error == base::PLATFORM_FILE_OK && entry) { | 755 DCHECK(upload_file_info); |
| 760 AddUploadedFile(remote_dest_file_path.DirName(), | 756 if (error == base::PLATFORM_FILE_OK && upload_file_info->entry.get()) { |
| 761 entry, | 757 AddUploadedFile(upload_file_info->gdata_path.DirName(), |
| 762 local_file_path, | 758 upload_file_info->entry.get(), |
| 759 upload_file_info->file_path, | |
| 763 FILE_OPERATION_COPY); | 760 FILE_OPERATION_COPY); |
| 764 } | 761 } |
| 765 if (!callback.is_null()) | 762 if (!callback.is_null()) |
| 766 callback.Run(error); | 763 callback.Run(error); |
| 764 | |
| 765 GDataSystemService* service = | |
| 766 GDataSystemServiceFactory::GetForProfile(profile_); | |
| 767 if (service) | |
| 768 service->uploader()->DeleteUpload(upload_file_info); | |
| 767 } | 769 } |
| 768 | 770 |
| 769 // static. | 771 // static. |
| 770 void GDataFileSystem::CreateUploadFileInfoOnIOThreadPool( | 772 void GDataFileSystem::CreateUploadFileInfoOnIOThreadPool( |
| 771 const FilePath& local_file, | 773 const FilePath& local_file, |
| 772 const FilePath& remote_dest_file, | 774 const FilePath& remote_dest_file, |
| 773 base::PlatformFileError* error, | 775 base::PlatformFileError* error, |
| 774 UploadFileInfo* upload_file_info) { | 776 UploadFileInfo* upload_file_info) { |
| 775 DCHECK(error); | 777 DCHECK(error); |
| 776 DCHECK(upload_file_info); | 778 DCHECK(upload_file_info); |
| (...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2502 | 2504 |
| 2503 GDataDirectory* parent_dir = file->parent(); | 2505 GDataDirectory* parent_dir = file->parent(); |
| 2504 if (!parent_dir->RemoveFile(file)) | 2506 if (!parent_dir->RemoveFile(file)) |
| 2505 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 2507 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 2506 | 2508 |
| 2507 NotifyDirectoryChanged(parent_dir->GetFilePath()); | 2509 NotifyDirectoryChanged(parent_dir->GetFilePath()); |
| 2508 return base::PLATFORM_FILE_OK; | 2510 return base::PLATFORM_FILE_OK; |
| 2509 } | 2511 } |
| 2510 | 2512 |
| 2511 void GDataFileSystem::AddUploadedFile(const FilePath& virtual_dir_path, | 2513 void GDataFileSystem::AddUploadedFile(const FilePath& virtual_dir_path, |
| 2512 gdata::DocumentEntry* entry, | 2514 DocumentEntry* entry, |
| 2513 const FilePath& file_content_path, | 2515 const FilePath& file_content_path, |
| 2514 FileOperationType cache_operation) { | 2516 FileOperationType cache_operation) { |
| 2515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2516 | 2518 |
| 2517 if (!entry) { | 2519 if (!entry) { |
| 2518 NOTREACHED(); | 2520 NOTREACHED(); |
| 2519 return; | 2521 return; |
| 2520 } | 2522 } |
| 2521 | 2523 |
| 2522 std::string resource_id; | 2524 std::string resource_id; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2671 FILE_OPERATION_MOVE, | 2673 FILE_OPERATION_MOVE, |
| 2672 error, | 2674 error, |
| 2673 cache_file_path), | 2675 cache_file_path), |
| 2674 base::Bind(&RunGetFromCacheCallbackHelper, | 2676 base::Bind(&RunGetFromCacheCallbackHelper, |
| 2675 callback, | 2677 callback, |
| 2676 base::Owned(error), | 2678 base::Owned(error), |
| 2677 resource_id, | 2679 resource_id, |
| 2678 md5, | 2680 md5, |
| 2679 FilePath() /* gdata_file_path */, | 2681 FilePath() /* gdata_file_path */, |
| 2680 base::Owned(cache_file_path))); | 2682 base::Owned(cache_file_path))); |
| 2681 | |
| 2682 } | 2683 } |
| 2683 | 2684 |
| 2684 void GDataFileSystem::CommitDirtyInCache( | 2685 void GDataFileSystem::CommitDirtyInCache( |
| 2685 const std::string& resource_id, | 2686 const std::string& resource_id, |
| 2686 const std::string& md5, | 2687 const std::string& md5, |
| 2687 const CacheOperationCallback& callback) { | 2688 const CacheOperationCallback& callback) { |
| 2688 InitializeCacheIfNecessary(); | 2689 InitializeCacheIfNecessary(); |
| 2689 | 2690 |
| 2690 base::PlatformFileError* error = | 2691 base::PlatformFileError* error = |
| 2691 new base::PlatformFileError(base::PLATFORM_FILE_OK); | 2692 new base::PlatformFileError(base::PLATFORM_FILE_OK); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3596 BrowserThread::FILE, | 3597 BrowserThread::FILE, |
| 3597 from_here, | 3598 from_here, |
| 3598 base::Bind(&GDataFileSystem::RunTaskOnIOThreadPool, | 3599 base::Bind(&GDataFileSystem::RunTaskOnIOThreadPool, |
| 3599 base::Unretained(this), | 3600 base::Unretained(this), |
| 3600 request_task), | 3601 request_task), |
| 3601 reply_task); | 3602 reply_task); |
| 3602 DCHECK(posted); | 3603 DCHECK(posted); |
| 3603 } | 3604 } |
| 3604 | 3605 |
| 3605 } // namespace gdata | 3606 } // namespace gdata |
| OLD | NEW |