diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 00:00:04 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 00:00:04 +0000 |
commit | ca22e119daef5bc95143d2bb43f52ebaad7e4acd (patch) | |
tree | d637425808b26423f9be04926d0b2a501375e774 | |
parent | 99627bcf2331de091b2c71b5a84f602a7da95275 (diff) | |
download | chromium_src-ca22e119daef5bc95143d2bb43f52ebaad7e4acd.zip chromium_src-ca22e119daef5bc95143d2bb43f52ebaad7e4acd.tar.gz chromium_src-ca22e119daef5bc95143d2bb43f52ebaad7e4acd.tar.bz2 |
Remove trusted interface wrappers from the FileIO C++ wrapper. The wrapper
should not expose functions that aren't accessible to normal plugins. The
proxy can just use the trusted interface directly without having a public C++
wrapper.
TEST=it compiles
BUG=53889
Review URL: http://codereview.chromium.org/5532001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68109 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ppapi/cpp/dev/file_io_dev.cc | 28 | ||||
-rw-r--r-- | ppapi/cpp/dev/file_io_dev.h | 10 | ||||
-rw-r--r-- | ppapi/tests/test_url_loader.cc | 14 | ||||
-rw-r--r-- | ppapi/tests/test_url_loader.h | 6 |
4 files changed, 19 insertions, 39 deletions
diff --git a/ppapi/cpp/dev/file_io_dev.cc b/ppapi/cpp/dev/file_io_dev.cc index e1197a1..bccfa99 100644 --- a/ppapi/cpp/dev/file_io_dev.cc +++ b/ppapi/cpp/dev/file_io_dev.cc @@ -14,10 +14,7 @@ namespace { -DeviceFuncs<PPB_FileIO_Dev> file_io_f( - PPB_FILEIO_DEV_INTERFACE); -DeviceFuncs<PPB_FileIOTrusted_Dev> file_io_trusted_f( - PPB_FILEIOTRUSTED_DEV_INTERFACE); +DeviceFuncs<PPB_FileIO_Dev> file_io_f(PPB_FILEIO_DEV_INTERFACE); } // namespace @@ -104,27 +101,4 @@ void FileIO_Dev::Close() { file_io_f->Close(pp_resource()); } -int32_t FileIO_Dev::GetOSFileDescriptor() { - if (!file_io_trusted_f) - return PP_ERROR_NOINTERFACE; - return file_io_trusted_f->GetOSFileDescriptor(pp_resource()); -} - -int32_t FileIO_Dev::WillWrite(int64_t offset, - int32_t bytes_to_write, - const CompletionCallback& cc) { - if (!file_io_trusted_f) - return PP_ERROR_NOINTERFACE; - return file_io_trusted_f->WillWrite(pp_resource(), offset, bytes_to_write, - cc.pp_completion_callback()); -} - -int32_t FileIO_Dev::WillSetLength(int64_t length, - const CompletionCallback& cc) { - if (!file_io_trusted_f) - return PP_ERROR_NOINTERFACE; - return file_io_trusted_f->WillSetLength(pp_resource(), length, - cc.pp_completion_callback()); -} - } // namespace pp diff --git a/ppapi/cpp/dev/file_io_dev.h b/ppapi/cpp/dev/file_io_dev.h index 957f9eb..1ec4d06 100644 --- a/ppapi/cpp/dev/file_io_dev.h +++ b/ppapi/cpp/dev/file_io_dev.h @@ -43,16 +43,6 @@ class FileIO_Dev : public Resource { const CompletionCallback& cc); int32_t Flush(const CompletionCallback& cc); void Close(); - - // PPB_FileIOTrusted methods: - // NOTE: These are only available to trusted plugins and will return - // PP_ERROR_NOINTERFACE if called from an untrusted plugin. - int32_t GetOSFileDescriptor(); - int32_t WillWrite(int64_t offset, - int32_t bytes_to_write, - const CompletionCallback& cc); - int32_t WillSetLength(int64_t length, - const CompletionCallback& cc); }; } // namespace pp diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc index f21a12a3..7d4b3b2 100644 --- a/ppapi/tests/test_url_loader.cc +++ b/ppapi/tests/test_url_loader.cc @@ -8,6 +8,7 @@ #include <string> #include "ppapi/c/dev/ppb_file_io_dev.h" +#include "ppapi/c/dev/ppb_file_io_trusted_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_url_loader.h" @@ -24,7 +25,17 @@ REGISTER_TEST_CASE(URLLoader); +TestURLLoader::TestURLLoader(TestingInstance* instance) + : TestCase(instance), + file_io_trusted_interface_(NULL) { +} + bool TestURLLoader::Init() { + file_io_trusted_interface_ = static_cast<const PPB_FileIOTrusted_Dev*>( + pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_DEV_INTERFACE)); + if (!file_io_trusted_interface_) { + instance_->AppendError("FileIOTrusted interface not available"); + } return InitTestingInterface() && EnsureRunningOverHTTP(); } @@ -226,7 +237,8 @@ std::string TestURLLoader::TestStreamToFile() { if (data != expected_body) return "ReadEntireFile returned unexpected content"; - int32_t file_descriptor = reader.GetOSFileDescriptor(); + int32_t file_descriptor = file_io_trusted_interface_->GetOSFileDescriptor( + reader.pp_resource()); if (file_descriptor < 0) return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; diff --git a/ppapi/tests/test_url_loader.h b/ppapi/tests/test_url_loader.h index 944868f..447b7e2 100644 --- a/ppapi/tests/test_url_loader.h +++ b/ppapi/tests/test_url_loader.h @@ -9,6 +9,8 @@ #include "ppapi/tests/test_case.h" +struct PPB_FileIOTrusted_Dev; + namespace pp { class FileIO_Dev; class URLLoader; @@ -17,7 +19,7 @@ class URLRequestInfo; class TestURLLoader : public TestCase { public: - explicit TestURLLoader(TestingInstance* instance) : TestCase(instance) {} + explicit TestURLLoader(TestingInstance* instance); // TestCase implementation. virtual bool Init(); @@ -40,6 +42,8 @@ class TestURLLoader : public TestCase { std::string TestStreamToFile(); std::string TestSameOriginRestriction(); std::string TestAuditURLRedirect(); + + const PPB_FileIOTrusted_Dev* file_io_trusted_interface_; }; #endif // PAPPI_TESTS_TEST_URL_LOADER_H_ |