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_proxy.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // GDataFileSystemProxy class implementation. | 170 // GDataFileSystemProxy class implementation. |
171 | 171 |
172 GDataFileSystemProxy::GDataFileSystemProxy( | 172 GDataFileSystemProxy::GDataFileSystemProxy( |
173 GDataFileSystemInterface* file_system) | 173 GDataFileSystemInterface* file_system) |
174 : file_system_(file_system) { | 174 : file_system_(file_system) { |
175 // Should be created from the file browser extension API (AddMountFunction) | 175 // Should be created from the file browser extension API (AddMountFunction) |
176 // on UI thread. | 176 // on UI thread. |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
178 } | 178 } |
179 | 179 |
180 GDataFileSystemProxy::~GDataFileSystemProxy() { | |
181 // Should be deleted from the CrosMountPointProvider on IO thread. | |
182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
183 } | |
184 | |
185 void GDataFileSystemProxy::GetFileInfo(const GURL& file_url, | 180 void GDataFileSystemProxy::GetFileInfo(const GURL& file_url, |
186 const FileSystemOperationInterface::GetMetadataCallback& callback) { | 181 const FileSystemOperationInterface::GetMetadataCallback& callback) { |
187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
188 | 183 |
189 FilePath file_path; | 184 FilePath file_path; |
190 if (!ValidateUrl(file_url, &file_path)) { | 185 if (!ValidateUrl(file_url, &file_path)) { |
191 base::MessageLoopProxy::current()->PostTask( | 186 base::MessageLoopProxy::current()->PostTask( |
192 FROM_HERE, | 187 FROM_HERE, |
193 base::Bind(callback, | 188 base::Bind(callback, |
194 base::PLATFORM_FILE_ERROR_NOT_FOUND, | 189 base::PLATFORM_FILE_ERROR_NOT_FOUND, |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 451 } |
457 | 452 |
458 file_system_->OpenFile( | 453 file_system_->OpenFile( |
459 file_path, | 454 file_path, |
460 base::Bind(&GDataFileSystemProxy::OnCreateWritableSnapshotFile, | 455 base::Bind(&GDataFileSystemProxy::OnCreateWritableSnapshotFile, |
461 this, | 456 this, |
462 file_path, | 457 file_path, |
463 callback)); | 458 callback)); |
464 } | 459 } |
465 | 460 |
| 461 GDataFileSystemProxy::~GDataFileSystemProxy() { |
| 462 // Should be deleted from the CrosMountPointProvider on IO thread. |
| 463 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 464 } |
| 465 |
466 // static. | 466 // static. |
467 bool GDataFileSystemProxy::ValidateUrl(const GURL& url, FilePath* file_path) { | 467 bool GDataFileSystemProxy::ValidateUrl(const GURL& url, FilePath* file_path) { |
468 // what platform you're on. | 468 // what platform you're on. |
469 FilePath raw_path; | 469 FilePath raw_path; |
470 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown; | 470 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown; |
471 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) || | 471 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) || |
472 type != fileapi::kFileSystemTypeExternal) { | 472 type != fileapi::kFileSystemTypeExternal) { |
473 return false; | 473 return false; |
474 } | 474 } |
475 return true; | 475 return true; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 552 |
553 void GDataFileSystemProxy::CloseWritableSnapshotFile( | 553 void GDataFileSystemProxy::CloseWritableSnapshotFile( |
554 const FilePath& virtual_path, | 554 const FilePath& virtual_path, |
555 const FilePath& local_path) { | 555 const FilePath& local_path) { |
556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
557 | 557 |
558 file_system_->CloseFile(virtual_path, base::Bind(&OnClose, virtual_path)); | 558 file_system_->CloseFile(virtual_path, base::Bind(&OnClose, virtual_path)); |
559 } | 559 } |
560 | 560 |
561 } // namespace gdata | 561 } // namespace gdata |
OLD | NEW |