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

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

Issue 23050014: Convert drive::FileWriteHelper to a single function for simplification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/drive/write_on_cache_file.cc
diff --git a/chrome/browser/chromeos/drive/write_on_cache_file.cc b/chrome/browser/chromeos/drive/write_on_cache_file.cc
new file mode 100644
index 0000000000000000000000000000000000000000..12d2e7be0d26b4621b4405d964145b112286bf1a
--- /dev/null
+++ b/chrome/browser/chromeos/drive/write_on_cache_file.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/drive/write_on_cache_file.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/threading/sequenced_worker_pool.h"
+#include "chrome/browser/chromeos/drive/file_system_interface.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+namespace drive {
+
+namespace {
+
+// Runs |file_io_task_callback| in blocking pool and runs |close_callback|
+// in the UI thread after that.
+void WriteOnCacheFileAfterOpenFile(
+ const base::FilePath& drive_path,
+ const WriteOnCacheFileCallback& file_io_task_callback,
+ FileError error,
+ const base::FilePath& local_cache_path,
+ const base::Closure& close_callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (error == FILE_ERROR_OK) {
+ DCHECK(!close_callback.is_null());
+ BrowserThread::GetBlockingPool()->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(file_io_task_callback, error, local_cache_path),
+ close_callback);
+ } else {
+ BrowserThread::GetBlockingPool()->PostTask(
+ FROM_HERE,
+ base::Bind(file_io_task_callback, error, local_cache_path));
+
+ }
+}
+
+} // namespace
+
+void WriteOnCacheFile(FileSystemInterface* file_system,
+ const base::FilePath& path,
+ const WriteOnCacheFileCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(file_system);
+ DCHECK(!callback.is_null());
+
+ file_system->OpenFile(
+ path,
+ OPEN_OR_CREATE_FILE,
+ base::Bind(&WriteOnCacheFileAfterOpenFile, path, callback));
+}
+
+} // namespace drive
« no previous file with comments | « chrome/browser/chromeos/drive/write_on_cache_file.h ('k') | chrome/browser/chromeos/drive/write_on_cache_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698