summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 17:06:27 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 17:06:27 +0000
commitca1d0ca7ee585eba6bf0bdc45a06809a47b0b6dc (patch)
tree75d463b3651d4770c8d776e67cde82efb6e72ecd /ppapi
parent8e7415e446a2379aecead2903cbc96a34e02fe98 (diff)
downloadchromium_src-ca1d0ca7ee585eba6bf0bdc45a06809a47b0b6dc.zip
chromium_src-ca1d0ca7ee585eba6bf0bdc45a06809a47b0b6dc.tar.gz
chromium_src-ca1d0ca7ee585eba6bf0bdc45a06809a47b0b6dc.tar.bz2
Pepper: Remove Will* from PPB_FileIOTrusted.
Nobody uses these methods today. Additionally, WillWrite/WillSetLength are no good for plugin-side writes. They require an extra IPC round-trip that has to be made for every write call. I don't see any advantage of this over a plugin just calling Write()/SetLength() directly and getting a NOQUOTA error back. I'm removing these methods to clean up code a bit and make the FileIO move from the renderer to the browser smaller. R=bbudge@chromium.org, dmichael@chromium.org, kinuko@chromium.org TBR=jschuh BUG=246396 Review URL: https://codereview.chromium.org/24615002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/trusted/ppb_file_io_trusted.idl27
-rw-r--r--ppapi/c/trusted/ppb_file_io_trusted.h26
-rw-r--r--ppapi/cpp/trusted/file_io_trusted.cc20
-rw-r--r--ppapi/cpp/trusted/file_io_trusted.h9
-rw-r--r--ppapi/proxy/file_io_resource.cc21
-rw-r--r--ppapi/proxy/file_io_resource.h6
-rw-r--r--ppapi/proxy/ppapi_messages.h5
-rw-r--r--ppapi/tests/test_file_io.cc71
-rw-r--r--ppapi/tests/test_file_io.h1
-rw-r--r--ppapi/thunk/ppb_file_io_api.h5
-rw-r--r--ppapi/thunk/ppb_file_io_trusted_thunk.cc25
11 files changed, 2 insertions, 214 deletions
diff --git a/ppapi/api/trusted/ppb_file_io_trusted.idl b/ppapi/api/trusted/ppb_file_io_trusted.idl
index 7ba20de..3e12d63 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 8e05589..5142bb1 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 a3123ca..03a5c96 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<PPB_FileIOTrusted>())
- return callback.MayForce(PP_ERROR_NOINTERFACE);
- return get_interface<PPB_FileIOTrusted>()->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<PPB_FileIOTrusted>())
- return callback.MayForce(PP_ERROR_NOINTERFACE);
- return get_interface<PPB_FileIOTrusted>()->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 3ba2140..c6a04f7 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 fc53fb0..a2f55f1 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<TrackedCallback> callback) {
- Call<PpapiPluginMsg_FileIO_GeneralReply>(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<TrackedCallback> callback) {
- Call<PpapiPluginMsg_FileIO_GeneralReply>(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 26c4abb..b9ddb8e 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<TrackedCallback> callback) OVERRIDE;
- virtual int32_t WillWrite(int64_t offset,
- int32_t bytes_to_write,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t WillSetLength(
- int64_t length,
- scoped_refptr<TrackedCallback> 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 2a2533f..c308873 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 443f786..6711663 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<const PPB_FileIOTrusted*>(
- 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 8221f4d..3cc0095 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 ec7f16d..9c29f1f 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<TrackedCallback> callback) = 0;
- virtual int32_t WillSetLength(int64_t length,
- scoped_refptr<TrackedCallback> 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 3336026..8d31e28 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