summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 21:28:53 +0000
committerbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 21:28:53 +0000
commit90ca3f2eed88de69ace6be025fd2c22b79a25958 (patch)
tree15fc3c8d82b3f06f6e242a7777cc07c6aa3235c8 /native_client_sdk
parentb7bc5102e6982a8f4f255cd69ee1179a29c79f9a (diff)
downloadchromium_src-90ca3f2eed88de69ace6be025fd2c22b79a25958.zip
chromium_src-90ca3f2eed88de69ace6be025fd2c22b79a25958.tar.gz
chromium_src-90ca3f2eed88de69ace6be025fd2c22b79a25958.tar.bz2
[NaCl SDK] Used cached size when calling MountNodeHttp::GetSize.
Without this change, every call to seek will perform 2 HEAD requests. BUG=none R=sbc@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/12070007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179702 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc5
-rw-r--r--native_client_sdk/src/libraries/nacl_mounts/mount_http.cc12
2 files changed, 7 insertions, 10 deletions
diff --git a/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc
index 5103542..f1f2600 100644
--- a/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.cc
@@ -27,12 +27,13 @@ KernelHandle::KernelHandle(Mount* mnt, MountNode* node, int mode)
off_t KernelHandle::Seek(off_t offset, int whence) {
size_t base;
+ size_t node_size = node_->GetSize();
switch (whence) {
default: return -1;
case SEEK_SET: base = 0; break;
case SEEK_CUR: base = offs_; break;
- case SEEK_END: base = node_->GetSize(); break;
+ case SEEK_END: base = node_size; break;
}
if (base + offset < 0) {
@@ -44,7 +45,7 @@ off_t KernelHandle::Seek(off_t offset, int whence) {
// Seeking past the end of the file will zero out the space between the old
// end and the new end.
- if (offs_ > node_->GetSize()) {
+ if (offs_ > node_size) {
if (node_->Truncate(offs_) < 0) {
errno = EINVAL;
return -1;
diff --git a/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc b/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc
index bd5fc40..f269a41 100644
--- a/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc
+++ b/native_client_sdk/src/libraries/nacl_mounts/mount_http.cc
@@ -328,19 +328,15 @@ int MountNodeHttp::Truncate(size_t size) {
}
int MountNodeHttp::Write(size_t offs, const void* buf, size_t count) {
- // TODO(binji): supprt POST?
+ // TODO(binji): support POST?
errno = ENOSYS;
return -1;
}
size_t MountNodeHttp::GetSize() {
- struct stat stat;
- if (GetStat(&stat) == -1) {
- // errno is already set by GetStat.
- return -1;
- }
-
- return stat.st_size;
+ // TODO(binji): This value should be cached properly; i.e. obey the caching
+ // headers returned by the server.
+ return stat_.st_size;
}
MountNodeHttp::MountNodeHttp(Mount* mount, int ino, int dev,