diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc index 307b432e08ff0d..67938819de0e98 100644 --- a/chrome/test/ppapi/ppapi_browsertest.cc +++ b/chrome/test/ppapi/ppapi_browsertest.cc @@ -781,7 +781,6 @@ IN_PROC_BROWSER_TEST_F(PPAPITest, FileIO) { LIST_TEST(FileIO_ReadWriteSetLength) LIST_TEST(FileIO_ReadToArrayWriteSetLength) LIST_TEST(FileIO_TouchQuery) - LIST_TEST(FileIO_WillWriteWillSetLength) LIST_TEST(FileIO_RequestOSFileHandle) LIST_TEST(FileIO_RequestOSFileHandleWithOpenExclusive) LIST_TEST(FileIO_Mmap) @@ -797,7 +796,6 @@ IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FileIO) { LIST_TEST(FileIO_ReadWriteSetLength) LIST_TEST(FileIO_ReadToArrayWriteSetLength) LIST_TEST(FileIO_TouchQuery) - LIST_TEST(FileIO_WillWriteWillSetLength) LIST_TEST(FileIO_RequestOSFileHandle) LIST_TEST(FileIO_RequestOSFileHandleWithOpenExclusive) LIST_TEST(FileIO_Mmap) @@ -813,8 +811,6 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClNewlibTest, FileIO) { LIST_TEST(FileIO_ReadWriteSetLength) LIST_TEST(FileIO_ReadToArrayWriteSetLength) LIST_TEST(FileIO_TouchQuery) - // The following test requires PPB_FileIO_Trusted, not available in NaCl. - LIST_TEST(DISABLED_FileIO_WillWriteWillSetLength) LIST_TEST(FileIO_RequestOSFileHandle) LIST_TEST(FileIO_RequestOSFileHandleWithOpenExclusive) LIST_TEST(FileIO_Mmap) @@ -830,8 +826,6 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClGLibcTest, MAYBE_GLIBC(FileIO)) { LIST_TEST(FileIO_ReadWriteSetLength) LIST_TEST(FileIO_ReadToArrayWriteSetLength) LIST_TEST(FileIO_TouchQuery) - // The following test requires PPB_FileIO_Trusted, not available in NaCl. - LIST_TEST(DISABLED_FileIO_WillWriteWillSetLength) LIST_TEST(FileIO_RequestOSFileHandle) LIST_TEST(FileIO_RequestOSFileHandleWithOpenExclusive) LIST_TEST(FileIO_Mmap) @@ -847,8 +841,6 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClPNaClTest, FileIO) { LIST_TEST(FileIO_ReadWriteSetLength) LIST_TEST(FileIO_ReadToArrayWriteSetLength) LIST_TEST(FileIO_TouchQuery) - // The following test requires PPB_FileIO_Trusted, not available in NaCl. - LIST_TEST(DISABLED_FileIO_WillWriteWillSetLength) LIST_TEST(FileIO_RequestOSFileHandle) LIST_TEST(FileIO_RequestOSFileHandleWithOpenExclusive) LIST_TEST(FileIO_Mmap) diff --git a/content/renderer/pepper/pepper_file_io_host.cc b/content/renderer/pepper/pepper_file_io_host.cc index 6add31ae0d6cc7..f5bfeacc351d34 100644 --- a/content/renderer/pepper/pepper_file_io_host.cc +++ b/content/renderer/pepper/pepper_file_io_host.cc @@ -166,10 +166,6 @@ int32_t PepperFileIOHost::OnResourceMessageReceived( OnHostMsgFlush) PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_Close, OnHostMsgClose) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_WillWrite, - OnHostMsgWillWrite) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_WillSetLength, - OnHostMsgWillSetLength) PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_GetOSFileDescriptor, OnHostMsgGetOSFileDescriptor) PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_RequestOSFileHandle, @@ -395,51 +391,6 @@ int32_t PepperFileIOHost::OnHostMsgClose( return PP_OK; } -int32_t PepperFileIOHost::OnHostMsgWillWrite( - ppapi::host::HostMessageContext* context, - int64_t offset, - int32_t bytes_to_write) { - int32_t rv = state_manager_.CheckOperationState( - FileIOStateManager::OPERATION_EXCLUSIVE, true); - if (rv != PP_OK) - return rv; - - if (!quota_file_io_) - return PP_OK; - - if (!quota_file_io_->WillWrite( - offset, bytes_to_write, - base::Bind(&PepperFileIOHost::ExecutePlatformWriteCallback, - weak_factory_.GetWeakPtr(), - context->MakeReplyMessageContext()))) - return PP_ERROR_FAILED; - - state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); - return PP_OK_COMPLETIONPENDING; -} - -int32_t PepperFileIOHost::OnHostMsgWillSetLength( - ppapi::host::HostMessageContext* context, - int64_t length) { - int32_t rv = state_manager_.CheckOperationState( - FileIOStateManager::OPERATION_EXCLUSIVE, true); - if (rv != PP_OK) - return rv; - - if (!quota_file_io_) - return PP_OK; - - if (!quota_file_io_->WillSetLength( - length, - base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback, - weak_factory_.GetWeakPtr(), - context->MakeReplyMessageContext()))) - return PP_ERROR_FAILED; - - state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); - return PP_OK_COMPLETIONPENDING; -} - int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( ppapi::host::HostMessageContext* context) { if (!is_running_in_process_ && diff --git a/content/renderer/pepper/pepper_file_io_host.h b/content/renderer/pepper/pepper_file_io_host.h index 0525a6c605bc18..e6a3ced865a152 100644 --- a/content/renderer/pepper/pepper_file_io_host.h +++ b/content/renderer/pepper/pepper_file_io_host.h @@ -73,11 +73,6 @@ class PepperFileIOHost : public ppapi::host::ResourceHost, // Trusted API. int32_t OnHostMsgGetOSFileDescriptor( ppapi::host::HostMessageContext* context); - int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, - int64_t offset, - int32_t bytes_to_write); - int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, - int64_t length); // Callback handlers. These mostly convert the PlatformFileError to the // PP_Error code and send back the reply. Note that the argument diff --git a/content/renderer/pepper/quota_file_io.cc b/content/renderer/pepper/quota_file_io.cc index a5e4f6b3dd1b74..7995ce7362776d 100644 --- a/content/renderer/pepper/quota_file_io.cc +++ b/content/renderer/pepper/quota_file_io.cc @@ -51,25 +51,22 @@ class QuotaFileIO::PendingOperationBase { virtual void DidFail(PlatformFileError error) = 0; protected: - PendingOperationBase(QuotaFileIO* quota_io, bool is_will_operation) - : quota_io_(quota_io), is_will_operation_(is_will_operation) { + explicit PendingOperationBase(QuotaFileIO* quota_io) : quota_io_(quota_io) { DCHECK(quota_io_); quota_io_->WillUpdate(); } QuotaFileIO* quota_io_; - const bool is_will_operation_; }; class QuotaFileIO::WriteOperation : public PendingOperationBase { public: WriteOperation(QuotaFileIO* quota_io, - bool is_will_operation, int64_t offset, const char* buffer, int32_t bytes_to_write, const WriteCallback& callback) - : PendingOperationBase(quota_io, is_will_operation), + : PendingOperationBase(quota_io), offset_(offset), bytes_to_write_(bytes_to_write), callback_(callback), @@ -77,12 +74,10 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase { status_(base::PLATFORM_FILE_OK), bytes_written_(0), weak_factory_(this) { - if (!is_will_operation) { - // TODO(kinuko): Check the API convention if we really need to keep a copy - // of the buffer during the async write operations. - buffer_.reset(new char[bytes_to_write]); - memcpy(buffer_.get(), buffer, bytes_to_write); - } + // TODO(kinuko): Check the API convention if we really need to keep a copy + // of the buffer during the async write operations. + buffer_.reset(new char[bytes_to_write]); + memcpy(buffer_.get(), buffer, bytes_to_write); } virtual ~WriteOperation() {} virtual void Run() OVERRIDE { @@ -91,11 +86,6 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase { DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); return; } - if (is_will_operation_) { - // Assuming the write will succeed. - DidFinish(base::PLATFORM_FILE_OK, bytes_to_write_); - return; - } DCHECK(buffer_.get()); if (!base::PostTaskAndReplyWithResult( @@ -161,10 +151,9 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase { class QuotaFileIO::SetLengthOperation : public PendingOperationBase { public: SetLengthOperation(QuotaFileIO* quota_io, - bool is_will_operation, int64_t length, const StatusCallback& callback) - : PendingOperationBase(quota_io, is_will_operation), + : PendingOperationBase(quota_io), length_(length), callback_(callback), weak_factory_(this) {} @@ -177,10 +166,6 @@ class QuotaFileIO::SetLengthOperation : public PendingOperationBase { DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); return; } - if (is_will_operation_) { - DidFinish(base::PLATFORM_FILE_OK); - return; - } if (!base::FileUtilProxy::Truncate( quota_io_->delegate()->GetFileThreadMessageLoopProxy().get(), @@ -247,28 +232,13 @@ bool QuotaFileIO::Write( return false; WriteOperation* op = new WriteOperation( - this, false, offset, buffer, bytes_to_write, callback); + this, offset, buffer, bytes_to_write, callback); return RegisterOperationForQuotaChecks(op); } bool QuotaFileIO::SetLength(int64_t length, const StatusCallback& callback) { DCHECK(pending_operations_.empty()); - SetLengthOperation* op = new SetLengthOperation( - this, false, length, callback); - return RegisterOperationForQuotaChecks(op); -} - -bool QuotaFileIO::WillWrite( - int64_t offset, int32_t bytes_to_write, const WriteCallback& callback) { - WriteOperation* op = new WriteOperation( - this, true, offset, NULL, bytes_to_write, callback); - return RegisterOperationForQuotaChecks(op); -} - -bool QuotaFileIO::WillSetLength(int64_t length, - const StatusCallback& callback) { - DCHECK(pending_operations_.empty()); - SetLengthOperation* op = new SetLengthOperation(this, true, length, callback); + SetLengthOperation* op = new SetLengthOperation(this, length, callback); return RegisterOperationForQuotaChecks(op); } diff --git a/content/renderer/pepper/quota_file_io.h b/content/renderer/pepper/quota_file_io.h index 8dbcd2a115fd01..e6805da39cd002 100644 --- a/content/renderer/pepper/quota_file_io.h +++ b/content/renderer/pepper/quota_file_io.h @@ -62,21 +62,15 @@ class QuotaFileIO { // Otherwise it returns false and |callback| will not be dispatched. // |callback| will not be dispatched either when this instance is // destroyed before the operation completes. - // SetLength/WillSetLength cannot be called while there're any in-flight - // operations. For Write/WillWrite it is guaranteed that |callback| are + // SetLength cannot be called while there're any in-flight + // operations. For Write it is guaranteed that |callback| are // always dispatched in the same order as Write being called. CONTENT_EXPORT bool Write(int64_t offset, const char* buffer, int32_t bytes_to_write, const WriteCallback& callback); - CONTENT_EXPORT bool WillWrite(int64_t offset, - int32_t bytes_to_write, - const WriteCallback& callback); - CONTENT_EXPORT bool SetLength(int64_t length, const StatusCallback& callback); - CONTENT_EXPORT bool WillSetLength(int64_t length, - const StatusCallback& callback); Delegate* delegate() const { return delegate_.get(); } diff --git a/content/renderer/pepper/quota_file_io_unittest.cc b/content/renderer/pepper/quota_file_io_unittest.cc index 2321c9f369e1d5..c31d2ea7f51d29 100644 --- a/content/renderer/pepper/quota_file_io_unittest.cc +++ b/content/renderer/pepper/quota_file_io_unittest.cc @@ -115,7 +115,7 @@ class QuotaFileIOTest : public PpapiUnittest { } protected: - void WriteTestBody(bool will_operation) { + void WriteTestBody() { // Attempt to write zero bytes. EXPECT_FALSE(quota_file_io_->Write( 0, "data", 0, @@ -130,7 +130,7 @@ class QuotaFileIOTest : public PpapiUnittest { // Write 8 bytes at offset 0 (-> length=8). std::string data("12345678"); - Write(0, data, will_operation); + Write(0, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -138,20 +138,13 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(100 - 8, delegate()->available_space()); reset_results(); - if (will_operation) { - // WillWrite doesn't actually write. - EXPECT_EQ(0, GetPlatformFileSize()); - // Adjust the actual file size to 'fake' write to proceed testing. - SetPlatformFileSize(8); - } else { - EXPECT_EQ(8, GetPlatformFileSize()); - ReadPlatformFile(&read_buffer); - EXPECT_EQ(data, read_buffer); - } + EXPECT_EQ(8, GetPlatformFileSize()); + ReadPlatformFile(&read_buffer); + EXPECT_EQ(data, read_buffer); // Write 5 bytes at offset 5 (-> length=10). data = "55555"; - Write(5, data, will_operation); + Write(5, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -159,18 +152,13 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(100 - 10, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(8, GetPlatformFileSize()); - SetPlatformFileSize(10); - } else { - EXPECT_EQ(10, GetPlatformFileSize()); - ReadPlatformFile(&read_buffer); - EXPECT_EQ("1234555555", read_buffer); - } + EXPECT_EQ(10, GetPlatformFileSize()); + ReadPlatformFile(&read_buffer); + EXPECT_EQ("1234555555", read_buffer); // Write 7 bytes at offset 8 (-> length=15). data = "9012345"; - Write(8, data, will_operation); + Write(8, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -178,18 +166,13 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(100 - 15, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(10, GetPlatformFileSize()); - SetPlatformFileSize(15); - } else { - EXPECT_EQ(15, GetPlatformFileSize()); - ReadPlatformFile(&read_buffer); - EXPECT_EQ("123455559012345", read_buffer); - } + EXPECT_EQ(15, GetPlatformFileSize()); + ReadPlatformFile(&read_buffer); + EXPECT_EQ("123455559012345", read_buffer); // Write 2 bytes at offset 2 (-> length=15). data = "33"; - Write(2, data, will_operation); + Write(2, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -197,17 +180,13 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(100 - 15, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(15, GetPlatformFileSize()); - } else { - EXPECT_EQ(15, GetPlatformFileSize()); - ReadPlatformFile(&read_buffer); - EXPECT_EQ("123355559012345", read_buffer); - } + EXPECT_EQ(15, GetPlatformFileSize()); + ReadPlatformFile(&read_buffer); + EXPECT_EQ("123355559012345", read_buffer); // Write 4 bytes at offset 20 (-> length=24). data = "XXXX"; - Write(20, data, will_operation); + Write(20, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -215,20 +194,15 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(100 - 24, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(15, GetPlatformFileSize()); - SetPlatformFileSize(24); - } else { - EXPECT_EQ(24, GetPlatformFileSize()); - ReadPlatformFile(&read_buffer); - EXPECT_EQ(std::string("123355559012345\0\0\0\0\0XXXX", 24), read_buffer); - } + EXPECT_EQ(24, GetPlatformFileSize()); + ReadPlatformFile(&read_buffer); + EXPECT_EQ(std::string("123355559012345\0\0\0\0\0XXXX", 24), read_buffer); delegate()->set_available_space(5); // Quota error case. Write 7 bytes at offset 23 (-> length is unchanged) data = "ABCDEFG"; - Write(23, data, will_operation); + Write(23, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status().front()); @@ -237,7 +211,7 @@ class QuotaFileIOTest : public PpapiUnittest { // Overlapping write. Write 6 bytes at offset 2 (-> length is unchanged) data = "ABCDEF"; - Write(2, data, will_operation); + Write(2, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -247,7 +221,7 @@ class QuotaFileIOTest : public PpapiUnittest { // Overlapping + extending the file size, but within the quota. // Write 6 bytes at offset 23 (-> length=29). - Write(23, data, will_operation); + Write(23, data); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(static_cast(data.size()), bytes_written().front()); @@ -255,18 +229,16 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(0, delegate()->available_space()); reset_results(); - if (!will_operation) { - EXPECT_EQ(29, GetPlatformFileSize()); - ReadPlatformFile(&read_buffer); - EXPECT_EQ(std::string("12ABCDEF9012345\0\0\0\0\0XXXABCDEF", 29), - read_buffer); - } + EXPECT_EQ(29, GetPlatformFileSize()); + ReadPlatformFile(&read_buffer); + EXPECT_EQ(std::string("12ABCDEF9012345\0\0\0\0\0XXXABCDEF", 29), + read_buffer); } - void SetLengthTestBody(bool will_operation) { + void SetLengthTestBody() { delegate()->set_available_space(100); - SetLength(0, will_operation); + SetLength(0); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_OK, status().front()); @@ -274,66 +246,46 @@ class QuotaFileIOTest : public PpapiUnittest { EXPECT_EQ(100, delegate()->available_space()); reset_results(); - SetLength(8, will_operation); + SetLength(8); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_OK, status().front()); EXPECT_EQ(100 - 8, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(0, GetPlatformFileSize()); - SetPlatformFileSize(8); - } else { - EXPECT_EQ(8, GetPlatformFileSize()); - } + EXPECT_EQ(8, GetPlatformFileSize()); - SetLength(16, will_operation); + SetLength(16); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_OK, status().front()); EXPECT_EQ(100 - 16, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(8, GetPlatformFileSize()); - SetPlatformFileSize(16); - } else { - EXPECT_EQ(16, GetPlatformFileSize()); - } + EXPECT_EQ(16, GetPlatformFileSize()); - SetLength(4, will_operation); + SetLength(4); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_OK, status().front()); EXPECT_EQ(100 - 4, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(16, GetPlatformFileSize()); - SetPlatformFileSize(4); - } else { - EXPECT_EQ(4, GetPlatformFileSize()); - } + EXPECT_EQ(4, GetPlatformFileSize()); - SetLength(0, will_operation); + SetLength(0); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_OK, status().front()); EXPECT_EQ(100, delegate()->available_space()); reset_results(); - if (will_operation) { - EXPECT_EQ(4, GetPlatformFileSize()); - SetPlatformFileSize(0); - } else { - EXPECT_EQ(0, GetPlatformFileSize()); - } + EXPECT_EQ(0, GetPlatformFileSize()); delegate()->set_available_space(5); // Quota error case. - SetLength(7, will_operation); + SetLength(7); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(1U, num_results()); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status().front()); @@ -345,30 +297,17 @@ class QuotaFileIOTest : public PpapiUnittest { return delegate_; } - void Write(int64_t offset, const std::string& data, bool will_operation) { - if (will_operation) { - ASSERT_TRUE(quota_file_io_->WillWrite( - offset, data.size(), - base::Bind(&QuotaFileIOTest::DidWrite, weak_factory_.GetWeakPtr()))); - } else { - ASSERT_TRUE(quota_file_io_->Write( - offset, data.c_str(), data.size(), - base::Bind(&QuotaFileIOTest::DidWrite, weak_factory_.GetWeakPtr()))); - } + void Write(int64_t offset, const std::string& data) { + ASSERT_TRUE(quota_file_io_->Write( + offset, data.c_str(), data.size(), + base::Bind(&QuotaFileIOTest::DidWrite, weak_factory_.GetWeakPtr()))); } - void SetLength(int64_t length, bool will_operation) { - if (will_operation) { - ASSERT_TRUE(quota_file_io_->WillSetLength( - length, - base::Bind(&QuotaFileIOTest::DidSetLength, - weak_factory_.GetWeakPtr()))); - } else { - ASSERT_TRUE(quota_file_io_->SetLength( - length, - base::Bind(&QuotaFileIOTest::DidSetLength, - weak_factory_.GetWeakPtr()))); - } + void SetLength(int64_t length) { + ASSERT_TRUE(quota_file_io_->SetLength( + length, + base::Bind(&QuotaFileIOTest::DidSetLength, + weak_factory_.GetWeakPtr()))); } void DidWrite(PlatformFileError status, int bytes_written) { @@ -429,19 +368,11 @@ class QuotaFileIOTest : public PpapiUnittest { }; TEST_F(QuotaFileIOTest, Write) { - WriteTestBody(false); -} - -TEST_F(QuotaFileIOTest, WillWrite) { - WriteTestBody(true); + WriteTestBody(); } TEST_F(QuotaFileIOTest, SetLength) { - SetLengthTestBody(false); -} - -TEST_F(QuotaFileIOTest, WillSetLength) { - SetLengthTestBody(true); + SetLengthTestBody(); } TEST_F(QuotaFileIOTest, ParallelWrites) { @@ -453,9 +384,9 @@ TEST_F(QuotaFileIOTest, ParallelWrites) { std::string("55555"), std::string("9012345"), }; - Write(0, data1[0], false); - Write(5, data1[1], false); - Write(8, data1[2], false); + Write(0, data1[0]); + Write(5, data1[1]); + Write(8, data1[2]); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(ARRAYSIZE_UNSAFE(data1), num_results()); @@ -475,8 +406,8 @@ TEST_F(QuotaFileIOTest, ParallelWrites) { std::string("33"), std::string("XXXX"), }; - Write(2, data2[0], false); - Write(20, data2[1], false); + Write(2, data2[0]); + Write(20, data2[1]); base::MessageLoop::current()->RunUntilIdle(); ASSERT_EQ(ARRAYSIZE_UNSAFE(data2), num_results()); diff --git a/ppapi/api/trusted/ppb_file_io_trusted.idl b/ppapi/api/trusted/ppb_file_io_trusted.idl index 7ba20deb4bfc31..3e12d632c331f2 100644 --- a/ppapi/api/trusted/ppb_file_io_trusted.idl +++ b/ppapi/api/trusted/ppb_file_io_trusted.idl @@ -23,31 +23,4 @@ interface PPB_FileIOTrusted { * TODO(hamaji): Remove this and use RequestOSFileHandle instead. */ int32_t GetOSFileDescriptor([in] PP_Resource file_io); - - /** - * Notifies the browser that underlying file will be modified. This gives - * the browser the opportunity to apply quota restrictions and possibly - * return an error to indicate that the write is not allowed. - */ - int32_t WillWrite([in] PP_Resource file_io, - [in] int64_t offset, - [in] int32_t bytes_to_write, - [in] PP_CompletionCallback callback); - - /** - * Notifies the browser that underlying file will be modified. This gives - * the browser the opportunity to apply quota restrictions and possibly - * return an error to indicate that the write is not allowed. - * - * TODO(darin): Maybe unify the above into a single WillChangeFileSize - * method? The above methods have the advantage of mapping to PPB_FileIO - * Write and SetLength calls. WillChangeFileSize would require the caller to - * compute the file size resulting from a Write call, which may be - * undesirable. - */ - int32_t WillSetLength([in] PP_Resource file_io, - [in] int64_t length, - [in] PP_CompletionCallback callback); - }; - diff --git a/ppapi/c/trusted/ppb_file_io_trusted.h b/ppapi/c/trusted/ppb_file_io_trusted.h index 8e05589eeb621c..5142bb141b09f7 100644 --- a/ppapi/c/trusted/ppb_file_io_trusted.h +++ b/ppapi/c/trusted/ppb_file_io_trusted.h @@ -3,12 +3,11 @@ * found in the LICENSE file. */ -/* From trusted/ppb_file_io_trusted.idl modified Wed Mar 27 14:50:12 2013. */ +/* From trusted/ppb_file_io_trusted.idl modified Wed Sep 25 09:30:40 2013. */ #ifndef PPAPI_C_TRUSTED_PPB_FILE_IO_TRUSTED_H_ #define PPAPI_C_TRUSTED_PPB_FILE_IO_TRUSTED_H_ -#include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -39,29 +38,6 @@ struct PPB_FileIOTrusted_0_4 { * TODO(hamaji): Remove this and use RequestOSFileHandle instead. */ int32_t (*GetOSFileDescriptor)(PP_Resource file_io); - /** - * Notifies the browser that underlying file will be modified. This gives - * the browser the opportunity to apply quota restrictions and possibly - * return an error to indicate that the write is not allowed. - */ - int32_t (*WillWrite)(PP_Resource file_io, - int64_t offset, - int32_t bytes_to_write, - struct PP_CompletionCallback callback); - /** - * Notifies the browser that underlying file will be modified. This gives - * the browser the opportunity to apply quota restrictions and possibly - * return an error to indicate that the write is not allowed. - * - * TODO(darin): Maybe unify the above into a single WillChangeFileSize - * method? The above methods have the advantage of mapping to PPB_FileIO - * Write and SetLength calls. WillChangeFileSize would require the caller to - * compute the file size resulting from a Write call, which may be - * undesirable. - */ - int32_t (*WillSetLength)(PP_Resource file_io, - int64_t length, - struct PP_CompletionCallback callback); }; typedef struct PPB_FileIOTrusted_0_4 PPB_FileIOTrusted; diff --git a/ppapi/cpp/trusted/file_io_trusted.cc b/ppapi/cpp/trusted/file_io_trusted.cc index a3123cac18894d..03a5c96c2504cb 100644 --- a/ppapi/cpp/trusted/file_io_trusted.cc +++ b/ppapi/cpp/trusted/file_io_trusted.cc @@ -31,24 +31,4 @@ int32_t FileIO_Trusted::GetOSFileDescriptor(const FileIO& file_io) { file_io.pp_resource()); } -int32_t FileIO_Trusted::WillWrite(const FileIO& file_io, - int64_t offset, - int32_t bytes_to_write, - const CompletionCallback& callback) { - if (!has_interface()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - return get_interface()->WillWrite( - file_io.pp_resource(), offset, bytes_to_write, - callback.pp_completion_callback()); -} - -int32_t FileIO_Trusted::WillSetLength(const FileIO& file_io, - int64_t length, - const CompletionCallback& callback) { - if (!has_interface()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - return get_interface()->WillSetLength( - file_io.pp_resource(), length, callback.pp_completion_callback()); -} - } // namespace pp diff --git a/ppapi/cpp/trusted/file_io_trusted.h b/ppapi/cpp/trusted/file_io_trusted.h index 3ba2140832b685..c6a04f78d3e66a 100644 --- a/ppapi/cpp/trusted/file_io_trusted.h +++ b/ppapi/cpp/trusted/file_io_trusted.h @@ -20,15 +20,6 @@ class FileIO_Trusted { FileIO_Trusted(); int32_t GetOSFileDescriptor(const FileIO& file_io); - - int32_t WillWrite(const FileIO& file_io, - int64_t offset, - int32_t bytes_to_write, - const CompletionCallback& callback); - - int32_t WillSetLength(const FileIO& file_io, - int64_t length, - const CompletionCallback& callback); }; } // namespace pp diff --git a/ppapi/proxy/file_io_resource.cc b/ppapi/proxy/file_io_resource.cc index fc53fb052432c7..a2f55f121d3328 100644 --- a/ppapi/proxy/file_io_resource.cc +++ b/ppapi/proxy/file_io_resource.cc @@ -291,27 +291,6 @@ int32_t FileIOResource::RequestOSFileHandle( return PP_OK_COMPLETIONPENDING; } -int32_t FileIOResource::WillWrite(int64_t offset, - int32_t bytes_to_write, - scoped_refptr callback) { - Call(RENDERER, - PpapiHostMsg_FileIO_WillWrite(offset, bytes_to_write), - base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this, callback)); - - state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileIOResource::WillSetLength(int64_t length, - scoped_refptr callback) { - Call(RENDERER, - PpapiHostMsg_FileIO_WillSetLength(length), - base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this, callback)); - - state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); - return PP_OK_COMPLETIONPENDING; -} - int32_t FileIOResource::ReadValidated(int64_t offset, int32_t bytes_to_read, const PP_ArrayOutput& array_output, diff --git a/ppapi/proxy/file_io_resource.h b/ppapi/proxy/file_io_resource.h index 26c4abb948855e..b9ddb8ebb27846 100644 --- a/ppapi/proxy/file_io_resource.h +++ b/ppapi/proxy/file_io_resource.h @@ -61,12 +61,6 @@ class PPAPI_PROXY_EXPORT FileIOResource virtual int32_t RequestOSFileHandle( PP_FileHandle* handle, scoped_refptr callback) OVERRIDE; - virtual int32_t WillWrite(int64_t offset, - int32_t bytes_to_write, - scoped_refptr callback) OVERRIDE; - virtual int32_t WillSetLength( - int64_t length, - scoped_refptr callback) OVERRIDE; private: // Class to perform file query operations across multiple threads. diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 2a2533fbfbfc83..c308873f1c81cf 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1220,11 +1220,6 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Write, IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileIO_SetLength, int64_t /* length */) IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_Flush) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_WillWrite, - int64_t /* offset */, - int32_t /* bytes_to_write */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileIO_WillSetLength, - int64_t /* length */) IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_GetOSFileDescriptor) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileIO_GetOSFileDescriptorReply, int32_t /* file descriptor */) diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index 443f7866e57be0..6711663301d977 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -183,7 +183,6 @@ void TestFileIO::RunTests(const std::string& filter) { RUN_CALLBACK_TEST(TestFileIO, ParallelReads, filter); RUN_CALLBACK_TEST(TestFileIO, ParallelWrites, filter); RUN_CALLBACK_TEST(TestFileIO, NotAllowMixedReadWrite, filter); - RUN_CALLBACK_TEST(TestFileIO, WillWriteWillSetLength, filter); RUN_CALLBACK_TEST(TestFileIO, RequestOSFileHandle, filter); RUN_CALLBACK_TEST(TestFileIO, RequestOSFileHandleWithOpenExclusive, filter); RUN_CALLBACK_TEST(TestFileIO, Mmap, filter); @@ -991,76 +990,6 @@ std::string TestFileIO::TestNotAllowMixedReadWrite() { PASS(); } -std::string TestFileIO::TestWillWriteWillSetLength() { - TestCompletionCallback callback(instance_->pp_instance(), callback_type()); - - pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); - pp::FileRef file_ref(file_system, "/file_will_write"); - callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); - CHECK_CALLBACK_BEHAVIOR(callback); - ASSERT_EQ(PP_OK, callback.result()); - - pp::FileIO file_io(instance_); - callback.WaitForResult(file_io.Open(file_ref, - PP_FILEOPENFLAG_CREATE | - PP_FILEOPENFLAG_TRUNCATE | - PP_FILEOPENFLAG_READ | - PP_FILEOPENFLAG_WRITE, - callback.GetCallback())); - CHECK_CALLBACK_BEHAVIOR(callback); - ASSERT_EQ(PP_OK, callback.result()); - - const PPB_FileIOTrusted* trusted = static_cast( - pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); - ASSERT_TRUE(trusted); - - // Get file descriptor. This is only supported in-process for now, so don't - // test out of process. - const PPB_Testing_Dev* testing_interface = GetTestingInterface(); - if (testing_interface && !testing_interface->IsOutOfProcess()) { - int32_t fd = trusted->GetOSFileDescriptor(file_io.pp_resource()); - ASSERT_TRUE(fd >= 0); - } - - // Calling WillWrite. - callback.WaitForResult(trusted->WillWrite( - file_io.pp_resource(), 0, 9, - callback.GetCallback().pp_completion_callback())); - CHECK_CALLBACK_BEHAVIOR(callback); - ASSERT_EQ(9, callback.result()); - - // Writing the actual data. - int32_t rv = WriteEntireBuffer(instance_->pp_instance(), &file_io, 0, - "test_test", callback_type()); - ASSERT_EQ(PP_OK, rv); - - std::string read_buffer; - rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer, - callback_type()); - ASSERT_EQ(PP_OK, rv); - ASSERT_EQ(std::string("test_test"), read_buffer); - - // Calling WillSetLength. - callback.WaitForResult(trusted->WillSetLength( - file_io.pp_resource(), 4, - callback.GetCallback().pp_completion_callback())); - CHECK_CALLBACK_BEHAVIOR(callback); - ASSERT_EQ(PP_OK, rv); - - // Calling actual SetLength. - callback.WaitForResult(file_io.SetLength(4, callback.GetCallback())); - CHECK_CALLBACK_BEHAVIOR(callback); - ASSERT_EQ(PP_OK, rv); - - read_buffer.clear(); - rv = ReadEntireFile(instance_->pp_instance(), &file_io, 0, &read_buffer, - callback_type()); - ASSERT_EQ(PP_OK, rv); - ASSERT_EQ(std::string("test"), read_buffer); - - PASS(); -} - std::string TestFileIO::TestRequestOSFileHandle() { TestCompletionCallback callback(instance_->pp_instance(), callback_type()); diff --git a/ppapi/tests/test_file_io.h b/ppapi/tests/test_file_io.h index 8221f4da80ec30..3cc0095c915952 100644 --- a/ppapi/tests/test_file_io.h +++ b/ppapi/tests/test_file_io.h @@ -46,7 +46,6 @@ class TestFileIO : public TestCase { std::string TestParallelReads(); std::string TestParallelWrites(); std::string TestNotAllowMixedReadWrite(); - std::string TestWillWriteWillSetLength(); std::string TestRequestOSFileHandle(); std::string TestRequestOSFileHandleWithOpenExclusive(); std::string TestMmap(); diff --git a/ppapi/thunk/ppb_file_io_api.h b/ppapi/thunk/ppb_file_io_api.h index ec7f16d1140ed3..9c29f1f361cdaf 100644 --- a/ppapi/thunk/ppb_file_io_api.h +++ b/ppapi/thunk/ppb_file_io_api.h @@ -47,11 +47,6 @@ class PPAPI_THUNK_EXPORT PPB_FileIO_API { // Trusted API. virtual int32_t GetOSFileDescriptor() = 0; - virtual int32_t WillWrite(int64_t offset, - int32_t bytes_to_write, - scoped_refptr callback) = 0; - virtual int32_t WillSetLength(int64_t length, - scoped_refptr callback) = 0; // Private API. virtual int32_t RequestOSFileHandle( diff --git a/ppapi/thunk/ppb_file_io_trusted_thunk.cc b/ppapi/thunk/ppb_file_io_trusted_thunk.cc index 3336026e8e487a..8d31e28d5e5052 100644 --- a/ppapi/thunk/ppb_file_io_trusted_thunk.cc +++ b/ppapi/thunk/ppb_file_io_trusted_thunk.cc @@ -25,31 +25,8 @@ int32_t GetOSFileDescriptor(PP_Resource file_io) { return enter.object()->GetOSFileDescriptor(); } -int32_t WillWrite(PP_Resource file_io, - int64_t offset, - int32_t bytes_to_write, - PP_CompletionCallback callback) { - EnterFileIO enter(file_io, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write, - enter.callback())); -} - -int32_t WillSetLength(PP_Resource file_io, - int64_t length, - PP_CompletionCallback callback) { - EnterFileIO enter(file_io, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult(enter.object()->WillSetLength(length, - enter.callback())); -} - const PPB_FileIOTrusted g_ppb_file_io_trusted_thunk = { - &GetOSFileDescriptor, - &WillWrite, - &WillSetLength + &GetOSFileDescriptor }; } // namespace