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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/drive/write_on_cache_file.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/browser/chromeos/drive/file_system_interface.h"
11 #include "content/public/browser/browser_thread.h"
12
13 using content::BrowserThread;
14
15 namespace drive {
16
17 namespace {
18
19 // Runs |file_io_task_callback| in blocking pool and runs |close_callback|
20 // in the UI thread after that.
21 void WriteOnCacheFileAfterOpenFile(
22 const base::FilePath& drive_path,
23 const WriteOnCacheFileCallback& file_io_task_callback,
24 FileError error,
25 const base::FilePath& local_cache_path,
26 const base::Closure& close_callback) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
28
29 if (error == FILE_ERROR_OK) {
30 DCHECK(!close_callback.is_null());
31 BrowserThread::GetBlockingPool()->PostTaskAndReply(
32 FROM_HERE,
33 base::Bind(file_io_task_callback, error, local_cache_path),
34 close_callback);
35 } else {
36 BrowserThread::GetBlockingPool()->PostTask(
37 FROM_HERE,
38 base::Bind(file_io_task_callback, error, local_cache_path));
39
40 }
41 }
42
43 } // namespace
44
45 void WriteOnCacheFile(FileSystemInterface* file_system,
46 const base::FilePath& path,
47 const WriteOnCacheFileCallback& callback) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49 DCHECK(file_system);
50 DCHECK(!callback.is_null());
51
52 file_system->OpenFile(
53 path,
54 OPEN_OR_CREATE_FILE,
55 base::Bind(&WriteOnCacheFileAfterOpenFile, path, callback));
56 }
57
58 } // namespace drive
OLDNEW
« 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