| 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 | 9 |
| 10 VisitedLinkSlave::VisitedLinkSlave() : shared_memory_(NULL) { | 10 VisitedLinkSlave::VisitedLinkSlave() : shared_memory_(NULL) { |
| 11 } | 11 } |
| 12 VisitedLinkSlave::~VisitedLinkSlave() { | 12 VisitedLinkSlave::~VisitedLinkSlave() { |
| 13 FreeTable(); | 13 FreeTable(); |
| 14 } | 14 } |
| 15 | 15 |
| 16 // This function's job is to initialize the table with the given | 16 // This function's job is to initialize the table with the given |
| 17 // shared memory handle. This memory is mappend into the process. | 17 // shared memory handle. This memory is mappend into the process. |
| 18 bool VisitedLinkSlave::Init(SharedMemoryHandle shared_memory) { | 18 bool VisitedLinkSlave::Init(base::SharedMemoryHandle shared_memory) { |
| 19 // since this function may be called again to change the table, we may need | 19 // since this function may be called again to change the table, we may need |
| 20 // to free old objects | 20 // to free old objects |
| 21 FreeTable(); | 21 FreeTable(); |
| 22 DCHECK(shared_memory_ == NULL && hash_table_ == NULL); | 22 DCHECK(shared_memory_ == NULL && hash_table_ == NULL); |
| 23 | 23 |
| 24 // create the shared memory object | 24 // create the shared memory object |
| 25 shared_memory_ = new SharedMemory(shared_memory, true); | 25 shared_memory_ = new base::SharedMemory(shared_memory, true); |
| 26 if (!shared_memory_) | 26 if (!shared_memory_) |
| 27 return false; | 27 return false; |
| 28 | 28 |
| 29 // map the header into our process so we can see how long the rest is, | 29 // map the header into our process so we can see how long the rest is, |
| 30 // and set the salt | 30 // and set the salt |
| 31 if (!shared_memory_->Map(sizeof(SharedHeader))) | 31 if (!shared_memory_->Map(sizeof(SharedHeader))) |
| 32 return false; | 32 return false; |
| 33 SharedHeader* header = | 33 SharedHeader* header = |
| 34 static_cast<SharedHeader*>(shared_memory_->memory()); | 34 static_cast<SharedHeader*>(shared_memory_->memory()); |
| 35 DCHECK(header); | 35 DCHECK(header); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 | 54 |
| 55 void VisitedLinkSlave::FreeTable() { | 55 void VisitedLinkSlave::FreeTable() { |
| 56 if (shared_memory_ ) { | 56 if (shared_memory_ ) { |
| 57 delete shared_memory_; | 57 delete shared_memory_; |
| 58 shared_memory_ = NULL; | 58 shared_memory_ = NULL; |
| 59 } | 59 } |
| 60 hash_table_ = NULL; | 60 hash_table_ = NULL; |
| 61 table_length_ = 0; | 61 table_length_ = 0; |
| 62 } | 62 } |
| 63 | 63 |
| OLD | NEW |