| Index: chrome/browser/chromeos/file_system_provider/provided_file_system.cc
|
| diff --git a/chrome/browser/chromeos/file_system_provider/provided_file_system.cc b/chrome/browser/chromeos/file_system_provider/provided_file_system.cc
|
| index 8d669afd31a467a82409229054b62a7029c3d8c1..4fa3bbd35d31963315d08540938dbfb2ef1dfef7 100644
|
| --- a/chrome/browser/chromeos/file_system_provider/provided_file_system.cc
|
| +++ b/chrome/browser/chromeos/file_system_provider/provided_file_system.cc
|
| @@ -4,21 +4,76 @@
|
|
|
| #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
|
|
|
| +#include "base/files/file.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/request_manager.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/common/extensions/api/file_system_provider.h"
|
| +#include "extensions/browser/event_router.h"
|
| +
|
| namespace chromeos {
|
| namespace file_system_provider {
|
| +namespace {
|
| +
|
| +// Creates values to be passed to request events. These values can be extended
|
| +// by additional fields.
|
| +scoped_ptr<base::ListValue> CreateRequestValues(int file_system_id,
|
| + int request_id) {
|
| + scoped_ptr<base::ListValue> values(new base::ListValue());
|
| + values->AppendInteger(file_system_id);
|
| + values->AppendInteger(request_id);
|
| + return values.Pass();
|
| +}
|
| +
|
| +// Forwards the success callback to the status callback. Ignores arguments,
|
| +// since unmount request does not provide arguments.
|
| +void OnRequestUnmountSuccess(
|
| + const fileapi::AsyncFileUtil::StatusCallback& callback,
|
| + scoped_ptr<base::DictionaryValue> /* result */,
|
| + bool /* has_next */) {
|
| + callback.Run(base::File::FILE_OK);
|
| +}
|
| +
|
| +} // namespace
|
|
|
| ProvidedFileSystem::ProvidedFileSystem() {}
|
|
|
| -ProvidedFileSystem::ProvidedFileSystem(const std::string& extension_id,
|
| - int file_system_id,
|
| - const std::string& file_system_name,
|
| - const base::FilePath& mount_path)
|
| - : extension_id_(extension_id),
|
| - file_system_id_(file_system_id),
|
| - file_system_name_(file_system_name),
|
| - mount_path_(mount_path) {}
|
| +ProvidedFileSystem::ProvidedFileSystem(
|
| + extensions::EventRouter* event_router,
|
| + RequestManager* request_manager,
|
| + const ProvidedFileSystemInfo& file_system_info)
|
| + : event_router_(event_router),
|
| + request_manager_(request_manager),
|
| + file_system_info_(file_system_info) {}
|
|
|
| ProvidedFileSystem::~ProvidedFileSystem() {}
|
|
|
| +bool ProvidedFileSystem::RequestUnmount(
|
| + const fileapi::AsyncFileUtil::StatusCallback& callback) {
|
| + int request_id = request_manager_->CreateRequest(
|
| + file_system_info_.extension_id(),
|
| + file_system_info_.file_system_id(),
|
| + base::Bind(&OnRequestUnmountSuccess, callback),
|
| + callback);
|
| +
|
| + if (!request_id)
|
| + return false;
|
| +
|
| + scoped_ptr<base::ListValue> values(
|
| + CreateRequestValues(file_system_info_.file_system_id(), request_id));
|
| +
|
| + event_router_->DispatchEventToExtension(
|
| + file_system_info_.extension_id(),
|
| + make_scoped_ptr(new extensions::Event(
|
| + extensions::api::file_system_provider::OnUnmountRequested::kEventName,
|
| + values.Pass())));
|
| +
|
| + return true;
|
| +}
|
| +
|
| +const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const {
|
| + return file_system_info_;
|
| +}
|
| +
|
| } // namespace file_system_provider
|
| } // namespace chromeos
|
|
|