diff options
Diffstat (limited to 'chrome/browser')
28 files changed, 185 insertions, 133 deletions
diff --git a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc index d15392e..5bd2b0a8 100644 --- a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc +++ b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc @@ -97,6 +97,15 @@ bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunWhenValid() { return true; } +bool FileSystemProviderInternalUnmountRequestedErrorFunction::RunWhenValid() { + using api::file_system_provider_internal::UnmountRequestedError::Params; + const scoped_ptr<Params> params(Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + + RejectRequest(ProviderErrorToFileError(params->error)); + return true; +} + bool FileSystemProviderInternalGetMetadataRequestedSuccessFunction::RunWhenValid() { using api::file_system_provider_internal::GetMetadataRequestedSuccess::Params; @@ -108,6 +117,16 @@ FileSystemProviderInternalGetMetadataRequestedSuccessFunction::RunWhenValid() { return true; } +bool +FileSystemProviderInternalGetMetadataRequestedErrorFunction::RunWhenValid() { + using api::file_system_provider_internal::GetMetadataRequestedError::Params; + const scoped_ptr<Params> params(Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + + RejectRequest(ProviderErrorToFileError(params->error)); + return true; +} + bool FileSystemProviderInternalReadDirectoryRequestedSuccessFunction:: RunWhenValid() { using api::file_system_provider_internal::ReadDirectoryRequestedSuccess:: @@ -122,6 +141,16 @@ bool FileSystemProviderInternalReadDirectoryRequestedSuccessFunction:: } bool +FileSystemProviderInternalReadDirectoryRequestedErrorFunction::RunWhenValid() { + using api::file_system_provider_internal::ReadDirectoryRequestedError::Params; + const scoped_ptr<Params> params(Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + + RejectRequest(ProviderErrorToFileError(params->error)); + return true; +} + +bool FileSystemProviderInternalOpenFileRequestedSuccessFunction::RunWhenValid() { using api::file_system_provider_internal::OpenFileRequestedSuccess::Params; scoped_ptr<Params> params(Params::Create(*args_)); @@ -132,6 +161,15 @@ FileSystemProviderInternalOpenFileRequestedSuccessFunction::RunWhenValid() { return true; } +bool FileSystemProviderInternalOpenFileRequestedErrorFunction::RunWhenValid() { + using api::file_system_provider_internal::OpenFileRequestedError::Params; + const scoped_ptr<Params> params(Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + + RejectRequest(ProviderErrorToFileError(params->error)); + return true; +} + bool FileSystemProviderInternalCloseFileRequestedSuccessFunction::RunWhenValid() { using api::file_system_provider_internal::CloseFileRequestedSuccess::Params; @@ -143,6 +181,15 @@ FileSystemProviderInternalCloseFileRequestedSuccessFunction::RunWhenValid() { return true; } +bool FileSystemProviderInternalCloseFileRequestedErrorFunction::RunWhenValid() { + using api::file_system_provider_internal::CloseFileRequestedError::Params; + const scoped_ptr<Params> params(Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + + RejectRequest(ProviderErrorToFileError(params->error)); + return true; +} + bool FileSystemProviderInternalReadFileRequestedSuccessFunction::RunWhenValid() { using api::file_system_provider_internal::ReadFileRequestedSuccess::Params; @@ -155,12 +202,12 @@ FileSystemProviderInternalReadFileRequestedSuccessFunction::RunWhenValid() { return true; } -bool FileSystemProviderInternalOperationRequestedErrorFunction::RunWhenValid() { - using api::file_system_provider_internal::OperationRequestedError::Params; - scoped_ptr<Params> params(Params::Create(*args_)); +bool FileSystemProviderInternalReadFileRequestedErrorFunction::RunWhenValid() { + using api::file_system_provider_internal::ReadFileRequestedError::Params; + const scoped_ptr<Params> params(Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params); - RejectRequest(RequestValue::CreateForOperationError(params.Pass()), - ProviderErrorToFileError(params->error)); + + RejectRequest(ProviderErrorToFileError(params->error)); return true; } diff --git a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h index fa92009..c4c94fd 100644 --- a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h +++ b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h @@ -42,6 +42,18 @@ class FileSystemProviderInternalUnmountRequestedSuccessFunction virtual bool RunWhenValid() OVERRIDE; }; +class FileSystemProviderInternalUnmountRequestedErrorFunction + : public FileSystemProviderInternalFunction { + public: + DECLARE_EXTENSION_FUNCTION( + "fileSystemProviderInternal.unmountRequestedError", + FILESYSTEMPROVIDERINTERNAL_GETMETADATAREQUESTEDERROR) + + protected: + virtual ~FileSystemProviderInternalUnmountRequestedErrorFunction() {} + virtual bool RunWhenValid() OVERRIDE; +}; + class FileSystemProviderInternalGetMetadataRequestedSuccessFunction : public FileSystemProviderInternalFunction { public: @@ -54,6 +66,18 @@ class FileSystemProviderInternalGetMetadataRequestedSuccessFunction virtual bool RunWhenValid() OVERRIDE; }; +class FileSystemProviderInternalGetMetadataRequestedErrorFunction + : public FileSystemProviderInternalFunction { + public: + DECLARE_EXTENSION_FUNCTION( + "fileSystemProviderInternal.getMetadataRequestedError", + FILESYSTEMPROVIDERINTERNAL_GETMETADATAREQUESTEDERROR) + + protected: + virtual ~FileSystemProviderInternalGetMetadataRequestedErrorFunction() {} + virtual bool RunWhenValid() OVERRIDE; +}; + class FileSystemProviderInternalReadDirectoryRequestedSuccessFunction : public FileSystemProviderInternalFunction { public: @@ -66,6 +90,18 @@ class FileSystemProviderInternalReadDirectoryRequestedSuccessFunction virtual bool RunWhenValid() OVERRIDE; }; +class FileSystemProviderInternalReadDirectoryRequestedErrorFunction + : public FileSystemProviderInternalFunction { + public: + DECLARE_EXTENSION_FUNCTION( + "fileSystemProviderInternal.readDirectoryRequestedError", + FILESYSTEMPROVIDERINTERNAL_READDIRECTORYREQUESTEDERROR) + + protected: + virtual ~FileSystemProviderInternalReadDirectoryRequestedErrorFunction() {} + virtual bool RunWhenValid() OVERRIDE; +}; + class FileSystemProviderInternalOpenFileRequestedSuccessFunction : public FileSystemProviderInternalFunction { public: @@ -78,6 +114,18 @@ class FileSystemProviderInternalOpenFileRequestedSuccessFunction virtual bool RunWhenValid() OVERRIDE; }; +class FileSystemProviderInternalOpenFileRequestedErrorFunction + : public FileSystemProviderInternalFunction { + public: + DECLARE_EXTENSION_FUNCTION( + "fileSystemProviderInternal.openFileRequestedError", + FILESYSTEMPROVIDERINTERNAL_OPENFILEREQUESTEDERROR) + + protected: + virtual ~FileSystemProviderInternalOpenFileRequestedErrorFunction() {} + virtual bool RunWhenValid() OVERRIDE; +}; + class FileSystemProviderInternalCloseFileRequestedSuccessFunction : public FileSystemProviderInternalFunction { public: @@ -90,6 +138,18 @@ class FileSystemProviderInternalCloseFileRequestedSuccessFunction virtual bool RunWhenValid() OVERRIDE; }; +class FileSystemProviderInternalCloseFileRequestedErrorFunction + : public FileSystemProviderInternalFunction { + public: + DECLARE_EXTENSION_FUNCTION( + "fileSystemProviderInternal.closeFileRequestedError", + FILESYSTEMPROVIDERINTERNAL_CLOSEFILEREQUESTEDERROR) + + protected: + virtual ~FileSystemProviderInternalCloseFileRequestedErrorFunction() {} + virtual bool RunWhenValid() OVERRIDE; +}; + class FileSystemProviderInternalReadFileRequestedSuccessFunction : public FileSystemProviderInternalFunction { public: @@ -102,15 +162,15 @@ class FileSystemProviderInternalReadFileRequestedSuccessFunction virtual bool RunWhenValid() OVERRIDE; }; -class FileSystemProviderInternalOperationRequestedErrorFunction +class FileSystemProviderInternalReadFileRequestedErrorFunction : public FileSystemProviderInternalFunction { public: DECLARE_EXTENSION_FUNCTION( - "fileSystemProviderInternal.operationRequestedError", - FILESYSTEMPROVIDERINTERNAL_OPERATIONREQUESTEDERROR) + "fileSystemProviderInternal.readFileRequestedError", + FILESYSTEMPROVIDERINTERNAL_READFILEREQUESTEDERROR) protected: - virtual ~FileSystemProviderInternalOperationRequestedErrorFunction() {} + virtual ~FileSystemProviderInternalReadFileRequestedErrorFunction() {} virtual bool RunWhenValid() OVERRIDE; }; diff --git a/chrome/browser/chromeos/extensions/file_system_provider/provider_function.cc b/chrome/browser/chromeos/extensions/file_system_provider/provider_function.cc index 0061ee1..d77b9f5 100644 --- a/chrome/browser/chromeos/extensions/file_system_provider/provider_function.cc +++ b/chrome/browser/chromeos/extensions/file_system_provider/provider_function.cc @@ -83,9 +83,8 @@ FileSystemProviderInternalFunction::FileSystemProviderInternalFunction() } void FileSystemProviderInternalFunction::RejectRequest( - scoped_ptr<chromeos::file_system_provider::RequestValue> value, base::File::Error error) { - if (!request_manager_->RejectRequest(request_id_, value.Pass(), error)) + if (!request_manager_->RejectRequest(request_id_, error)) SetErrorResponse(kSecurityErrorName, kResponseFailedErrorMessage); } diff --git a/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h b/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h index b575d0e..f4ed7d7 100644 --- a/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h +++ b/chrome/browser/chromeos/extensions/file_system_provider/provider_function.h @@ -60,9 +60,7 @@ class FileSystemProviderInternalFunction : public ChromeSyncExtensionFunction { virtual ~FileSystemProviderInternalFunction() {} // Rejects the request and sets a response for this API function. - void RejectRequest( - scoped_ptr<chromeos::file_system_provider::RequestValue> value, - base::File::Error error); + void RejectRequest(base::File::Error error); // Fulfills the request with parsed arguments of this API function // encapsulated as a RequestValue instance. Also, sets a response. diff --git a/chrome/browser/chromeos/file_system_provider/operations/close_file.cc b/chrome/browser/chromeos/file_system_provider/operations/close_file.cc index ad97736..c38624c2 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/close_file.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/close_file.cc @@ -41,9 +41,7 @@ void CloseFile::OnSuccess(int /* request_id */, callback_.Run(base::File::FILE_OK); } -void CloseFile::OnError(int /* request_id */, - scoped_ptr<RequestValue> /* result */, - base::File::Error error) { +void CloseFile::OnError(int /* request_id */, base::File::Error error) { callback_.Run(error); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/close_file.h b/chrome/browser/chromeos/file_system_provider/operations/close_file.h index 83bafff..c9ab99e 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/close_file.h +++ b/chrome/browser/chromeos/file_system_provider/operations/close_file.h @@ -41,9 +41,7 @@ class CloseFile : public Operation { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE; private: int open_request_id_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc index 316dd06..c9429e5 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc @@ -144,6 +144,9 @@ TEST_F(FileSystemProviderOperationsCloseFileTest, Execute_NoListener) { } TEST_F(FileSystemProviderOperationsCloseFileTest, OnSuccess) { + using extensions::api::file_system_provider_internal:: + CloseFileRequestedSuccess::Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -166,6 +169,9 @@ TEST_F(FileSystemProviderOperationsCloseFileTest, OnSuccess) { } TEST_F(FileSystemProviderOperationsCloseFileTest, OnError) { + using extensions::api::file_system_provider_internal:: + CloseFileRequestedError::Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -180,9 +186,7 @@ TEST_F(FileSystemProviderOperationsCloseFileTest, OnError) { EXPECT_TRUE(close_file.Execute(kRequestId)); - close_file.OnError(kRequestId, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_TOO_MANY_OPENED); + close_file.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); ASSERT_EQ(1u, callback_logger.events().size()); EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_logger.events()[0]); diff --git a/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc b/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc index dde4ce5..476ac50 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc @@ -77,9 +77,7 @@ void GetMetadata::OnSuccess(int /* request_id */, callback_.Run(base::File::FILE_OK, file_info); } -void GetMetadata::OnError(int /* request_id */, - scoped_ptr<RequestValue> /* result */, - base::File::Error error) { +void GetMetadata::OnError(int /* request_id */, base::File::Error error) { callback_.Run(error, base::File::Info()); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/get_metadata.h b/chrome/browser/chromeos/file_system_provider/operations/get_metadata.h index 38eb87b..a41b54c 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/get_metadata.h +++ b/chrome/browser/chromeos/file_system_provider/operations/get_metadata.h @@ -39,9 +39,7 @@ class GetMetadata : public Operation { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE; private: base::FilePath entry_path_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc index cb72bec..e62efd8 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc @@ -164,6 +164,7 @@ TEST_F(FileSystemProviderOperationsGetMetadataTest, Execute_NoListener) { } TEST_F(FileSystemProviderOperationsGetMetadataTest, OnSuccess) { + using extensions::api::file_system_provider::EntryMetadata; using extensions::api::file_system_provider_internal:: GetMetadataRequestedSuccess::Params; @@ -229,6 +230,10 @@ TEST_F(FileSystemProviderOperationsGetMetadataTest, OnSuccess) { } TEST_F(FileSystemProviderOperationsGetMetadataTest, OnError) { + using extensions::api::file_system_provider::EntryMetadata; + using extensions::api::file_system_provider_internal:: + GetMetadataRequestedError::Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -243,9 +248,7 @@ TEST_F(FileSystemProviderOperationsGetMetadataTest, OnError) { EXPECT_TRUE(get_metadata.Execute(kRequestId)); - get_metadata.OnError(kRequestId, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_TOO_MANY_OPENED); + get_metadata.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0]; diff --git a/chrome/browser/chromeos/file_system_provider/operations/open_file.cc b/chrome/browser/chromeos/file_system_provider/operations/open_file.cc index 0104089..b0592e9 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/open_file.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/open_file.cc @@ -64,9 +64,7 @@ void OpenFile::OnSuccess(int request_id, callback_.Run(request_id, base::File::FILE_OK); } -void OpenFile::OnError(int /* request_id */, - scoped_ptr<RequestValue> /* result */, - base::File::Error error) { +void OpenFile::OnError(int /* request_id */, base::File::Error error) { callback_.Run(0 /* file_handle */, error); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/open_file.h b/chrome/browser/chromeos/file_system_provider/operations/open_file.h index d0fe1a0..e3585db 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/open_file.h +++ b/chrome/browser/chromeos/file_system_provider/operations/open_file.h @@ -43,9 +43,7 @@ class OpenFile : public Operation { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE; private: base::FilePath file_path_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc index b7853d1..9d028cb 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc @@ -178,6 +178,9 @@ TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_NoListener) { } TEST_F(FileSystemProviderOperationsOpenFileTest, OnSuccess) { + using extensions::api::file_system_provider_internal:: + OpenFileRequestedSuccess::Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -204,6 +207,9 @@ TEST_F(FileSystemProviderOperationsOpenFileTest, OnSuccess) { } TEST_F(FileSystemProviderOperationsOpenFileTest, OnError) { + using extensions::api::file_system_provider_internal::OpenFileRequestedError:: + Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -220,9 +226,7 @@ TEST_F(FileSystemProviderOperationsOpenFileTest, OnError) { EXPECT_TRUE(open_file.Execute(kRequestId)); - open_file.OnError(kRequestId, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_TOO_MANY_OPENED); + open_file.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0]; EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); diff --git a/chrome/browser/chromeos/file_system_provider/operations/operation.h b/chrome/browser/chromeos/file_system_provider/operations/operation.h index e5d07eb..3c1e78a 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/operation.h +++ b/chrome/browser/chromeos/file_system_provider/operations/operation.h @@ -41,9 +41,7 @@ class Operation : public RequestManager::HandlerInterface { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE = 0; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE = 0; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE = 0; // Sets custom dispatchign event implementation for tests. void SetDispatchEventImplForTesting( diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_directory.cc b/chrome/browser/chromeos/file_system_provider/operations/read_directory.cc index e46b4f5..f0ae20c 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_directory.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/read_directory.cc @@ -84,9 +84,7 @@ void ReadDirectory::OnSuccess(int /* request_id */, callback_.Run(base::File::FILE_OK, entry_list, has_more); } -void ReadDirectory::OnError(int /* request_id */, - scoped_ptr<RequestValue> /* result */, - base::File::Error error) { +void ReadDirectory::OnError(int /* request_id */, base::File::Error error) { callback_.Run( error, fileapi::AsyncFileUtil::EntryList(), false /* has_more */); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_directory.h b/chrome/browser/chromeos/file_system_provider/operations/read_directory.h index bc939a6..535edad 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_directory.h +++ b/chrome/browser/chromeos/file_system_provider/operations/read_directory.h @@ -39,9 +39,7 @@ class ReadDirectory : public Operation { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE; private: base::FilePath directory_path_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc index 3764501..26ca85c 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc @@ -171,6 +171,7 @@ TEST_F(FileSystemProviderOperationsReadDirectoryTest, Execute_NoListener) { } TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess) { + using extensions::api::file_system_provider::EntryMetadata; using extensions::api::file_system_provider_internal:: ReadDirectoryRequestedSuccess::Params; @@ -241,6 +242,10 @@ TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess) { } TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnError) { + using extensions::api::file_system_provider::EntryMetadata; + using extensions::api::file_system_provider_internal:: + ReadDirectoryRequestedSuccess::Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -255,9 +260,7 @@ TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnError) { EXPECT_TRUE(read_directory.Execute(kRequestId)); - read_directory.OnError(kRequestId, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_TOO_MANY_OPENED); + read_directory.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0]; diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_file.cc b/chrome/browser/chromeos/file_system_provider/operations/read_file.cc index ca0bf5a..3f0d386 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_file.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/read_file.cc @@ -84,9 +84,7 @@ void ReadFile::OnSuccess(int /* request_id */, callback_.Run(copy_result, has_more, base::File::FILE_OK); } -void ReadFile::OnError(int /* request_id */, - scoped_ptr<RequestValue> /* result */, - base::File::Error error) { +void ReadFile::OnError(int /* request_id */, base::File::Error error) { callback_.Run(0 /* chunk_length */, false /* has_more */, error); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_file.h b/chrome/browser/chromeos/file_system_provider/operations/read_file.h index 1d0bc9e..98b92e0 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_file.h +++ b/chrome/browser/chromeos/file_system_provider/operations/read_file.h @@ -46,9 +46,7 @@ class ReadFile : public Operation { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE; private: int file_handle_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc index 8eec579..aa92d73 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc @@ -231,6 +231,9 @@ TEST_F(FileSystemProviderOperationsReadFileTest, OnSuccess) { } TEST_F(FileSystemProviderOperationsReadFileTest, OnError) { + using extensions::api::file_system_provider_internal::ReadFileRequestedError:: + Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -248,9 +251,7 @@ TEST_F(FileSystemProviderOperationsReadFileTest, OnError) { EXPECT_TRUE(read_file.Execute(kRequestId)); - read_file.OnError(kRequestId, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_TOO_MANY_OPENED); + read_file.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0]; diff --git a/chrome/browser/chromeos/file_system_provider/operations/unmount.cc b/chrome/browser/chromeos/file_system_provider/operations/unmount.cc index eb4ccba..395670a 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/unmount.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/unmount.cc @@ -34,9 +34,7 @@ void Unmount::OnSuccess(int /* request_id */, callback_.Run(base::File::FILE_OK); } -void Unmount::OnError(int /* request_id */, - scoped_ptr<RequestValue> /* result */, - base::File::Error error) { +void Unmount::OnError(int /* request_id */, base::File::Error error) { callback_.Run(error); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/unmount.h b/chrome/browser/chromeos/file_system_provider/operations/unmount.h index b6614d4..948b540 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/unmount.h +++ b/chrome/browser/chromeos/file_system_provider/operations/unmount.h @@ -39,9 +39,7 @@ class Unmount : public Operation { virtual void OnSuccess(int request_id, scoped_ptr<RequestValue> result, bool has_more) OVERRIDE; - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE; + virtual void OnError(int request_id, base::File::Error error) OVERRIDE; private: const fileapi::AsyncFileUtil::StatusCallback callback_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc index a1c9d82..d2c8f5e 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc @@ -162,6 +162,9 @@ TEST_F(FileSystemProviderOperationsUnmountTest, OnSuccess) { } TEST_F(FileSystemProviderOperationsUnmountTest, OnError) { + using extensions::api::file_system_provider_internal::UnmountRequestedError:: + Params; + LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; @@ -175,9 +178,7 @@ TEST_F(FileSystemProviderOperationsUnmountTest, OnError) { EXPECT_TRUE(unmount.Execute(kRequestId)); - unmount.OnError(kRequestId, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_NOT_FOUND); + unmount.OnError(kRequestId, base::File::FILE_ERROR_NOT_FOUND); ASSERT_EQ(1u, callback_logger.events().size()); base::File::Error event_result = callback_logger.events()[0]; EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, event_result); diff --git a/chrome/browser/chromeos/file_system_provider/request_manager.cc b/chrome/browser/chromeos/file_system_provider/request_manager.cc index 6fb39dd..9abe554 100644 --- a/chrome/browser/chromeos/file_system_provider/request_manager.cc +++ b/chrome/browser/chromeos/file_system_provider/request_manager.cc @@ -49,9 +49,7 @@ RequestManager::~RequestManager() { while (it != requests_.end()) { const int request_id = it->first; ++it; - RejectRequest(request_id, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_ABORT); + RejectRequest(request_id, base::File::FILE_ERROR_ABORT); } DCHECK_EQ(0u, requests_.size()); @@ -113,15 +111,15 @@ bool RequestManager::FulfillRequest(int request_id, return true; } -bool RequestManager::RejectRequest(int request_id, - scoped_ptr<RequestValue> response, - base::File::Error error) { +bool RequestManager::RejectRequest(int request_id, base::File::Error error) { RequestMap::iterator request_it = requests_.find(request_id); if (request_it == requests_.end()) return false; - request_it->second->handler->OnError(request_id, response.Pass(), error); + request_it->second->handler->OnError(request_id, error); + FOR_EACH_OBSERVER(Observer, observers_, OnRequestRejected(request_id, error)); + DestroyRequest(request_id); return true; @@ -152,9 +150,7 @@ RequestManager::Request::~Request() {} void RequestManager::OnRequestTimeout(int request_id) { FOR_EACH_OBSERVER(Observer, observers_, OnRequestTimeouted(request_id)); - RejectRequest(request_id, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_ABORT); + RejectRequest(request_id, base::File::FILE_ERROR_ABORT); } void RequestManager::DestroyRequest(int request_id) { diff --git a/chrome/browser/chromeos/file_system_provider/request_manager.h b/chrome/browser/chromeos/file_system_provider/request_manager.h index 4518bfa..c1cb5d5 100644 --- a/chrome/browser/chromeos/file_system_provider/request_manager.h +++ b/chrome/browser/chromeos/file_system_provider/request_manager.h @@ -59,9 +59,7 @@ class RequestManager { // Error callback invoked by the providing extension in response to // Execute(). It can be called at most once. It can be also called if the // request is aborted due to a timeout. - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) = 0; + virtual void OnError(int request_id, base::File::Error error) = 0; }; // Observes activities in the request manager. @@ -105,9 +103,7 @@ class RequestManager { // Handles error response for the |request_id|. If handling the error fails, // returns false. Always disposes the request. - bool RejectRequest(int request_id, - scoped_ptr<RequestValue> response, - base::File::Error error); + bool RejectRequest(int request_id, base::File::Error error); // Sets a custom timeout for tests. The new timeout value will be applied to // new requests diff --git a/chrome/browser/chromeos/file_system_provider/request_manager_unittest.cc b/chrome/browser/chromeos/file_system_provider/request_manager_unittest.cc index b4956a9..49fcefe 100644 --- a/chrome/browser/chromeos/file_system_provider/request_manager_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/request_manager_unittest.cc @@ -56,19 +56,15 @@ class EventLogger { class ErrorEvent { public: - ErrorEvent(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) - : request_id_(request_id), result_(result.Pass()), error_(error) {} + ErrorEvent(int request_id, base::File::Error error) + : request_id_(request_id), error_(error) {} virtual ~ErrorEvent() {} int request_id() { return request_id_; } - RequestValue* result() { return result_.get(); } base::File::Error error() { return error_; } private: int request_id_; - scoped_ptr<RequestValue> result_; base::File::Error error_; }; @@ -86,10 +82,8 @@ class EventLogger { new SuccessEvent(request_id, result.Pass(), has_more)); } - void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) { - error_events_.push_back(new ErrorEvent(request_id, result.Pass(), error)); + void OnError(int request_id, base::File::Error error) { + error_events_.push_back(new ErrorEvent(request_id, error)); } ScopedVector<ExecuteEvent>& execute_events() { return execute_events_; } @@ -135,11 +129,9 @@ class FakeHandler : public RequestManager::HandlerInterface { } // RequestManager::Handler overrides. - virtual void OnError(int request_id, - scoped_ptr<RequestValue> result, - base::File::Error error) OVERRIDE { + virtual void OnError(int request_id, base::File::Error error) OVERRIDE { if (logger_.get()) - logger_->OnError(request_id, result.Pass(), error); + logger_->OnError(request_id, error); } virtual ~FakeHandler() {} @@ -343,10 +335,8 @@ TEST_F(FileSystemProviderRequestManagerTest, CreateAndFulFill) { // Rejecting should also fail. { - bool retry = request_manager_->RejectRequest( - request_id, - scoped_ptr<RequestValue>(new RequestValue()), - base::File::FILE_ERROR_FAILED); + bool retry = request_manager_->RejectRequest(request_id, + base::File::FILE_ERROR_FAILED); EXPECT_FALSE(retry); EXPECT_EQ(0u, observer.rejected().size()); } @@ -449,8 +439,7 @@ TEST_F(FileSystemProviderRequestManagerTest, CreateAndReject) { EXPECT_EQ(request_id, observer.executed()[0].request_id()); base::File::Error error = base::File::FILE_ERROR_NO_MEMORY; - bool result = request_manager_->RejectRequest( - request_id, scoped_ptr<RequestValue>(new RequestValue()), error); + bool result = request_manager_->RejectRequest(request_id, error); EXPECT_TRUE(result); // Validate if the callback has correct arguments. @@ -476,8 +465,7 @@ TEST_F(FileSystemProviderRequestManagerTest, CreateAndReject) { // Rejecting should also fail. { - bool retry = request_manager_->RejectRequest( - request_id, scoped_ptr<RequestValue>(new RequestValue()), error); + bool retry = request_manager_->RejectRequest(request_id, error); EXPECT_FALSE(retry); EXPECT_EQ(1u, observer.rejected().size()); } @@ -559,8 +547,7 @@ TEST_F(FileSystemProviderRequestManagerTest, EXPECT_EQ(request_id, observer.executed()[0].request_id()); base::File::Error error = base::File::FILE_ERROR_NO_MEMORY; - bool result = request_manager_->RejectRequest( - request_id + 1, scoped_ptr<RequestValue>(new RequestValue()), error); + bool result = request_manager_->RejectRequest(request_id + 1, error); EXPECT_FALSE(result); // Callbacks should not be called. @@ -571,8 +558,7 @@ TEST_F(FileSystemProviderRequestManagerTest, // Confirm, that the request hasn't been removed, by rejecting it correctly. { - bool retry = request_manager_->RejectRequest( - request_id, scoped_ptr<RequestValue>(new RequestValue()), error); + bool retry = request_manager_->RejectRequest(request_id, error); EXPECT_TRUE(retry); EXPECT_EQ(1u, observer.rejected().size()); } diff --git a/chrome/browser/chromeos/file_system_provider/request_value.cc b/chrome/browser/chromeos/file_system_provider/request_value.cc index 73d98fc..53744d2 100644 --- a/chrome/browser/chromeos/file_system_provider/request_value.cc +++ b/chrome/browser/chromeos/file_system_provider/request_value.cc @@ -45,14 +45,6 @@ scoped_ptr<RequestValue> RequestValue::CreateForReadFileSuccess( return result.Pass(); } -scoped_ptr<RequestValue> RequestValue::CreateForOperationError( - scoped_ptr<extensions::api::file_system_provider_internal:: - OperationRequestedError::Params> params) { - scoped_ptr<RequestValue> result(new RequestValue); - result->operation_error_params_ = params.Pass(); - return result.Pass(); -} - scoped_ptr<RequestValue> RequestValue::CreateForTesting( const std::string& params) { scoped_ptr<RequestValue> result(new RequestValue); diff --git a/chrome/browser/chromeos/file_system_provider/request_value.h b/chrome/browser/chromeos/file_system_provider/request_value.h index b7c38f3..3920afb 100644 --- a/chrome/browser/chromeos/file_system_provider/request_value.h +++ b/chrome/browser/chromeos/file_system_provider/request_value.h @@ -40,10 +40,6 @@ class RequestValue { scoped_ptr<extensions::api::file_system_provider_internal:: ReadFileRequestedSuccess::Params> params); - static scoped_ptr<RequestValue> CreateForOperationError( - scoped_ptr<extensions::api::file_system_provider_internal:: - OperationRequestedError::Params> params); - static scoped_ptr<RequestValue> CreateForTesting(const std::string& params); const extensions::api::file_system_provider_internal:: @@ -70,12 +66,6 @@ class RequestValue { return read_file_success_params_.get(); } - const extensions::api::file_system_provider_internal:: - OperationRequestedError::Params* - operation_error_params() const { - return operation_error_params_.get(); - } - const std::string* testing_params() const { return testing_params_.get(); } private: @@ -89,8 +79,6 @@ class RequestValue { read_directory_success_params_; scoped_ptr<extensions::api::file_system_provider_internal:: ReadFileRequestedSuccess::Params> read_file_success_params_; - scoped_ptr<extensions::api::file_system_provider_internal:: - OperationRequestedError::Params> operation_error_params_; scoped_ptr<std::string> testing_params_; DISALLOW_COPY_AND_ASSIGN(RequestValue); |