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

Unified Diff: chrome/browser/chromeos/file_system_provider/provided_file_system.cc

Issue 1093383002: [WIP] Provided file system from NACL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved several modules to chromeos folder. Created 5 years, 5 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/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 bd248e7a657d2c152b49dbe77ee6c2ac4da704d9..7dc8189caa07e345d79a2f6c7f1ca52be03fa036 100644
--- a/chrome/browser/chromeos/file_system_provider/provided_file_system.cc
+++ b/chrome/browser/chromeos/file_system_provider/provided_file_system.cc
@@ -8,6 +8,7 @@
#include "base/files/file.h"
#include "base/trace_event/trace_event.h"
+#include "chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_operation_router.h"
#include "chrome/browser/chromeos/file_system_provider/notification_manager.h"
#include "chrome/browser/chromeos/file_system_provider/operations/abort.h"
#include "chrome/browser/chromeos/file_system_provider/operations/add_watcher.h"
@@ -37,6 +38,17 @@ class IOBuffer;
namespace chromeos {
namespace file_system_provider {
+
+
+typename ExtensionDestination::EventRouterType*
+ExtensionDestination::Get(Profile *profile) {
+ return extensions::EventRouter::Get(profile);
+}
+
+PluginDestination::EventRouterType* PluginDestination::Get(Profile *) {
+ return chromeos::file_system_provider::PluginOperationRouter::GetInstance();
+}
+
namespace {
// Discards the result of Abort() when called from the destructor.
@@ -71,8 +83,8 @@ AutoUpdater::~AutoUpdater() {
else if (pending_callbacks_)
LOG(ERROR) << "Not all callbacks called. This may happen on shutdown.";
}
-
-struct ProvidedFileSystem::AddWatcherInQueueArgs {
+template <class DestinationPolicy>
+struct ProvidedFileSystem<DestinationPolicy>::AddWatcherInQueueArgs {
AddWatcherInQueueArgs(size_t token,
const GURL& origin,
const base::FilePath& entry_path,
@@ -99,7 +111,8 @@ struct ProvidedFileSystem::AddWatcherInQueueArgs {
const storage::WatcherManager::NotificationCallback notification_callback;
};
-struct ProvidedFileSystem::NotifyInQueueArgs {
+template <class DestinationPolicy>
+struct ProvidedFileSystem<DestinationPolicy>::NotifyInQueueArgs {
NotifyInQueueArgs(size_t token,
const base::FilePath& entry_path,
bool recursive,
@@ -128,11 +141,12 @@ struct ProvidedFileSystem::NotifyInQueueArgs {
DISALLOW_COPY_AND_ASSIGN(NotifyInQueueArgs);
};
-ProvidedFileSystem::ProvidedFileSystem(
+template <class DestinationPolicy>
+ProvidedFileSystem<DestinationPolicy>::ProvidedFileSystem(
Profile* profile,
const ProvidedFileSystemInfo& file_system_info)
: profile_(profile),
- event_router_(extensions::EventRouter::Get(profile)), // May be NULL.
+ event_router_(DestinationPolicy::Get(profile)), // May be NULL.
file_system_info_(file_system_info),
notification_manager_(
new NotificationManager(profile_, file_system_info_)),
@@ -142,66 +156,72 @@ ProvidedFileSystem::ProvidedFileSystem(
watcher_queue_(1),
weak_ptr_factory_(this) {
}
-
-ProvidedFileSystem::~ProvidedFileSystem() {
+template <class DestinationPolicy>
+ProvidedFileSystem<DestinationPolicy>::~ProvidedFileSystem() {
const std::vector<int> request_ids = request_manager_->GetActiveRequestIds();
for (size_t i = 0; i < request_ids.size(); ++i) {
Abort(request_ids[i]);
}
}
-
-void ProvidedFileSystem::SetEventRouterForTesting(
- extensions::EventRouter* event_router) {
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::SetEventRouterForTesting(
+ typename DestinationPolicy::EventRouterType* event_router) {
event_router_ = event_router;
}
-void ProvidedFileSystem::SetNotificationManagerForTesting(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::SetNotificationManagerForTesting(
scoped_ptr<NotificationManagerInterface> notification_manager) {
notification_manager_ = notification_manager.Pass();
request_manager_.reset(new RequestManager(
profile_, file_system_info_.extension_id(), notification_manager_.get()));
}
-AbortCallback ProvidedFileSystem::RequestUnmount(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::RequestUnmount(
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- REQUEST_UNMOUNT,
- scoped_ptr<RequestManager::HandlerInterface>(
- new operations::Unmount(event_router_, file_system_info_, callback)));
+ REQUEST_UNMOUNT, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::Unmount<DestinationPolicy>(
+ event_router_, file_system_info_, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::GetMetadata(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::GetMetadata(
const base::FilePath& entry_path,
MetadataFieldMask fields,
const GetMetadataCallback& callback) {
const int request_id = request_manager_->CreateRequest(
GET_METADATA,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::GetMetadata(
- event_router_, file_system_info_, entry_path, fields, callback)));
+ scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::GetMetadata<DestinationPolicy>(
+ event_router_, file_system_info_,
+ entry_path, fields, callback)));
if (!request_id) {
callback.Run(make_scoped_ptr<EntryMetadata>(NULL),
base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::ReadDirectory(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::ReadDirectory(
const base::FilePath& directory_path,
const storage::AsyncFileUtil::ReadDirectoryCallback& callback) {
const int request_id = request_manager_->CreateRequest(
READ_DIRECTORY,
scoped_ptr<RequestManager::HandlerInterface>(
- new operations::ReadDirectory(
+ new operations::ReadDirectory<DestinationPolicy>(
event_router_, file_system_info_, directory_path, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY,
@@ -210,11 +230,12 @@ AbortCallback ProvidedFileSystem::ReadDirectory(
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::ReadFile(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::ReadFile(
int file_handle,
net::IOBuffer* buffer,
int64 offset,
@@ -223,15 +244,10 @@ AbortCallback ProvidedFileSystem::ReadFile(
TRACE_EVENT1(
"file_system_provider", "ProvidedFileSystem::ReadFile", "length", length);
const int request_id = request_manager_->CreateRequest(
- READ_FILE,
- make_scoped_ptr<RequestManager::HandlerInterface>(
- new operations::ReadFile(event_router_,
- file_system_info_,
- file_handle,
- buffer,
- offset,
- length,
- callback)));
+ READ_FILE, make_scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::ReadFile<DestinationPolicy>(
+ event_router_, file_system_info_, file_handle, buffer,
+ offset, length, callback)));
if (!request_id) {
callback.Run(0 /* chunk_length */,
false /* has_more */,
@@ -239,123 +255,131 @@ AbortCallback ProvidedFileSystem::ReadFile(
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::OpenFile(const base::FilePath& file_path,
- OpenFileMode mode,
- const OpenFileCallback& callback) {
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::OpenFile(
+ const base::FilePath& file_path,
+ OpenFileMode mode,
+ const OpenFileCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- OPEN_FILE,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::OpenFile(
- event_router_, file_system_info_, file_path, mode,
- base::Bind(&ProvidedFileSystem::OnOpenFileCompleted,
- weak_ptr_factory_.GetWeakPtr(), file_path, mode,
- callback))));
+ OPEN_FILE, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::OpenFile<DestinationPolicy>(
+ event_router_, file_system_info_, file_path, mode,
+ base::Bind(&ProvidedFileSystem::OnOpenFileCompleted,
+ weak_ptr_factory_.GetWeakPtr(), file_path,
+ mode, callback))));
if (!request_id) {
callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::CloseFile(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::CloseFile(
int file_handle,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
CLOSE_FILE,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::CloseFile(
- event_router_, file_system_info_, file_handle,
- base::Bind(&ProvidedFileSystem::OnCloseFileCompleted,
- weak_ptr_factory_.GetWeakPtr(), file_handle, callback))));
+ scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::CloseFile<DestinationPolicy>(
+ event_router_, file_system_info_, file_handle,
+ base::Bind(
+ &ProvidedFileSystem<DestinationPolicy>::OnCloseFileCompleted,
+ weak_ptr_factory_.GetWeakPtr(), file_handle,
+ callback))));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::CreateDirectory(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::CreateDirectory(
const base::FilePath& directory_path,
bool recursive,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- CREATE_DIRECTORY,
- scoped_ptr<RequestManager::HandlerInterface>(
- new operations::CreateDirectory(event_router_,
- file_system_info_,
- directory_path,
- recursive,
- callback)));
+ CREATE_DIRECTORY, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::CreateDirectory<DestinationPolicy>(
+ event_router_, file_system_info_,
+ directory_path, recursive, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::DeleteEntry(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::DeleteEntry(
const base::FilePath& entry_path,
bool recursive,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- DELETE_ENTRY,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::DeleteEntry(
- event_router_, file_system_info_, entry_path, recursive, callback)));
+ DELETE_ENTRY, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::DeleteEntry<DestinationPolicy>(
+ event_router_, file_system_info_, entry_path,
+ recursive, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::CreateFile(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::CreateFile(
const base::FilePath& file_path,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
CREATE_FILE,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::CreateFile(
- event_router_, file_system_info_, file_path, callback)));
+ scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::CreateFile<DestinationPolicy>(
+ event_router_, file_system_info_,
+ file_path, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::CopyEntry(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::CopyEntry(
const base::FilePath& source_path,
const base::FilePath& target_path,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- COPY_ENTRY,
- scoped_ptr<RequestManager::HandlerInterface>(
- new operations::CopyEntry(event_router_,
- file_system_info_,
- source_path,
- target_path,
- callback)));
+ COPY_ENTRY, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::CopyEntry<DestinationPolicy>(
+ event_router_, file_system_info_, source_path,
+ target_path, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::WriteFile(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::WriteFile(
int file_handle,
net::IOBuffer* buffer,
int64 offset,
@@ -368,61 +392,59 @@ AbortCallback ProvidedFileSystem::WriteFile(
const int request_id = request_manager_->CreateRequest(
WRITE_FILE,
make_scoped_ptr<RequestManager::HandlerInterface>(
- new operations::WriteFile(event_router_,
- file_system_info_,
- file_handle,
- make_scoped_refptr(buffer),
- offset,
- length,
- callback)));
+ new operations::WriteFile<DestinationPolicy>(
+ event_router_, file_system_info_, file_handle,
+ make_scoped_refptr(buffer), offset, length, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::MoveEntry(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::MoveEntry(
const base::FilePath& source_path,
const base::FilePath& target_path,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- MOVE_ENTRY,
- scoped_ptr<RequestManager::HandlerInterface>(
- new operations::MoveEntry(event_router_,
- file_system_info_,
- source_path,
- target_path,
- callback)));
+ MOVE_ENTRY, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::MoveEntry<DestinationPolicy>(
+ event_router_, file_system_info_, source_path,
+ target_path, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::Truncate(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::Truncate(
const base::FilePath& file_path,
int64 length,
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
TRUNCATE,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::Truncate(
- event_router_, file_system_info_, file_path, length, callback)));
+ scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::Truncate<DestinationPolicy>(
+ event_router_, file_system_info_,
+ file_path, length, callback)));
if (!request_id) {
callback.Run(base::File::FILE_ERROR_SECURITY);
return AbortCallback();
}
- return base::Bind(
- &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id);
+ return base::Bind(&ProvidedFileSystem<DestinationPolicy>::Abort,
+ weak_ptr_factory_.GetWeakPtr(), request_id);
}
-AbortCallback ProvidedFileSystem::AddWatcher(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::AddWatcher(
const GURL& origin,
const base::FilePath& entry_path,
bool recursive,
@@ -432,53 +454,67 @@ AbortCallback ProvidedFileSystem::AddWatcher(
notification_callback) {
const size_t token = watcher_queue_.NewToken();
watcher_queue_.Enqueue(
- token, base::Bind(&ProvidedFileSystem::AddWatcherInQueue,
- base::Unretained(this), // Outlived by the queue.
- AddWatcherInQueueArgs(token, origin, entry_path,
- recursive, persistent, callback,
- notification_callback)));
+ token, base::Bind(
+ &ProvidedFileSystem<DestinationPolicy>::AddWatcherInQueue,
+ base::Unretained(this), // Outlived by the queue.
+ AddWatcherInQueueArgs(token, origin, entry_path,
+ recursive, persistent, callback,
+ notification_callback)));
return AbortCallback();
}
-void ProvidedFileSystem::RemoveWatcher(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::RemoveWatcher(
const GURL& origin,
const base::FilePath& entry_path,
bool recursive,
const storage::AsyncFileUtil::StatusCallback& callback) {
const size_t token = watcher_queue_.NewToken();
watcher_queue_.Enqueue(
- token, base::Bind(&ProvidedFileSystem::RemoveWatcherInQueue,
- base::Unretained(this), // Outlived by the queue.
- token, origin, entry_path, recursive, callback));
+ token, base::Bind(
+ &ProvidedFileSystem<DestinationPolicy>::RemoveWatcherInQueue,
+ base::Unretained(this), // Outlived by the queue.
+ token, origin, entry_path, recursive, callback));
}
-const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const {
+template <class DestinationPolicy>
+const ProvidedFileSystemInfo&
+ProvidedFileSystem<DestinationPolicy>::GetFileSystemInfo() const {
return file_system_info_;
}
-RequestManager* ProvidedFileSystem::GetRequestManager() {
+template <class DestinationPolicy>
+RequestManager* ProvidedFileSystem<DestinationPolicy>::GetRequestManager() {
return request_manager_.get();
}
-Watchers* ProvidedFileSystem::GetWatchers() {
+template <class DestinationPolicy>
+Watchers* ProvidedFileSystem<DestinationPolicy>::GetWatchers() {
return &watchers_;
}
-const OpenedFiles& ProvidedFileSystem::GetOpenedFiles() const {
+template <class DestinationPolicy>
+const OpenedFiles&
+ProvidedFileSystem<DestinationPolicy>::GetOpenedFiles() const {
return opened_files_;
}
-void ProvidedFileSystem::AddObserver(ProvidedFileSystemObserver* observer) {
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::AddObserver(
+ ProvidedFileSystemObserver* observer) {
DCHECK(observer);
observers_.AddObserver(observer);
}
-void ProvidedFileSystem::RemoveObserver(ProvidedFileSystemObserver* observer) {
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::RemoveObserver(
+ ProvidedFileSystemObserver* observer) {
DCHECK(observer);
observers_.RemoveObserver(observer);
}
-void ProvidedFileSystem::Notify(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::Notify(
const base::FilePath& entry_path,
bool recursive,
storage::WatcherManager::ChangeType change_type,
@@ -487,37 +523,40 @@ void ProvidedFileSystem::Notify(
const storage::AsyncFileUtil::StatusCallback& callback) {
const size_t token = watcher_queue_.NewToken();
watcher_queue_.Enqueue(
- token, base::Bind(&ProvidedFileSystem::NotifyInQueue,
+ token, base::Bind(&ProvidedFileSystem<DestinationPolicy>::NotifyInQueue,
base::Unretained(this), // Outlived by the queue.
base::Passed(make_scoped_ptr(new NotifyInQueueArgs(
token, entry_path, recursive, change_type,
changes.Pass(), tag, callback)))));
}
-void ProvidedFileSystem::Configure(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::Configure(
const storage::AsyncFileUtil::StatusCallback& callback) {
const int request_id = request_manager_->CreateRequest(
- CONFIGURE,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::Configure(
- event_router_, file_system_info_, callback)));
+ CONFIGURE, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::Configure<DestinationPolicy>(
+ event_router_, file_system_info_, callback)));
if (!request_id)
callback.Run(base::File::FILE_ERROR_SECURITY);
}
-void ProvidedFileSystem::Abort(int operation_request_id) {
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::Abort(int operation_request_id) {
request_manager_->RejectRequest(operation_request_id,
make_scoped_ptr(new RequestValue()),
base::File::FILE_ERROR_ABORT);
if (!request_manager_->CreateRequest(
- ABORT,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::Abort(
- event_router_, file_system_info_, operation_request_id,
- base::Bind(&EmptyStatusCallback))))) {
+ ABORT, scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::Abort<DestinationPolicy>(
+ event_router_, file_system_info_, operation_request_id,
+ base::Bind(&EmptyStatusCallback))))) {
LOG(ERROR) << "Failed to create an abort request.";
}
}
-AbortCallback ProvidedFileSystem::AddWatcherInQueue(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::AddWatcherInQueue(
const AddWatcherInQueueArgs& args) {
if (args.persistent && (!file_system_info_.supports_notify_tag() ||
!args.notification_callback.is_null())) {
@@ -547,12 +586,14 @@ AbortCallback ProvidedFileSystem::AddWatcherInQueue(
const int request_id = request_manager_->CreateRequest(
ADD_WATCHER,
- scoped_ptr<RequestManager::HandlerInterface>(new operations::AddWatcher(
- event_router_, file_system_info_, args.entry_path, args.recursive,
- base::Bind(&ProvidedFileSystem::OnAddWatcherInQueueCompleted,
- weak_ptr_factory_.GetWeakPtr(), args.token,
- args.entry_path, args.recursive, subscriber,
- args.callback))));
+ scoped_ptr<RequestManager::HandlerInterface>(
+ new operations::AddWatcher<DestinationPolicy>(
+ event_router_, file_system_info_, args.entry_path, args.recursive,
+ base::Bind(
+ &ProvidedFileSystem<DestinationPolicy>::
+ OnAddWatcherInQueueCompleted,
+ weak_ptr_factory_.GetWeakPtr(), args.token, args.entry_path,
+ args.recursive, subscriber, args.callback))));
if (!request_id) {
OnAddWatcherInQueueCompleted(args.token, args.entry_path, args.recursive,
@@ -563,7 +604,8 @@ AbortCallback ProvidedFileSystem::AddWatcherInQueue(
return AbortCallback();
}
-AbortCallback ProvidedFileSystem::RemoveWatcherInQueue(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::RemoveWatcherInQueue(
size_t token,
const GURL& origin,
const base::FilePath& entry_path,
@@ -592,16 +634,19 @@ AbortCallback ProvidedFileSystem::RemoveWatcherInQueue(
request_manager_->CreateRequest(
REMOVE_WATCHER,
scoped_ptr<RequestManager::HandlerInterface>(
- new operations::RemoveWatcher(
+ new operations::RemoveWatcher<DestinationPolicy>(
event_router_, file_system_info_, entry_path, recursive,
- base::Bind(&ProvidedFileSystem::OnRemoveWatcherInQueueCompleted,
- weak_ptr_factory_.GetWeakPtr(), token, origin, key,
- callback, true /* extension_response */))));
+ base::Bind(
+ &ProvidedFileSystem<DestinationPolicy>::
+ OnRemoveWatcherInQueueCompleted,
+ weak_ptr_factory_.GetWeakPtr(), token, origin, key, callback,
+ true /* extension_response */))));
return AbortCallback();
}
-AbortCallback ProvidedFileSystem::NotifyInQueue(
+template <class DestinationPolicy>
+AbortCallback ProvidedFileSystem<DestinationPolicy>::NotifyInQueue(
scoped_ptr<NotifyInQueueArgs> args) {
const WatcherKey key(args->entry_path, args->recursive);
const auto& watcher_it = watchers_.find(key);
@@ -629,10 +674,11 @@ AbortCallback ProvidedFileSystem::NotifyInQueue(
const ProvidedFileSystemObserver::Changes& changes_ref = *args->changes.get();
const storage::WatcherManager::ChangeType change_type = args->change_type;
- scoped_refptr<AutoUpdater> auto_updater(
- new AutoUpdater(base::Bind(&ProvidedFileSystem::OnNotifyInQueueCompleted,
- weak_ptr_factory_.GetWeakPtr(),
- base::Passed(&args), base::File::FILE_OK)));
+ scoped_refptr<AutoUpdater> auto_updater(new AutoUpdater(
+ base::Bind(
+ &ProvidedFileSystem<DestinationPolicy>::OnNotifyInQueueCompleted,
+ weak_ptr_factory_.GetWeakPtr(), base::Passed(&args),
+ base::File::FILE_OK)));
// Call all notification callbacks (if any).
for (const auto& subscriber_it : watcher_it->second.subscribers) {
@@ -654,11 +700,14 @@ AbortCallback ProvidedFileSystem::NotifyInQueue(
return AbortCallback();
}
-base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() {
+template <class DestinationPolicy>
+base::WeakPtr<ProvidedFileSystemInterface>
+ProvidedFileSystem<DestinationPolicy>::GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
-void ProvidedFileSystem::OnAddWatcherInQueueCompleted(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::OnAddWatcherInQueueCompleted(
size_t token,
const base::FilePath& entry_path,
bool recursive,
@@ -692,7 +741,8 @@ void ProvidedFileSystem::OnAddWatcherInQueueCompleted(
watcher_queue_.Complete(token);
}
-void ProvidedFileSystem::OnRemoveWatcherInQueueCompleted(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::OnRemoveWatcherInQueueCompleted(
size_t token,
const GURL& origin,
const WatcherKey& key,
@@ -724,7 +774,8 @@ void ProvidedFileSystem::OnRemoveWatcherInQueueCompleted(
watcher_queue_.Complete(token);
}
-void ProvidedFileSystem::OnNotifyInQueueCompleted(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::OnNotifyInQueueCompleted(
scoped_ptr<NotifyInQueueArgs> args,
base::File::Error result) {
if (result != base::File::FILE_OK) {
@@ -763,11 +814,13 @@ void ProvidedFileSystem::OnNotifyInQueueCompleted(
watcher_queue_.Complete(args->token);
}
-void ProvidedFileSystem::OnOpenFileCompleted(const base::FilePath& file_path,
- OpenFileMode mode,
- const OpenFileCallback& callback,
- int file_handle,
- base::File::Error result) {
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::OnOpenFileCompleted(
+ const base::FilePath& file_path,
+ OpenFileMode mode,
+ const OpenFileCallback& callback,
+ int file_handle,
+ base::File::Error result) {
if (result != base::File::FILE_OK) {
callback.Run(file_handle, result);
return;
@@ -777,7 +830,8 @@ void ProvidedFileSystem::OnOpenFileCompleted(const base::FilePath& file_path,
callback.Run(file_handle, base::File::FILE_OK);
}
-void ProvidedFileSystem::OnCloseFileCompleted(
+template <class DestinationPolicy>
+void ProvidedFileSystem<DestinationPolicy>::OnCloseFileCompleted(
int file_handle,
const storage::AsyncFileUtil::StatusCallback& callback,
base::File::Error result) {
@@ -787,5 +841,7 @@ void ProvidedFileSystem::OnCloseFileCompleted(
callback.Run(result);
}
+FOR_EACH_DESTINATION_SPECIALIZE(ProvidedFileSystem)
+
} // namespace file_system_provider
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698