diff options
author | mal@chromium.org <mal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 21:38:54 +0000 |
---|---|---|
committer | mal@chromium.org <mal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 21:38:54 +0000 |
commit | 4e8ebaae85e28511c93c6f3ba08c9839d9370b29 (patch) | |
tree | 68e05fde1f1922a1ed449b3d273229d5f98c07e0 | |
parent | de8c1bd2848d9425d939c587c42b37ae496b954d (diff) | |
download | chromium_src-4e8ebaae85e28511c93c6f3ba08c9839d9370b29.zip chromium_src-4e8ebaae85e28511c93c6f3ba08c9839d9370b29.tar.gz chromium_src-4e8ebaae85e28511c93c6f3ba08c9839d9370b29.tar.bz2 |
Merge 32701 - Don't do work in the SharedIOBuffer constructor;
use an Init method instead. This eliminates instances of allocatedbutinvalid SharedIOBuffers. Also clean up some CHECKs and TODOs associated with the bug.
The upshot is that we no longer crash in AsyncResourceHandler::OnResponseCompleted() when we can't allocate shared memory. We now crash (properly, I believe) in the renderer process if the shared memory that failed to allocate was the TransportDIB, since the renderer can't communicate with the browser without it.
BUG=16371
TEST=none
Review URL: http://codereview.chromium.org/391009
TBR=hawk@chromium.org
Review URL: http://codereview.chromium.org/437070
git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@33126 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/shared_memory_posix.cc | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/async_resource_handler.cc | 16 |
2 files changed, 13 insertions, 9 deletions
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc index 6919cfc..34e7b72 100644 --- a/base/shared_memory_posix.cc +++ b/base/shared_memory_posix.cc @@ -203,10 +203,8 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name, return false; const size_t current_size = stat.st_size; if (current_size != size) { - // TODO(hawk): When finished with bug 16371, revert this CHECK() to: - // if (ftruncate(fileno(fp), size) != 0) - // return false; - CHECK(!ftruncate(fileno(fp), size)); + if (ftruncate(fileno(fp), size) != 0) + return false; if (fseeko(fp, size, SEEK_SET) != 0) return false; } diff --git a/chrome/browser/renderer_host/async_resource_handler.cc b/chrome/browser/renderer_host/async_resource_handler.cc index e7fe56c..276e431 100644 --- a/chrome/browser/renderer_host/async_resource_handler.cc +++ b/chrome/browser/renderer_host/async_resource_handler.cc @@ -31,12 +31,17 @@ class SharedIOBuffer : public net::IOBuffer { explicit SharedIOBuffer(int buffer_size) : net::IOBuffer(), ok_(false), - buffer_size_(buffer_size) { - if (shared_memory_.Create(std::wstring(), false, false, buffer_size) && - shared_memory_.Map(buffer_size)) { - ok_ = true; + buffer_size_(buffer_size) {} + + bool Init() { + if (shared_memory_.Create(std::wstring(), false, false, buffer_size_) && + shared_memory_.Map(buffer_size_)) { data_ = reinterpret_cast<char*>(shared_memory_.memory()); + // TODO(hawk): Remove after debugging bug 16371. + CHECK(data_); + ok_ = true; } + return ok_; } base::SharedMemory* shared_memory() { return &shared_memory_; } @@ -111,8 +116,9 @@ bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, *buf_size = read_buffer_->buffer_size(); } else { read_buffer_ = new SharedIOBuffer(next_buffer_size_); - if (!read_buffer_->ok()) { + if (!read_buffer_->Init()) { DLOG(ERROR) << "Couldn't allocate shared io buffer"; + read_buffer_ = NULL; return false; } // TODO(willchan): Remove after debugging bug 16371. |