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

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

Issue 9662041: Implement copy and move operations within the same remote file system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase to HEAD Created 8 years, 9 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_file_system_proxy.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
6 6
7 #include <vector>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/platform_file.h" 10 #include "base/platform_file.h"
9 #include "base/string_util.h" 11 #include "base/string_util.h"
10 #include "base/values.h" 12 #include "base/values.h"
11 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
12 #include "webkit/fileapi/file_system_file_util_proxy.h" 14 #include "webkit/fileapi/file_system_file_util_proxy.h"
13 #include "webkit/fileapi/file_system_types.h" 15 #include "webkit/fileapi/file_system_types.h"
14 #include "webkit/fileapi/file_system_util.h" 16 #include "webkit/fileapi/file_system_util.h"
15 17
16 using base::MessageLoopProxy; 18 using base::MessageLoopProxy;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 GDataDirectory* dir) OVERRIDE { 66 GDataDirectory* dir) OVERRIDE {
65 DCHECK(dir); 67 DCHECK(dir);
66 Reply(base::PLATFORM_FILE_OK, dir->file_info(), search_file_path_); 68 Reply(base::PLATFORM_FILE_OK, dir->file_info(), search_file_path_);
67 } 69 }
68 70
69 virtual void OnError(base::PlatformFileError error) OVERRIDE { 71 virtual void OnError(base::PlatformFileError error) OVERRIDE {
70 Reply(error, base::PlatformFileInfo(), FilePath()); 72 Reply(error, base::PlatformFileInfo(), FilePath());
71 } 73 }
72 74
73 private: 75 private:
74
75 // Relays reply back to the callback on calling thread. 76 // Relays reply back to the callback on calling thread.
76 void Reply(base::PlatformFileError result, 77 void Reply(base::PlatformFileError result,
77 const base::PlatformFileInfo& file_info, 78 const base::PlatformFileInfo& file_info,
78 const FilePath& platform_path) { 79 const FilePath& platform_path) {
79 if (!callback_.is_null()) { 80 if (!callback_.is_null()) {
80 reply_message_proxy_->PostTask(FROM_HERE, 81 reply_message_proxy_->PostTask(FROM_HERE,
81 Bind(&GetFileInfoDelegate::ReplyOnCallingThread, 82 Bind(&GetFileInfoDelegate::ReplyOnCallingThread,
82 this, 83 this,
83 result, 84 result,
84 file_info, 85 file_info,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 145
145 GURL unused; 146 GURL unused;
146 Reply(base::PLATFORM_FILE_OK, results, directory->NeedsRefresh(&unused)); 147 Reply(base::PLATFORM_FILE_OK, results, directory->NeedsRefresh(&unused));
147 } 148 }
148 149
149 virtual void OnError(base::PlatformFileError error) OVERRIDE { 150 virtual void OnError(base::PlatformFileError error) OVERRIDE {
150 Reply(error, std::vector<base::FileUtilProxy::Entry>(), false); 151 Reply(error, std::vector<base::FileUtilProxy::Entry>(), false);
151 } 152 }
152 153
153 private: 154 private:
154
155 // Relays reply back to the callback on calling thread. 155 // Relays reply back to the callback on calling thread.
156 void Reply(base::PlatformFileError result, 156 void Reply(base::PlatformFileError result,
157 const std::vector<base::FileUtilProxy::Entry>& file_list, 157 const std::vector<base::FileUtilProxy::Entry>& file_list,
158 bool has_more) { 158 bool has_more) {
159 if (!callback_.is_null()) { 159 if (!callback_.is_null()) {
160 reply_message_proxy_->PostTask(FROM_HERE, 160 reply_message_proxy_->PostTask(FROM_HERE,
161 Bind(&ReadDirectoryDelegate::ReplyOnCallingThread, 161 Bind(&ReadDirectoryDelegate::ReplyOnCallingThread,
162 this, 162 this,
163 result, 163 result,
164 file_list, 164 file_list,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 scoped_refptr<GetFileInfoDelegate> delegate( 200 scoped_refptr<GetFileInfoDelegate> delegate(
201 new GetFileInfoDelegate(file_system_, FilePath(), callback)); 201 new GetFileInfoDelegate(file_system_, FilePath(), callback));
202 delegate->OnError(base::PLATFORM_FILE_ERROR_NOT_FOUND); 202 delegate->OnError(base::PLATFORM_FILE_ERROR_NOT_FOUND);
203 return; 203 return;
204 } 204 }
205 205
206 file_system_->FindFileByPath( 206 file_system_->FindFileByPath(
207 file_path, new GetFileInfoDelegate(file_system_, file_path, callback)); 207 file_path, new GetFileInfoDelegate(file_system_, file_path, callback));
208 } 208 }
209 209
210 void GDataFileSystemProxy::Copy(const GURL& src_file_url,
211 const GURL& dest_file_url,
212 const FileSystemOperationInterface::StatusCallback& callback) {
213 FilePath src_file_path, dest_file_path;
214 if (!ValidateUrl(src_file_url, &src_file_path) ||
215 !ValidateUrl(dest_file_url, &dest_file_path)) {
216 MessageLoopProxy::current()->PostTask(FROM_HERE,
217 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
218 return;
219 }
220
221 file_system_->Copy(src_file_path, dest_file_path, callback);
222 }
223
224 void GDataFileSystemProxy::Move(const GURL& src_file_url,
225 const GURL& dest_file_url,
226 const FileSystemOperationInterface::StatusCallback& callback) {
227 FilePath src_file_path, dest_file_path;
228 if (!ValidateUrl(src_file_url, &src_file_path) ||
229 !ValidateUrl(dest_file_url, &dest_file_path)) {
230 MessageLoopProxy::current()->PostTask(FROM_HERE,
231 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
232 return;
233 }
234
235 file_system_->Move(src_file_path, dest_file_path, callback);
236 }
210 237
211 void GDataFileSystemProxy::ReadDirectory(const GURL& file_url, 238 void GDataFileSystemProxy::ReadDirectory(const GURL& file_url,
212 const FileSystemOperationInterface::ReadDirectoryCallback& callback) { 239 const FileSystemOperationInterface::ReadDirectoryCallback& callback) {
213 FilePath file_path; 240 FilePath file_path;
214 if (!ValidateUrl(file_url, &file_path)) { 241 if (!ValidateUrl(file_url, &file_path)) {
215 scoped_refptr<ReadDirectoryDelegate> delegate( 242 scoped_refptr<ReadDirectoryDelegate> delegate(
216 new ReadDirectoryDelegate(file_system_, FilePath(), callback)); 243 new ReadDirectoryDelegate(file_system_, FilePath(), callback));
217 delegate->OnError(base::PLATFORM_FILE_ERROR_NOT_FOUND); 244 delegate->OnError(base::PLATFORM_FILE_ERROR_NOT_FOUND);
218 return; 245 return;
219 } 246 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 FilePath raw_path; 282 FilePath raw_path;
256 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown; 283 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown;
257 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) || 284 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) ||
258 type != fileapi::kFileSystemTypeExternal) { 285 type != fileapi::kFileSystemTypeExternal) {
259 return false; 286 return false;
260 } 287 }
261 return true; 288 return true;
262 } 289 }
263 290
264 } // namespace gdata 291 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_proxy.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698