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

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: 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 86eefb895d45daaca82512b3d855b3cf05a1d3d9..cb80c360852953e8d2e94ea657335aa4a2fbe0c2 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -310,41 +310,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) OVERRIDE {
+ if (result != base::PLATFORM_FILE_OK) {
+ DidFail(result);
+ return;
+ }
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
// Set up file permission access.
if (!SetupFileSystemAccessPermissions()) {
@@ -361,7 +346,7 @@ class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher
root_path));
}
- virtual void DidFail(base::PlatformFileError error_code) OVERRIDE {
+ void DidFail(base::PlatformFileError error_code) OVERRIDE {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
@@ -430,7 +415,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,
@@ -624,10 +609,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(
kinuko 2012/02/10 05:34:09 Nice practical solution.
kinaba 2012/02/10 08:22:58 :)
ExecuteTasksFileBrowserFunction* function,
Profile* profile,
int child_id,
@@ -635,34 +620,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) OVERRIDE {
+ 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();
@@ -696,7 +667,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(
@@ -895,7 +866,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