| 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/renderer/visitedlink_slave.h" | 5 #include "chrome/renderer/visitedlink_slave.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 11 | 11 |
| 12 using WebKit::WebView; | 12 using WebKit::WebView; |
| 13 | 13 |
| 14 VisitedLinkSlave::VisitedLinkSlave() : shared_memory_(NULL) { | 14 VisitedLinkSlave::VisitedLinkSlave() : shared_memory_(NULL) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 VisitedLinkSlave::~VisitedLinkSlave() { | 17 VisitedLinkSlave::~VisitedLinkSlave() { |
| 18 FreeTable(); | 18 FreeTable(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 bool VisitedLinkSlave::OnControlMessageReceived(const IPC::Message& message) { | 21 bool VisitedLinkSlave::OnControlMessageReceived(const IPC::Message& message) { |
| 22 bool handled = true; | 22 bool handled = true; |
| 23 IPC_BEGIN_MESSAGE_MAP(VisitedLinkSlave, message) | 23 IPC_BEGIN_MESSAGE_MAP(VisitedLinkSlave, message) |
| 24 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) | 24 IPC_MESSAGE_HANDLER(ChromeViewMsg_VisitedLink_NewTable, |
| 25 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks) | 25 OnUpdateVisitedLinks) |
| 26 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks) | 26 IPC_MESSAGE_HANDLER(ChromeViewMsg_VisitedLink_Add, OnAddVisitedLinks) |
| 27 IPC_MESSAGE_HANDLER(ChromeViewMsg_VisitedLink_Reset, OnResetVisitedLinks) |
| 27 IPC_MESSAGE_UNHANDLED(handled = false) | 28 IPC_MESSAGE_UNHANDLED(handled = false) |
| 28 IPC_END_MESSAGE_MAP() | 29 IPC_END_MESSAGE_MAP() |
| 29 return handled; | 30 return handled; |
| 30 } | 31 } |
| 31 | 32 |
| 32 // This function's job is to initialize the table with the given | 33 // This function's job is to initialize the table with the given |
| 33 // shared memory handle. This memory is mapped into the process. | 34 // shared memory handle. This memory is mapped into the process. |
| 34 void VisitedLinkSlave::OnUpdateVisitedLinks(base::SharedMemoryHandle table) { | 35 void VisitedLinkSlave::OnUpdateVisitedLinks(base::SharedMemoryHandle table) { |
| 35 DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle"; | 36 DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle"; |
| 36 // since this function may be called again to change the table, we may need | 37 // since this function may be called again to change the table, we may need |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 80 } |
| 80 | 81 |
| 81 void VisitedLinkSlave::FreeTable() { | 82 void VisitedLinkSlave::FreeTable() { |
| 82 if (shared_memory_) { | 83 if (shared_memory_) { |
| 83 delete shared_memory_; | 84 delete shared_memory_; |
| 84 shared_memory_ = NULL; | 85 shared_memory_ = NULL; |
| 85 } | 86 } |
| 86 hash_table_ = NULL; | 87 hash_table_ = NULL; |
| 87 table_length_ = 0; | 88 table_length_ = 0; |
| 88 } | 89 } |
| OLD | NEW |