| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |