Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/renderer_host/async_resource_handler.cc

Issue 20099: Fix a memory leak on the async resource handler. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/io_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_host/async_resource_handler.h" 5 #include "chrome/browser/renderer_host/async_resource_handler.h"
6 6
7 #include "base/process.h" 7 #include "base/process.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 9
10 SharedIOBuffer* AsyncResourceHandler::spare_read_buffer_; 10 SharedIOBuffer* AsyncResourceHandler::spare_read_buffer_;
11 11
12 // Our version of IOBuffer that uses shared memory. 12 // Our version of IOBuffer that uses shared memory.
13 class SharedIOBuffer : public net::IOBuffer { 13 class SharedIOBuffer : public net::IOBuffer {
14 public: 14 public:
15 SharedIOBuffer(int buffer_size) : net::IOBuffer(NULL), ok_(false) { 15 SharedIOBuffer(int buffer_size) : net::IOBuffer(), ok_(false) {
16 if (shared_memory_.Create(std::wstring(), false, false, buffer_size) && 16 if (shared_memory_.Create(std::wstring(), false, false, buffer_size) &&
17 shared_memory_.Map(buffer_size)) { 17 shared_memory_.Map(buffer_size)) {
18 ok_ = true; 18 ok_ = true;
19 data_ = reinterpret_cast<char*>(shared_memory_.memory()); 19 data_ = reinterpret_cast<char*>(shared_memory_.memory());
20 } 20 }
21 } 21 }
22 ~SharedIOBuffer() { 22 ~SharedIOBuffer() {
23 data_ = NULL; 23 data_ = NULL;
24 } 24 }
25 25
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } else if (read_buffer_.get()) { 123 } else if (read_buffer_.get()) {
124 read_buffer_.swap(&spare_read_buffer_); 124 read_buffer_.swap(&spare_read_buffer_);
125 } 125 }
126 return true; 126 return true;
127 } 127 }
128 128
129 // static 129 // static
130 void AsyncResourceHandler::GlobalCleanup() { 130 void AsyncResourceHandler::GlobalCleanup() {
131 spare_read_buffer_ = NULL; 131 spare_read_buffer_ = NULL;
132 } 132 }
OLDNEW
« no previous file with comments | « no previous file | net/base/io_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698