| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 int timeout_ms) { | 771 int timeout_ms) { |
| 772 if (!channel_.get()) { | 772 if (!channel_.get()) { |
| 773 delete msg; | 773 delete msg; |
| 774 return false; | 774 return false; |
| 775 } | 775 } |
| 776 return channel_->SendWithTimeout(msg, timeout_ms); | 776 return channel_->SendWithTimeout(msg, timeout_ms); |
| 777 } | 777 } |
| 778 | 778 |
| 779 // This is a platform specific function for mapping a transport DIB given its id | 779 // This is a platform specific function for mapping a transport DIB given its id |
| 780 TransportDIB* BrowserRenderProcessHost::MapTransportDIB( | 780 TransportDIB* BrowserRenderProcessHost::MapTransportDIB( |
| 781 TransportDIB::Id dib_id) { | 781 TransportDIB::Id dib_id, TransportDIB::Handle dib_handle) { |
| 782 #if defined(OS_WIN) | 782 TransportDIB::ScopedHandle scoped_handle(dib_handle); |
| 783 // On Windows we need to duplicate the handle from the remote process | 783 #if defined(OS_MACOSX) |
| 784 HANDLE section = win_util::GetSectionFromProcess( | |
| 785 dib_id.handle, GetHandle(), false /* read write */); | |
| 786 return TransportDIB::Map(section); | |
| 787 #elif defined(OS_MACOSX) | |
| 788 // On OSX, the browser allocates all DIBs and keeps a file descriptor around | 784 // On OSX, the browser allocates all DIBs and keeps a file descriptor around |
| 789 // for each. | 785 // for each. |
| 790 return widget_helper_->MapTransportDIB(dib_id); | 786 return widget_helper_->MapTransportDIB(dib_id); |
| 791 #elif defined(OS_POSIX) | 787 #else |
| 792 return TransportDIB::Map(dib_id); | 788 return TransportDIB::Map(scoped_handle.release()); |
| 793 #endif // defined(OS_POSIX) | 789 #endif |
| 794 } | 790 } |
| 795 | 791 |
| 796 TransportDIB* BrowserRenderProcessHost::GetTransportDIB( | 792 TransportDIB* BrowserRenderProcessHost::GetTransportDIB( |
| 797 TransportDIB::Id dib_id) { | 793 TransportDIB::Id dib_id, TransportDIB::Handle dib_handle) { |
| 794 TransportDIB::ScopedHandle scoped_handle(dib_handle); |
| 798 const std::map<TransportDIB::Id, TransportDIB*>::iterator | 795 const std::map<TransportDIB::Id, TransportDIB*>::iterator |
| 799 i = cached_dibs_.find(dib_id); | 796 i = cached_dibs_.find(dib_id); |
| 800 if (i != cached_dibs_.end()) { | 797 if (i != cached_dibs_.end()) { |
| 801 cached_dibs_cleaner_.Reset(); | 798 cached_dibs_cleaner_.Reset(); |
| 802 return i->second; | 799 return i->second; |
| 803 } | 800 } |
| 804 | 801 |
| 805 TransportDIB* dib = MapTransportDIB(dib_id); | 802 TransportDIB* dib = MapTransportDIB(dib_id, scoped_handle.release()); |
| 806 if (!dib) | 803 if (!dib) |
| 807 return NULL; | 804 return NULL; |
| 808 | 805 |
| 809 if (cached_dibs_.size() >= MAX_MAPPED_TRANSPORT_DIBS) { | 806 if (cached_dibs_.size() >= MAX_MAPPED_TRANSPORT_DIBS) { |
| 810 // Clean a single entry from the cache | 807 // Clean a single entry from the cache |
| 811 std::map<TransportDIB::Id, TransportDIB*>::iterator smallest_iterator; | 808 std::map<TransportDIB::Id, TransportDIB*>::iterator smallest_iterator; |
| 812 size_t smallest_size = std::numeric_limits<size_t>::max(); | 809 size_t smallest_size = std::numeric_limits<size_t>::max(); |
| 813 | 810 |
| 814 for (std::map<TransportDIB::Id, TransportDIB*>::iterator | 811 for (std::map<TransportDIB::Id, TransportDIB*>::iterator |
| 815 i = cached_dibs_.begin(); i != cached_dibs_.end(); ++i) { | 812 i = cached_dibs_.begin(); i != cached_dibs_.end(); ++i) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 IPC::InvalidPlatformFileForTransit(), | 1126 IPC::InvalidPlatformFileForTransit(), |
| 1130 std::vector<std::string>(), | 1127 std::vector<std::string>(), |
| 1131 std::string(), | 1128 std::string(), |
| 1132 false)); | 1129 false)); |
| 1133 } | 1130 } |
| 1134 } | 1131 } |
| 1135 | 1132 |
| 1136 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { | 1133 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { |
| 1137 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); | 1134 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); |
| 1138 } | 1135 } |
| OLD | NEW |