summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorhawk@chromium.org <hawk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 23:08:38 +0000
committerhawk@chromium.org <hawk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 23:08:38 +0000
commitad8db61766da16b0be8177aa11128f4e8ec82ba0 (patch)
treea6d75a47f3be439dd2c78a6807b57bd16b7ce27c /chrome
parentb9148774aa3ad1d550a2835d5441febc97a4770e (diff)
downloadchromium_src-ad8db61766da16b0be8177aa11128f4e8ec82ba0.zip
chromium_src-ad8db61766da16b0be8177aa11128f4e8ec82ba0.tar.gz
chromium_src-ad8db61766da16b0be8177aa11128f4e8ec82ba0.tar.bz2
Don't do work in the SharedIOBuffer constructor; use an Init method instead. This eliminates instances of allocated-but-invalid 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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/async_resource_handler.cc16
1 files changed, 11 insertions, 5 deletions
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.