Commit eaffd75f authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

[Extensions Functions] Migrate fileSystemProvider.notify to ExtensionFunction

Bug: 634140
Change-Id: I7728ca5b5bfda31be35c10609a2602e6efd6adfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035518Reviewed-by: default avatarTatsuhisa Yamaguchi <yamaguchi@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738415}
parent 60ea1ff5
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/chromeos/file_system_provider/request_manager.h" #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
#include "chrome/browser/chromeos/file_system_provider/request_value.h" #include "chrome/browser/chromeos/file_system_provider/request_value.h"
#include "chrome/browser/chromeos/file_system_provider/service.h" #include "chrome/browser/chromeos/file_system_provider/service.h"
#include "chrome/browser/extensions/chrome_extension_function_details.h"
#include "chrome/common/extensions/api/file_system_provider.h" #include "chrome/common/extensions/api/file_system_provider.h"
#include "chrome/common/extensions/api/file_system_provider_internal.h" #include "chrome/common/extensions/api/file_system_provider_internal.h"
#include "storage/browser/file_system/watcher_manager.h" #include "storage/browser/file_system/watcher_manager.h"
...@@ -244,12 +245,13 @@ ExtensionFunction::ResponseAction FileSystemProviderGetFunction::Run() { ...@@ -244,12 +245,13 @@ ExtensionFunction::ResponseAction FileSystemProviderGetFunction::Run() {
api::file_system_provider::Get::Results::Create(file_system_info))); api::file_system_provider::Get::Results::Create(file_system_info)));
} }
bool FileSystemProviderNotifyFunction::RunAsync() { ExtensionFunction::ResponseAction FileSystemProviderNotifyFunction::Run() {
using api::file_system_provider::Notify::Params; using api::file_system_provider::Notify::Params;
std::unique_ptr<Params> params(Params::Create(*args_)); std::unique_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
Service* const service = Service::Get(GetProfile()); ChromeExtensionFunctionDetails details(this);
Service* const service = Service::Get(details.GetProfile());
DCHECK(service); DCHECK(service);
ProvidedFileSystemInterface* const file_system = ProvidedFileSystemInterface* const file_system =
...@@ -257,8 +259,8 @@ bool FileSystemProviderNotifyFunction::RunAsync() { ...@@ -257,8 +259,8 @@ bool FileSystemProviderNotifyFunction::RunAsync() {
ProviderId::CreateFromExtensionId(extension_id()), ProviderId::CreateFromExtensionId(extension_id()),
params->options.file_system_id); params->options.file_system_id);
if (!file_system) { if (!file_system) {
SetError(FileErrorToString(base::File::FILE_ERROR_NOT_FOUND)); return RespondNow(
return false; Error(FileErrorToString(base::File::FILE_ERROR_NOT_FOUND)));
} }
file_system->Notify( file_system->Notify(
...@@ -270,18 +272,17 @@ bool FileSystemProviderNotifyFunction::RunAsync() { ...@@ -270,18 +272,17 @@ bool FileSystemProviderNotifyFunction::RunAsync() {
params->options.tag.get() ? *params->options.tag.get() : "", params->options.tag.get() ? *params->options.tag.get() : "",
base::Bind(&FileSystemProviderNotifyFunction::OnNotifyCompleted, this)); base::Bind(&FileSystemProviderNotifyFunction::OnNotifyCompleted, this));
return true; return RespondLater();
} }
void FileSystemProviderNotifyFunction::OnNotifyCompleted( void FileSystemProviderNotifyFunction::OnNotifyCompleted(
base::File::Error result) { base::File::Error result) {
if (result != base::File::FILE_OK) { if (result != base::File::FILE_OK) {
SetError(FileErrorToString(result)); Respond(Error(FileErrorToString(result)));
SendResponse(false);
return; return;
} }
SendResponse(true); Respond(NoArguments());
} }
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PROVIDER_API_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_SYSTEM_PROVIDER_FILE_SYSTEM_PROVIDER_API_H_
#include "chrome/browser/chromeos/extensions/file_system_provider/provider_function.h" #include "chrome/browser/chromeos/extensions/file_system_provider/provider_function.h"
#include "chrome/browser/extensions/chrome_extension_function.h" #include "extensions/browser/extension_function.h"
namespace extensions { namespace extensions {
...@@ -49,14 +49,14 @@ class FileSystemProviderGetFunction : public ExtensionFunction { ...@@ -49,14 +49,14 @@ class FileSystemProviderGetFunction : public ExtensionFunction {
ResponseAction Run() override; ResponseAction Run() override;
}; };
class FileSystemProviderNotifyFunction : public ChromeAsyncExtensionFunction { class FileSystemProviderNotifyFunction : public ExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileSystemProvider.notify", DECLARE_EXTENSION_FUNCTION("fileSystemProvider.notify",
FILESYSTEMPROVIDER_NOTIFY) FILESYSTEMPROVIDER_NOTIFY)
protected: protected:
~FileSystemProviderNotifyFunction() override {} ~FileSystemProviderNotifyFunction() override {}
bool RunAsync() override; ResponseAction Run() override;
private: private:
// Called when notifying is completed. // Called when notifying is completed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment