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

Unified Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 9372044: Refactor FileSystemOperation to take callback for each method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reflected kinuko's comments + Fixture for failing-Write -> Cancel pattern. Created 8 years, 10 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/extensions/extension_file_browser_private_api.cc
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index da6453e2719d57c861fa06f0b4acd8c489c1b56f..ff2079ae44743e5404f295088ddd925e8f2fd4e1 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -314,41 +314,26 @@ base::DictionaryValue* MountPointToValue(Profile* profile,
} // namespace
-class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher
- : public fileapi::FileSystemCallbackDispatcher {
+class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher {
public:
- static scoped_ptr<FileSystemCallbackDispatcher> Create(
+ static fileapi::FileSystemContext::OpenFileSystemCallback CreateCallback(
RequestLocalFileSystemFunction* function,
Profile* profile,
int child_id,
scoped_refptr<const Extension> extension) {
- return scoped_ptr<fileapi::FileSystemCallbackDispatcher>(
- new LocalFileSystemCallbackDispatcher(
- function, profile, child_id, extension));
+ return base::Bind(
+ &LocalFileSystemCallbackDispatcher::DidOpenFileSystem,
+ base::Owned(new LocalFileSystemCallbackDispatcher(
+ function, profile, child_id, extension)));
}
- // fileapi::FileSystemCallbackDispatcher overrides.
- virtual void DidSucceed() OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidReadMetadata(const base::PlatformFileInfo& info,
- const FilePath& unused) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidReadDirectory(
- const std::vector<base::FileUtilProxy::Entry>& entries,
- bool has_more) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidWrite(int64 bytes, bool complete) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidOpenFileSystem(const std::string& name,
- const GURL& root_path) OVERRIDE {
+ void DidOpenFileSystem(base::PlatformFileError result,
+ const std::string& name,
+ const GURL& root_path) {
+ if (result != base::PLATFORM_FILE_OK) {
+ DidFail(result);
+ return;
+ }
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
// Set up file permission access.
if (!SetupFileSystemAccessPermissions()) {
@@ -365,7 +350,7 @@ class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher
root_path));
}
- virtual void DidFail(base::PlatformFileError error_code) OVERRIDE {
+ void DidFail(base::PlatformFileError error_code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
@@ -434,7 +419,7 @@ void RequestLocalFileSystemFunction::RequestOnFileThread(
GURL origin_url = source_url.GetOrigin();
profile()->GetFileSystemContext()->OpenFileSystem(
origin_url, fileapi::kFileSystemTypeExternal, false, // create
- LocalFileSystemCallbackDispatcher::Create(
+ LocalFileSystemCallbackDispatcher::CreateCallback(
this,
profile(),
child_id,
@@ -628,10 +613,10 @@ bool GetFileTasksFileBrowserFunction::RunImpl() {
return true;
}
-class ExecuteTasksFileBrowserFunction::ExecuteTasksFileSystemCallbackDispatcher
- : public fileapi::FileSystemCallbackDispatcher {
+class
+ ExecuteTasksFileBrowserFunction::ExecuteTasksFileSystemCallbackDispatcher {
public:
- static scoped_ptr<fileapi::FileSystemCallbackDispatcher> Create(
+ static fileapi::FileSystemContext::OpenFileSystemCallback CreateCallback(
ExecuteTasksFileBrowserFunction* function,
Profile* profile,
int child_id,
@@ -639,34 +624,20 @@ class ExecuteTasksFileBrowserFunction::ExecuteTasksFileSystemCallbackDispatcher
scoped_refptr<const Extension> extension,
const std::string task_id,
const std::vector<GURL>& file_urls) {
- return scoped_ptr<fileapi::FileSystemCallbackDispatcher>(
- new ExecuteTasksFileSystemCallbackDispatcher(
+ return base::Bind(
+ &ExecuteTasksFileSystemCallbackDispatcher::DidOpenFileSystem,
+ base::Owned(new ExecuteTasksFileSystemCallbackDispatcher(
function, profile, child_id, source_url, extension,
- task_id, file_urls));
+ task_id, file_urls)));
}
- // fileapi::FileSystemCallbackDispatcher overrides.
- virtual void DidSucceed() OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidReadMetadata(const base::PlatformFileInfo& info,
- const FilePath& unused) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidReadDirectory(
- const std::vector<base::FileUtilProxy::Entry>& entries,
- bool has_more) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidWrite(int64 bytes, bool complete) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void DidOpenFileSystem(const std::string& file_system_name,
- const GURL& file_system_root) OVERRIDE {
+ void DidOpenFileSystem(base::PlatformFileError result,
+ const std::string& file_system_name,
+ const GURL& file_system_root) {
+ if (result != base::PLATFORM_FILE_OK) {
+ DidFail(result);
+ return;
+ }
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
ExecuteTasksFileBrowserFunction::FileDefinitionList file_list;
for (std::vector<GURL>::iterator iter = origin_file_urls_.begin();
@@ -700,7 +671,7 @@ class ExecuteTasksFileBrowserFunction::ExecuteTasksFileSystemCallbackDispatcher
file_list));
}
- virtual void DidFail(base::PlatformFileError error_code) OVERRIDE {
+ void DidFail(base::PlatformFileError error_code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
@@ -899,7 +870,7 @@ void ExecuteTasksFileBrowserFunction::RequestFileEntryOnFileThread(
GURL origin_url = source_url.GetOrigin();
profile()->GetFileSystemContext()->OpenFileSystem(
origin_url, fileapi::kFileSystemTypeExternal, false, // create
- ExecuteTasksFileSystemCallbackDispatcher::Create(
+ ExecuteTasksFileSystemCallbackDispatcher::CreateCallback(
this,
profile(),
render_view_host()->process()->GetID(),

Powered by Google App Engine
This is Rietveld 408576698