| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/dom_distiller/core/distilled_content_store.h" | 5 #include "components/dom_distiller/core/distilled_content_store.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
| 8 | 8 |
| 9 namespace dom_distiller { | 9 namespace dom_distiller { |
| 10 | 10 |
| 11 InMemoryContentStore::InMemoryContentStore(const int max_num_entries) | 11 InMemoryContentStore::InMemoryContentStore(const int max_num_entries) |
| 12 : cache_(max_num_entries) {} | 12 : cache_(max_num_entries) {} |
| 13 | 13 |
| 14 InMemoryContentStore::~InMemoryContentStore() { | 14 InMemoryContentStore::~InMemoryContentStore() { |
| 15 // Clear the cache before destruction to ensure the CacheDeletor is not called | 15 // Clear the cache before destruction to ensure the CacheDeletor is not called |
| 16 // after InMemoryContentStore has been destroyed. | 16 // after InMemoryContentStore has been destroyed. |
| 17 cache_.Clear(); | 17 cache_.Clear(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void InMemoryContentStore::CacheDeletor::operator()( | 99 void InMemoryContentStore::CacheDeletor::operator()( |
| 100 DistilledArticleProto* proto) { | 100 DistilledArticleProto* proto) { |
| 101 // When InMemoryContentStore is deleted, the |store_| pointer becomes invalid, | 101 // When InMemoryContentStore is deleted, the |store_| pointer becomes invalid, |
| 102 // but since the ContentMap is cleared in the InMemoryContentStore destructor, | 102 // but since the ContentMap is cleared in the InMemoryContentStore destructor, |
| 103 // this should never be called after the destructor. | 103 // this should never be called after the destructor. |
| 104 store_->EraseUrlToIdMapping(*proto); | 104 store_->EraseUrlToIdMapping(*proto); |
| 105 delete proto; | 105 delete proto; |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace dom_distiller | 108 } // namespace dom_distiller |
| OLD | NEW |