| 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 #ifndef CHROME_BROWSER_VISITEDLINK_MASTER_H__ | 5 #ifndef CHROME_BROWSER_VISITEDLINK_MASTER_H__ |
| 6 #define CHROME_BROWSER_VISITEDLINK_MASTER_H__ | 6 #define CHROME_BROWSER_VISITEDLINK_MASTER_H__ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
| 15 #include "chrome/browser/history/history.h" | 15 #include "chrome/browser/history/history.h" |
| 16 #include "chrome/common/visitedlink_common.h" | 16 #include "chrome/common/visitedlink_common.h" |
| 17 #include "testing/gtest/include/gtest/gtest_prod.h" | 17 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 class Profile; | 20 class Profile; |
| 21 | 21 |
| 22 // Controls the link coloring database. The master controls all writing to the | 22 // Controls the link coloring database. The master controls all writing to the |
| 23 // database as well as disk I/O. There should be only one master. | 23 // database as well as disk I/O. There should be only one master. |
| 24 // | 24 // |
| 25 // This class will optionally defer writing operations to another thread. This | 25 // This class will optionally defer writing operations to another thread. This |
| 26 // means that after class destruction, the file may still be open since | 26 // means that after class destruction, the file may still be open since |
| 27 // operations are pending on another thread. | 27 // operations are pending on another thread. |
| 28 class VisitedLinkMaster : public VisitedLinkCommon { | 28 class VisitedLinkMaster : public VisitedLinkCommon { |
| 29 public: | 29 public: |
| 30 typedef void (PostNewTableEvent)(SharedMemory*); | 30 typedef void (PostNewTableEvent)(base::SharedMemory*); |
| 31 | 31 |
| 32 // The |file_thread| may be NULL, in which case write operations will be | 32 // The |file_thread| may be NULL, in which case write operations will be |
| 33 // synchronous. | 33 // synchronous. |
| 34 VisitedLinkMaster(base::Thread* file_thread, | 34 VisitedLinkMaster(base::Thread* file_thread, |
| 35 PostNewTableEvent* poster, | 35 PostNewTableEvent* poster, |
| 36 Profile* profile); | 36 Profile* profile); |
| 37 | 37 |
| 38 // In unit test mode, we allow the caller to optionally specify the database | 38 // In unit test mode, we allow the caller to optionally specify the database |
| 39 // filename so that it can be run from a unit test. The directory where this | 39 // filename so that it can be run from a unit test. The directory where this |
| 40 // file resides must exist in this mode. You can also specify the default | 40 // file resides must exist in this mode. You can also specify the default |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 int32 default_table_size); | 58 int32 default_table_size); |
| 59 virtual ~VisitedLinkMaster(); | 59 virtual ~VisitedLinkMaster(); |
| 60 | 60 |
| 61 // Must be called immediately after object creation. Nothing else will work | 61 // Must be called immediately after object creation. Nothing else will work |
| 62 // until this is called. Returns true on success, false means that this | 62 // until this is called. Returns true on success, false means that this |
| 63 // object won't work. | 63 // object won't work. |
| 64 bool Init(); | 64 bool Init(); |
| 65 | 65 |
| 66 // Duplicates the handle to the shared memory to another process. | 66 // Duplicates the handle to the shared memory to another process. |
| 67 // Returns true on success. | 67 // Returns true on success. |
| 68 bool ShareToProcess(ProcessHandle process, SharedMemoryHandle *new_handle); | 68 bool ShareToProcess(base::ProcessHandle process, |
| 69 base::SharedMemoryHandle *new_handle); |
| 69 | 70 |
| 70 // returns the name of the shared memory object that slaves can use to map | 71 // returns the name of the shared memory object that slaves can use to map |
| 71 // the data | 72 // the data |
| 72 std::wstring GetSharedMemoryName() const; | 73 std::wstring GetSharedMemoryName() const; |
| 73 | 74 |
| 74 // Returns the handle to the shared memory | 75 // Returns the handle to the shared memory |
| 75 SharedMemoryHandle GetSharedMemoryHandle(); | 76 base::SharedMemoryHandle GetSharedMemoryHandle(); |
| 76 | 77 |
| 77 // Adds a URL to the table. | 78 // Adds a URL to the table. |
| 78 void AddURL(const GURL& url); | 79 void AddURL(const GURL& url); |
| 79 | 80 |
| 80 // Adds a set of URLs to the table. | 81 // Adds a set of URLs to the table. |
| 81 void AddURLs(const std::vector<GURL>& url); | 82 void AddURLs(const std::vector<GURL>& url); |
| 82 | 83 |
| 83 // Deletes the specified URLs from the table. | 84 // Deletes the specified URLs from the table. |
| 84 void DeleteURLs(const std::set<GURL>& urls); | 85 void DeleteURLs(const std::set<GURL>& urls); |
| 85 | 86 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // deleted during the rebuild here. Then we should delete any of these | 323 // deleted during the rebuild here. Then we should delete any of these |
| 323 // entries from the complete table later. | 324 // entries from the complete table later. |
| 324 //std::vector<Fingerprint> removed_since_rebuild_; | 325 //std::vector<Fingerprint> removed_since_rebuild_; |
| 325 | 326 |
| 326 // The currently open file with the table in it. This may be NULL if we're | 327 // The currently open file with the table in it. This may be NULL if we're |
| 327 // rebuilding and haven't written a new version yet. Writing to the file may | 328 // rebuilding and haven't written a new version yet. Writing to the file may |
| 328 // be safely ignored in this case. | 329 // be safely ignored in this case. |
| 329 HANDLE file_; | 330 HANDLE file_; |
| 330 | 331 |
| 331 // Shared memory consists of a SharedHeader followed by the table. | 332 // Shared memory consists of a SharedHeader followed by the table. |
| 332 SharedMemory *shared_memory_; | 333 base::SharedMemory *shared_memory_; |
| 333 | 334 |
| 334 // When we generate new tables, we increment the serial number of the | 335 // When we generate new tables, we increment the serial number of the |
| 335 // shared memory object. | 336 // shared memory object. |
| 336 int32 shared_memory_serial_; | 337 int32 shared_memory_serial_; |
| 337 | 338 |
| 338 // Number of non-empty items in the table, used to compute fullness. | 339 // Number of non-empty items in the table, used to compute fullness. |
| 339 int32 used_items_; | 340 int32 used_items_; |
| 340 | 341 |
| 341 // Testing values ----------------------------------------------------------- | 342 // Testing values ----------------------------------------------------------- |
| 342 // | 343 // |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 for (int32 i = 0; i < table_length_; i++) { | 378 for (int32 i = 0; i < table_length_; i++) { |
| 378 if (hash_table_[i]) | 379 if (hash_table_[i]) |
| 379 used_count++; | 380 used_count++; |
| 380 } | 381 } |
| 381 DCHECK(used_count == used_items_); | 382 DCHECK(used_count == used_items_); |
| 382 } | 383 } |
| 383 #endif | 384 #endif |
| 384 | 385 |
| 385 #endif // CHROME_BROWSER_VISITEDLINK_MASTER_H__ | 386 #endif // CHROME_BROWSER_VISITEDLINK_MASTER_H__ |
| 386 | 387 |
| OLD | NEW |