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

Unified Diff: chrome/browser/chromeos/drive/drive_file_system.cc

Issue 14348016: chromeos: Add DriveFileSystem::Pin/Unpin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use GetEntryInfoByPathSync Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/drive/drive_file_system.cc
diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc b/chrome/browser/chromeos/drive/drive_file_system.cc
index b220684aaf571fdf5d553055dc7c9888a7800dcc..a887fcde43321f1e3afabd00e5e055f8dac4b961 100644
--- a/chrome/browser/chromeos/drive/drive_file_system.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system.cc
@@ -465,6 +465,70 @@ void DriveFileSystem::OnGetEntryInfoForCreateFile(
callback);
}
+void DriveFileSystem::Pin(const base::FilePath& file_path,
+ const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ GetEntryInfoByPath(file_path,
+ base::Bind(&DriveFileSystem::PinAfterGetEntryInfoByPath,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+}
+
+void DriveFileSystem::PinAfterGetEntryInfoByPath(
+ const FileOperationCallback& callback,
+ DriveFileError error,
+ scoped_ptr<DriveEntryProto> entry) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ // TODO(hashimoto): Support pinning directories. crbug.com/127831
+ if (entry && entry->file_info().is_directory())
+ error = DRIVE_FILE_ERROR_NOT_A_FILE;
+
+ if (error != DRIVE_FILE_OK) {
+ callback.Run(error);
+ return;
+ }
+ DCHECK(entry);
+
+ cache_->Pin(entry->resource_id(), entry->file_specific_info().file_md5(),
+ callback);
+}
+
+void DriveFileSystem::Unpin(const base::FilePath& file_path,
+ const FileOperationCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ GetEntryInfoByPath(file_path,
+ base::Bind(&DriveFileSystem::UnpinAfterGetEntryInfoByPath,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+}
+
+void DriveFileSystem::UnpinAfterGetEntryInfoByPath(
+ const FileOperationCallback& callback,
+ DriveFileError error,
+ scoped_ptr<DriveEntryProto> entry) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ // TODO(hashimoto): Support pinning directories. crbug.com/127831
+ if (entry && entry->file_info().is_directory())
+ error = DRIVE_FILE_ERROR_NOT_A_FILE;
+
+ if (error != DRIVE_FILE_OK) {
+ callback.Run(error);
+ return;
+ }
+ DCHECK(entry);
+
+ cache_->Unpin(entry->resource_id(), entry->file_specific_info().file_md5(),
+ callback);
+}
+
void DriveFileSystem::GetFileByPath(const base::FilePath& file_path,
const GetFileCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system.h ('k') | chrome/browser/chromeos/drive/drive_file_system_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698