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

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

Issue 10834415: gdata: Remove unnecessary callback function OnTransferRegularFileCompleteForCopy (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_file_system.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // GData update check interval (in seconds). 47 // GData update check interval (in seconds).
48 #ifndef NDEBUG 48 #ifndef NDEBUG
49 const int kGDataUpdateCheckIntervalInSec = 5; 49 const int kGDataUpdateCheckIntervalInSec = 5;
50 #else 50 #else
51 const int kGDataUpdateCheckIntervalInSec = 60; 51 const int kGDataUpdateCheckIntervalInSec = 60;
52 #endif 52 #endif
53 53
54 //================================ Helper functions ============================ 54 //================================ Helper functions ============================
55 55
56 // Invoked upon completion of TransferRegularFile initiated by Copy.
57 //
58 // |callback| is run on the thread represented by |relay_proxy|.
59 void OnTransferRegularFileCompleteForCopy(
60 const FileOperationCallback& callback,
61 scoped_refptr<base::MessageLoopProxy> relay_proxy,
62 GDataFileError error) {
63 if (!callback.is_null())
64 relay_proxy->PostTask(FROM_HERE, base::Bind(callback, error));
65 }
66
67 // Runs GetFileCallback with pointers dereferenced. 56 // Runs GetFileCallback with pointers dereferenced.
68 // Used for PostTaskAndReply(). 57 // Used for PostTaskAndReply().
69 void RunGetFileCallbackHelper(const GetFileCallback& callback, 58 void RunGetFileCallbackHelper(const GetFileCallback& callback,
70 GDataFileError* error, 59 GDataFileError* error,
71 FilePath* file_path, 60 FilePath* file_path,
72 std::string* mime_type, 61 std::string* mime_type,
73 GDataFileType* file_type) { 62 GDataFileType* file_type) {
74 DCHECK(error); 63 DCHECK(error);
75 DCHECK(file_path); 64 DCHECK(file_path);
76 DCHECK(mime_type); 65 DCHECK(mime_type);
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 const std::string& unused_mime_type, 1006 const std::string& unused_mime_type,
1018 GDataFileType file_type) { 1007 GDataFileType file_type) {
1019 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1008 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1020 DCHECK(!callback.is_null()); 1009 DCHECK(!callback.is_null());
1021 1010
1022 if (error != GDATA_FILE_OK) { 1011 if (error != GDATA_FILE_OK) {
1023 callback.Run(error); 1012 callback.Run(error);
1024 return; 1013 return;
1025 } 1014 }
1026 1015
1027 // This callback is only triggered for a regular file via Copy() and runs 1016 // This callback is only triggered for a regular file via Copy().
1028 // on the same thread as Copy (IO thread). As TransferRegularFile must run
1029 // on the UI thread, we thus need to post a task to the UI thread.
1030 // Also, upon the completion of TransferRegularFile, we need to run |callback|
1031 // on the same thread as Copy (IO thread), and the transition from UI thread
1032 // to IO thread is handled by OnTransferRegularFileCompleteForCopy.
1033 DCHECK_EQ(REGULAR_FILE, file_type); 1017 DCHECK_EQ(REGULAR_FILE, file_type);
1034 BrowserThread::PostTask( 1018 TransferRegularFile(local_file_path, remote_dest_file_path, callback);
1035 BrowserThread::UI,
1036 FROM_HERE,
1037 base::Bind(&GDataFileSystem::TransferRegularFile,
1038 ui_weak_ptr_,
1039 local_file_path, remote_dest_file_path,
1040 base::Bind(OnTransferRegularFileCompleteForCopy,
1041 callback,
1042 base::MessageLoopProxy::current())));
1043 } 1019 }
1044 1020
1045 void GDataFileSystem::OnGetFileCompleteForTransferFile( 1021 void GDataFileSystem::OnGetFileCompleteForTransferFile(
1046 const FilePath& local_dest_file_path, 1022 const FilePath& local_dest_file_path,
1047 const FileOperationCallback& callback, 1023 const FileOperationCallback& callback,
1048 GDataFileError error, 1024 GDataFileError error,
1049 const FilePath& local_file_path, 1025 const FilePath& local_file_path,
1050 const std::string& unused_mime_type, 1026 const std::string& unused_mime_type,
1051 GDataFileType file_type) { 1027 GDataFileType file_type) {
1052 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1028 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 return; 3418 return;
3443 } 3419 }
3444 3420
3445 PlatformFileInfoProto entry_file_info; 3421 PlatformFileInfoProto entry_file_info;
3446 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3422 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3447 *entry_proto->mutable_file_info() = entry_file_info; 3423 *entry_proto->mutable_file_info() = entry_file_info;
3448 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3424 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3449 } 3425 }
3450 3426
3451 } // namespace gdata 3427 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698