summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 21:19:03 +0000
committertzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 21:19:03 +0000
commit540d6af4f7ac9e5dbad65fc8fec8673f7144c018 (patch)
tree0e9599c36a8f05ccca9bd7b01fcb59b036a536c4
parent8ca54e192eaadc07db4434e8ed960691dcab7395 (diff)
downloadchromium_src-540d6af4f7ac9e5dbad65fc8fec8673f7144c018.zip
chromium_src-540d6af4f7ac9e5dbad65fc8fec8673f7144c018.tar.gz
chromium_src-540d6af4f7ac9e5dbad65fc8fec8673f7144c018.tar.bz2
[Pepper] Wire up append mode writing support of FileIO
BUG=334171 Review URL: https://codereview.chromium.org/130053003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247504 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/pepper/pepper_file_io_host.cc6
-rw-r--r--content/browser/renderer_host/pepper/pepper_file_io_host.h6
-rw-r--r--content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc11
-rw-r--r--content/browser/renderer_host/pepper/pepper_file_system_browser_host.h4
-rw-r--r--content/browser/renderer_host/pepper/quota_reservation.cc12
-rw-r--r--ppapi/proxy/file_io_resource.cc4
-rw-r--r--ppapi/proxy/file_system_resource.cc17
-rw-r--r--ppapi/proxy/file_system_resource_unittest.cc18
-rw-r--r--ppapi/proxy/nacl_message_scanner.cc35
-rw-r--r--ppapi/proxy/nacl_message_scanner_unittest.cc32
-rw-r--r--ppapi/proxy/ppapi_messages.h17
-rw-r--r--ppapi/shared_impl/file_growth.cc18
-rw-r--r--ppapi/shared_impl/file_growth.h5
13 files changed, 104 insertions, 81 deletions
diff --git a/content/browser/renderer_host/pepper/pepper_file_io_host.cc b/content/browser/renderer_host/pepper/pepper_file_io_host.cc
index e66219b..da802e5 100644
--- a/content/browser/renderer_host/pepper/pepper_file_io_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_file_io_host.cc
@@ -334,11 +334,9 @@ int32_t PepperFileIOHost::OnHostMsgFlush(
int32_t PepperFileIOHost::OnHostMsgClose(
ppapi::host::HostMessageContext* context,
- int64_t max_written_offset) {
+ const ppapi::FileGrowth& file_growth) {
if (check_quota_) {
- file_system_host_->CloseQuotaFile(
- this,
- ppapi::FileGrowth(max_written_offset, 0));
+ file_system_host_->CloseQuotaFile(this, file_growth);
check_quota_ = false;
}
diff --git a/content/browser/renderer_host/pepper/pepper_file_io_host.h b/content/browser/renderer_host/pepper/pepper_file_io_host.h
index 76991a9..45953c9 100644
--- a/content/browser/renderer_host/pepper/pepper_file_io_host.h
+++ b/content/browser/renderer_host/pepper/pepper_file_io_host.h
@@ -23,6 +23,10 @@
#include "url/gurl.h"
#include "webkit/browser/fileapi/file_system_context.h"
+namespace ppapi {
+struct FileGrowth;
+}
+
namespace content {
class PepperFileSystemBrowserHost;
@@ -58,7 +62,7 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
int32_t OnHostMsgSetLength(ppapi::host::HostMessageContext* context,
int64_t length);
int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context,
- int64_t max_written_offset);
+ const ppapi::FileGrowth& file_growth);
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgRequestOSFileHandle(
ppapi::host::HostMessageContext* context);
diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
index 0430b6b..0401ae2 100644
--- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
@@ -365,7 +365,7 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem(
int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota(
ppapi::host::HostMessageContext* context,
int64_t amount,
- const ppapi::FileSizeMap& file_sizes) {
+ const ppapi::FileGrowthMap& file_growths) {
DCHECK(ChecksQuota());
DCHECK(amount > 0);
@@ -373,11 +373,6 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota(
return PP_ERROR_INPROGRESS;
reserving_quota_ = true;
- ppapi::FileGrowthMap file_growths;
- for (ppapi::FileSizeMap::const_iterator it = file_sizes.begin();
- it != file_sizes.end(); ++it)
- file_growths[it->first] = ppapi::FileGrowth(it->second, 0);
-
int64_t reservation_amount = std::max<int64_t>(kMinimumQuotaReservationSize,
amount);
file_system_context_->default_file_task_runner()->PostTask(
@@ -463,7 +458,7 @@ void PepperFileSystemBrowserHost::GotQuotaReservation(
void PepperFileSystemBrowserHost::GotReservedQuota(
ppapi::host::ReplyMessageContext reply_context,
int64_t amount,
- const ppapi::FileSizeMap& max_written_offsets) {
+ const ppapi::FileSizeMap& file_sizes) {
DCHECK(reserving_quota_);
reserving_quota_ = false;
reserved_quota_ = amount;
@@ -471,7 +466,7 @@ void PepperFileSystemBrowserHost::GotReservedQuota(
reply_context.params.set_result(PP_OK);
host()->SendReply(
reply_context,
- PpapiPluginMsg_FileSystem_ReserveQuotaReply(amount, max_written_offsets));
+ PpapiPluginMsg_FileSystem_ReserveQuotaReply(amount, file_sizes));
}
std::string PepperFileSystemBrowserHost::GetPluginMimeType() const {
diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
index 30b9df9..d31a16d 100644
--- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
+++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
@@ -115,7 +115,7 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
int32_t OnHostMsgReserveQuota(
ppapi::host::HostMessageContext* context,
int64_t amount,
- const ppapi::FileSizeMap& max_written_offsets);
+ const ppapi::FileGrowthMap& file_growths);
void SendReplyForFileSystem(
ppapi::host::ReplyMessageContext reply_context,
@@ -137,7 +137,7 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
void GotReservedQuota(
ppapi::host::ReplyMessageContext reply_context,
int64_t amount,
- const ppapi::FileSizeMap& max_written_offsets);
+ const ppapi::FileSizeMap& file_sizes);
void DidOpenQuotaFile(
PP_Resource file_io_resource,
const OpenQuotaFileCallback& callback,
diff --git a/content/browser/renderer_host/pepper/quota_reservation.cc b/content/browser/renderer_host/pepper/quota_reservation.cc
index 2dd5caa..ed572d6 100644
--- a/content/browser/renderer_host/pepper/quota_reservation.cc
+++ b/content/browser/renderer_host/pepper/quota_reservation.cc
@@ -121,11 +121,9 @@ void QuotaReservation::OnClientCrash() {
void QuotaReservation::GotReservedQuota(
const ReserveQuotaCallback& callback,
base::File::Error error) {
- ppapi::FileSizeMap max_written_offsets;
- for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) {
- max_written_offsets.insert(
- std::make_pair(it->first, it->second->GetMaxWrittenOffset()));
- }
+ ppapi::FileSizeMap file_sizes;
+ for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it)
+ file_sizes[it->first] = it->second->GetMaxWrittenOffset();
if (file_system_context_) {
BrowserThread::PostTask(
@@ -133,10 +131,10 @@ void QuotaReservation::GotReservedQuota(
FROM_HERE,
base::Bind(callback,
quota_reservation_->remaining_quota(),
- max_written_offsets));
+ file_sizes));
} else {
// Unit testing code path.
- callback.Run(quota_reservation_->remaining_quota(), max_written_offsets);
+ callback.Run(quota_reservation_->remaining_quota(), file_sizes);
}
}
diff --git a/ppapi/proxy/file_io_resource.cc b/ppapi/proxy/file_io_resource.cc
index a35c9ec..7157574 100644
--- a/ppapi/proxy/file_io_resource.cc
+++ b/ppapi/proxy/file_io_resource.cc
@@ -404,10 +404,8 @@ void FileIOResource::Close() {
if (file_handle_)
file_handle_ = NULL;
- // TODO(tzik): Post |max_written_offset_| and |append_mode_write_amount_|
- // separately by using FileGrowth after the IPC signature changed.
Post(BROWSER, PpapiHostMsg_FileIO_Close(
- max_written_offset_ + append_mode_write_amount_));
+ FileGrowth(max_written_offset_, append_mode_write_amount_)));
}
int32_t FileIOResource::RequestOSFileHandle(
diff --git a/ppapi/proxy/file_system_resource.cc b/ppapi/proxy/file_system_resource.cc
index 5d6161e..0be0ea5 100644
--- a/ppapi/proxy/file_system_resource.cc
+++ b/ppapi/proxy/file_system_resource.cc
@@ -175,8 +175,7 @@ void FileSystemResource::ReserveQuota(int64_t amount) {
DCHECK(!reserving_quota_);
reserving_quota_ = true;
- // TODO(tzik): Use FileGrowthMap here after the IPC signature changed.
- FileSizeMap file_sizes;
+ FileGrowthMap file_growths;
for (std::set<PP_Resource>::iterator it = files_.begin();
it != files_.end(); ++it) {
EnterResourceNoLock<PPB_FileIO_API> enter(*it, true);
@@ -185,12 +184,12 @@ void FileSystemResource::ReserveQuota(int64_t amount) {
continue;
}
PPB_FileIO_API* file_io_api = enter.object();
- file_sizes[*it] =
- file_io_api->GetMaxWrittenOffset() +
- file_io_api->GetAppendModeWriteAmount();
+ file_growths[*it] = FileGrowth(
+ file_io_api->GetMaxWrittenOffset(),
+ file_io_api->GetAppendModeWriteAmount());
}
Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(BROWSER,
- PpapiHostMsg_FileSystem_ReserveQuota(amount, file_sizes),
+ PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths),
base::Bind(&FileSystemResource::ReserveQuotaComplete,
this));
}
@@ -198,13 +197,13 @@ void FileSystemResource::ReserveQuota(int64_t amount) {
void FileSystemResource::ReserveQuotaComplete(
const ResourceMessageReplyParams& params,
int64_t amount,
- const FileSizeMap& max_written_offsets) {
+ const FileSizeMap& file_sizes) {
DCHECK(reserving_quota_);
reserving_quota_ = false;
reserved_quota_ = amount;
- for (FileSizeMap::const_iterator it = max_written_offsets.begin();
- it != max_written_offsets.end(); ++it) {
+ for (FileSizeMap::const_iterator it = file_sizes.begin();
+ it != file_sizes.end(); ++it) {
EnterResourceNoLock<PPB_FileIO_API> enter(it->first, true);
// It is possible that the host has sent an offset for a file that has been
diff --git a/ppapi/proxy/file_system_resource_unittest.cc b/ppapi/proxy/file_system_resource_unittest.cc
index e60a808..f936954 100644
--- a/ppapi/proxy/file_system_resource_unittest.cc
+++ b/ppapi/proxy/file_system_resource_unittest.cc
@@ -238,13 +238,13 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
sink().ClearMessages();
int64_t amount = 0;
- FileOffsetMap max_written_offsets;
+ FileGrowthMap file_growths;
ASSERT_TRUE(UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>(
- msg, &amount, &max_written_offsets));
+ msg, &amount, &file_growths));
ASSERT_EQ(kQuotaRequestAmount1, amount);
- ASSERT_EQ(2U, max_written_offsets.size());
- ASSERT_EQ(0, max_written_offsets[file_io1.get()]);
- ASSERT_EQ(0, max_written_offsets[file_io2.get()]);
+ ASSERT_EQ(2U, file_growths.size());
+ ASSERT_EQ(0, file_growths[file_io1.get()].max_written_offset);
+ ASSERT_EQ(0, file_growths[file_io2.get()].max_written_offset);
// Make another request while the "reserve quota" message is pending.
MockRequestQuotaCallback cb2;
@@ -263,7 +263,7 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
PP_OK,
PpapiPluginMsg_FileSystem_ReserveQuotaReply(
kQuotaRequestAmount1 + kQuotaRequestAmount2,
- max_written_offsets));
+ FileGrowthMapToFileSizeMapForTesting(file_growths)));
}
ASSERT_TRUE(cb1.called());
ASSERT_EQ(kQuotaRequestAmount1, cb1.result());
@@ -294,7 +294,7 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
PP_OK,
PpapiPluginMsg_FileSystem_ReserveQuotaReply(
kQuotaRequestAmount1 - 1,
- max_written_offsets));
+ FileGrowthMapToFileSizeMapForTesting(file_growths)));
}
ASSERT_TRUE(cb1.called());
ASSERT_EQ(0, cb1.result());
@@ -325,7 +325,7 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
PP_OK,
PpapiPluginMsg_FileSystem_ReserveQuotaReply(
kQuotaRequestAmount1,
- max_written_offsets));
+ FileGrowthMapToFileSizeMapForTesting(file_growths)));
}
ASSERT_TRUE(cb1.called());
ASSERT_EQ(kQuotaRequestAmount1, cb1.result());
@@ -343,7 +343,7 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
PP_OK,
PpapiPluginMsg_FileSystem_ReserveQuotaReply(
kQuotaRequestAmount1 + kQuotaRequestAmount2,
- max_written_offsets));
+ FileGrowthMapToFileSizeMapForTesting(file_growths)));
}
ASSERT_TRUE(cb2.called());
diff --git a/ppapi/proxy/nacl_message_scanner.cc b/ppapi/proxy/nacl_message_scanner.cc
index 3c2b45f8..44324c3 100644
--- a/ppapi/proxy/nacl_message_scanner.cc
+++ b/ppapi/proxy/nacl_message_scanner.cc
@@ -381,9 +381,9 @@ void NaClMessageScanner::ScanUntrustedMessage(
return;
// Audit FileIO Close messages to make sure the plugin reports an
// accurate file size.
- int64_t max_written_offset = 0;
+ FileGrowth file_growth;
if (!UnpackMessage<PpapiHostMsg_FileIO_Close>(
- nested_msg, &max_written_offset))
+ nested_msg, &file_growth))
return;
int64_t trusted_max_written_offset = it->second->max_written_offset();
@@ -391,11 +391,12 @@ void NaClMessageScanner::ScanUntrustedMessage(
files_.erase(it);
// If the plugin is under-reporting, rewrite the message with the
// trusted value.
- if (trusted_max_written_offset > max_written_offset) {
+ if (trusted_max_written_offset > file_growth.max_written_offset) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
- PpapiHostMsg_FileIO_Close(trusted_max_written_offset)));
+ PpapiHostMsg_FileIO_Close(
+ FileGrowth(trusted_max_written_offset, 0))));
}
}
case PpapiHostMsg_FileIO_SetLength::ID: {
@@ -429,22 +430,26 @@ void NaClMessageScanner::ScanUntrustedMessage(
// Audit FileSystem ReserveQuota messages to make sure the plugin
// reports accurate file sizes.
int64_t amount = 0;
- FileOffsetMap max_written_offsets;
+ FileGrowthMap file_growths;
if (!UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>(
- nested_msg, &amount, &max_written_offsets))
+ nested_msg, &amount, &file_growths))
return;
bool audit_failed = false;
- for (FileOffsetMap::iterator it = max_written_offsets.begin();
- it != max_written_offsets.end(); ++it) {
+ for (FileGrowthMap::iterator it = file_growths.begin();
+ it != file_growths.end(); ++it) {
FileIOMap::iterator file_it = files_.find(it->first);
if (file_it == files_.end())
continue;
int64_t trusted_max_written_offset =
file_it->second->max_written_offset();
- if (trusted_max_written_offset > it->second) {
+ if (trusted_max_written_offset > it->second.max_written_offset) {
audit_failed = true;
- it->second = trusted_max_written_offset;
+ it->second.max_written_offset = trusted_max_written_offset;
+ }
+ if (it->second.append_mode_write_amount < 0) {
+ audit_failed = true;
+ it->second.append_mode_write_amount = 0;
}
}
if (audit_failed) {
@@ -452,7 +457,7 @@ void NaClMessageScanner::ScanUntrustedMessage(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileSystem_ReserveQuota(
- amount, max_written_offsets)));
+ amount, file_growths)));
}
break;
}
@@ -518,15 +523,15 @@ void NaClMessageScanner::AuditNestedMessage(PP_Resource resource,
case PpapiPluginMsg_FileSystem_ReserveQuotaReply::ID: {
// The amount of reserved quota for a FileSystem was refreshed.
int64_t amount = 0;
- FileOffsetMap max_written_offsets;
+ FileSizeMap file_sizes;
if (ppapi::UnpackMessage<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(
- msg, &amount, &max_written_offsets)) {
+ msg, &amount, &file_sizes)) {
FileSystemMap::iterator it = file_systems_.find(resource);
DCHECK(it != file_systems_.end());
it->second->UpdateReservedQuota(amount);
- FileOffsetMap::const_iterator offset_it = max_written_offsets.begin();
- for (; offset_it != max_written_offsets.end(); ++offset_it) {
+ FileSizeMap::const_iterator offset_it = file_sizes.begin();
+ for (; offset_it != file_sizes.end(); ++offset_it) {
FileIOMap::iterator fio_it = files_.find(offset_it->first);
DCHECK(fio_it != files_.end());
if (fio_it != files_.end())
diff --git a/ppapi/proxy/nacl_message_scanner_unittest.cc b/ppapi/proxy/nacl_message_scanner_unittest.cc
index e0516ff..8e81e24 100644
--- a/ppapi/proxy/nacl_message_scanner_unittest.cc
+++ b/ppapi/proxy/nacl_message_scanner_unittest.cc
@@ -124,18 +124,18 @@ TEST_F(NaClMessageScannerTest, FileOpenClose) {
test.ScanUntrustedMessage(
PpapiHostMsg_ResourceCall(
fio_call_params,
- PpapiHostMsg_FileIO_Close(0)),
+ PpapiHostMsg_FileIO_Close(FileGrowth(0, 0))),
&new_msg_ptr);
EXPECT_TRUE(new_msg_ptr);
ResourceMessageCallParams call_params;
IPC::Message nested_msg;
- int64_t max_written_offset = 0;
+ FileGrowth file_growth;
EXPECT_TRUE(UnpackMessage<PpapiHostMsg_ResourceCall>(
*new_msg_ptr, &call_params, &nested_msg) &&
UnpackMessage<PpapiHostMsg_FileIO_Close>(
- nested_msg, &max_written_offset));
+ nested_msg, &file_growth));
new_msg_ptr.reset();
- EXPECT_EQ(kNewFileSize, max_written_offset);
+ EXPECT_EQ(kNewFileSize, file_growth.max_written_offset);
EXPECT_FALSE(FindFileIO(test, kFileIO));
// Reopen the file.
@@ -147,7 +147,7 @@ TEST_F(NaClMessageScannerTest, FileOpenClose) {
test.ScanUntrustedMessage(
PpapiHostMsg_ResourceCall(
fio_call_params,
- PpapiHostMsg_FileIO_Close(kNewFileSize)),
+ PpapiHostMsg_FileIO_Close(FileGrowth(kNewFileSize, 0))),
&new_msg_ptr);
EXPECT_FALSE(new_msg_ptr);
EXPECT_FALSE(FindFileIO(test, kFileIO));
@@ -185,14 +185,14 @@ TEST_F(NaClMessageScannerTest, QuotaAuditing) {
// Receive reserved quota, and updated file sizes.
const int64_t kNewFileSize = 10;
- FileOffsetMap offset_map;
- offset_map.insert(std::make_pair(kFileIO, kNewFileSize));
+ FileSizeMap file_sizes;
+ file_sizes[kFileIO] = kNewFileSize;
test.ScanMessage(
PpapiPluginMsg_ResourceReply(
fs_reply_params,
PpapiPluginMsg_FileSystem_ReserveQuotaReply(
kQuotaReservationAmount,
- offset_map)),
+ file_sizes)),
&unused_handles,
&new_msg_ptr);
EXPECT_FALSE(new_msg_ptr);
@@ -210,26 +210,26 @@ TEST_F(NaClMessageScannerTest, QuotaAuditing) {
EXPECT_EQ(kNewFileSize + 1, fio->max_written_offset());
// Plugin should not under-report max written offsets when reserving quota.
- offset_map[kFileIO] = 0; // should be kNewFileSize + 1.
+ file_sizes[kFileIO] = 0; // should be kNewFileSize + 1.
test.ScanUntrustedMessage(
PpapiHostMsg_ResourceCall(
fio_call_params,
PpapiHostMsg_FileSystem_ReserveQuota(
kQuotaReservationAmount,
- offset_map)),
+ FileSizeMapToFileGrowthMapForTesting(file_sizes))),
&new_msg_ptr);
EXPECT_TRUE(new_msg_ptr);
ResourceMessageCallParams call_params;
IPC::Message nested_msg;
int64_t amount = 0;
- FileOffsetMap new_offset_map;
+ FileGrowthMap new_file_growths;
EXPECT_TRUE(UnpackMessage<PpapiHostMsg_ResourceCall>(
*new_msg_ptr, &call_params, &nested_msg) &&
UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>(
- nested_msg, &amount, &new_offset_map));
+ nested_msg, &amount, &new_file_growths));
new_msg_ptr.reset();
EXPECT_EQ(kQuotaReservationAmount, amount);
- EXPECT_EQ(kNewFileSize + 1, new_offset_map[kFileIO]);
+ EXPECT_EQ(kNewFileSize + 1, new_file_growths[kFileIO].max_written_offset);
}
TEST_F(NaClMessageScannerTest, SetLength) {
@@ -247,14 +247,14 @@ TEST_F(NaClMessageScannerTest, SetLength) {
// Receive reserved quota, and updated file sizes.
const int64_t kNewFileSize = 10;
- FileOffsetMap offset_map;
- offset_map.insert(std::make_pair(kFileIO, 0));
+ FileSizeMap file_sizes;
+ file_sizes[kFileIO] = 0;
test.ScanMessage(
PpapiPluginMsg_ResourceReply(
fs_reply_params,
PpapiPluginMsg_FileSystem_ReserveQuotaReply(
kQuotaReservationAmount,
- offset_map)),
+ file_sizes)),
&unused_handles,
&new_msg_ptr);
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index ab28cf8..9a2ad06 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -59,6 +59,7 @@
#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/dir_contents.h"
+#include "ppapi/shared_impl/file_growth.h"
#include "ppapi/shared_impl/file_path.h"
#include "ppapi/shared_impl/file_ref_create_info.h"
#include "ppapi/shared_impl/ppapi_nacl_channel_args.h"
@@ -210,6 +211,11 @@ IPC_STRUCT_TRAITS_BEGIN(PP_FileInfo)
IPC_STRUCT_TRAITS_MEMBER(last_modified_time)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(ppapi::FileGrowth)
+ IPC_STRUCT_TRAITS_MEMBER(max_written_offset)
+ IPC_STRUCT_TRAITS_MEMBER(append_mode_write_amount)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(ppapi::DeviceRefData)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(name)
@@ -1246,9 +1252,9 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Open,
int32_t /* open_flags */)
IPC_MESSAGE_CONTROL2(PpapiPluginMsg_FileIO_OpenReply,
PP_Resource /* quota_file_system */,
- int64_t /* max_written_offset */)
+ int64_t /* file_size */)
IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileIO_Close,
- int64_t /* max_written_offset */)
+ ppapi::FileGrowth /* file_growth */)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileIO_Touch,
PP_Time /* last_access_time */,
PP_Time /* last_modified_time */)
@@ -1337,15 +1343,12 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileSystem_CreateFromRenderer,
// linked to the existing resource host given in the ResourceVar.
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileSystem_CreateFromPendingHost,
PP_FileSystemType /* file_system_type */)
-// IPC_MESSAGE macros choke on extra , in the std::map, when expanding. We need
-// to typedef it to avoid that.
-typedef std::map<int32_t, int64_t> FileOffsetMap;
IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileSystem_ReserveQuota,
int64_t /* amount */,
- FileOffsetMap /* max_written_offsets */)
+ ppapi::FileGrowthMap /* file_growths */)
IPC_MESSAGE_CONTROL2(PpapiPluginMsg_FileSystem_ReserveQuotaReply,
int64_t /* amount */,
- FileOffsetMap /* max_written_offsets */)
+ ppapi::FileSizeMap /* file_sizes */)
// Flash DRM ------------------------------------------------------------------
IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDRM_Create)
diff --git a/ppapi/shared_impl/file_growth.cc b/ppapi/shared_impl/file_growth.cc
index 002bd0f..ac97506 100644
--- a/ppapi/shared_impl/file_growth.cc
+++ b/ppapi/shared_impl/file_growth.cc
@@ -21,4 +21,22 @@ FileGrowth::FileGrowth(int64_t max_written_offset,
DCHECK_LE(0, append_mode_write_amount);
}
+FileGrowthMap FileSizeMapToFileGrowthMapForTesting(
+ const FileSizeMap& file_sizes) {
+ FileGrowthMap file_growths;
+ for (FileSizeMap::const_iterator it = file_sizes.begin();
+ it != file_sizes.end(); ++it)
+ file_growths[it->first] = FileGrowth(it->second, 0);
+ return file_growths;
+}
+
+FileSizeMap FileGrowthMapToFileSizeMapForTesting(
+ const FileGrowthMap& file_growths) {
+ FileSizeMap file_sizes;
+ for (FileGrowthMap::const_iterator it = file_growths.begin();
+ it != file_growths.end(); ++it)
+ file_sizes[it->first] = it->second.max_written_offset;
+ return file_sizes;
+}
+
} // namespace ppapi
diff --git a/ppapi/shared_impl/file_growth.h b/ppapi/shared_impl/file_growth.h
index b9e83ec..23f12e0 100644
--- a/ppapi/shared_impl/file_growth.h
+++ b/ppapi/shared_impl/file_growth.h
@@ -23,6 +23,11 @@ struct PPAPI_SHARED_EXPORT FileGrowth {
typedef std::map<int32_t, FileGrowth> FileGrowthMap;
typedef std::map<int32_t, int64_t> FileSizeMap;
+PPAPI_SHARED_EXPORT FileGrowthMap FileSizeMapToFileGrowthMapForTesting(
+ const FileSizeMap& file_sizes);
+PPAPI_SHARED_EXPORT FileSizeMap FileGrowthMapToFileSizeMapForTesting(
+ const FileGrowthMap& file_growths);
+
} // namespace ppapi
#endif // PPAPI_SHARED_IMPL_FILE_GROWTH_H_