Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: components/dom_distiller/core/distilled_content_store.h

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
12 #include "base/containers/mru_cache.h" 13 #include "base/containers/mru_cache.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "components/dom_distiller/core/article_entry.h" 15 #include "components/dom_distiller/core/article_entry.h"
16 #include "components/dom_distiller/core/proto/distilled_article.pb.h" 16 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
17 17
18 namespace dom_distiller { 18 namespace dom_distiller {
19 19
20 // The maximum number of items to keep in the cache before deleting some. 20 // The maximum number of items to keep in the cache before deleting some.
21 const int kDefaultMaxNumCachedEntries = 32; 21 const int kDefaultMaxNumCachedEntries = 32;
22 22
23 // This is a simple interface for saving and loading of distilled content for an 23 // This is a simple interface for saving and loading of distilled content for an
24 // ArticleEntry. 24 // ArticleEntry.
25 class DistilledContentStore { 25 class DistilledContentStore {
26 public: 26 public:
27 typedef base::Callback< 27 typedef base::Callback<void(bool /* success */,
28 void(bool /* success */, scoped_ptr<DistilledArticleProto>)> LoadCallback; 28 std::unique_ptr<DistilledArticleProto>)>
29 LoadCallback;
29 typedef base::Callback<void(bool /* success */)> SaveCallback; 30 typedef base::Callback<void(bool /* success */)> SaveCallback;
30 31
31 virtual void SaveContent(const ArticleEntry& entry, 32 virtual void SaveContent(const ArticleEntry& entry,
32 const DistilledArticleProto& proto, 33 const DistilledArticleProto& proto,
33 SaveCallback callback) = 0; 34 SaveCallback callback) = 0;
34 virtual void LoadContent(const ArticleEntry& entry, 35 virtual void LoadContent(const ArticleEntry& entry,
35 LoadCallback callback) = 0; 36 LoadCallback callback) = 0;
36 37
37 DistilledContentStore() {}; 38 DistilledContentStore() {};
38 virtual ~DistilledContentStore() {}; 39 virtual ~DistilledContentStore() {};
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 private: 71 private:
71 InMemoryContentStore* store_; 72 InMemoryContentStore* store_;
72 }; 73 };
73 74
74 void AddUrlToIdMapping(const ArticleEntry& entry, 75 void AddUrlToIdMapping(const ArticleEntry& entry,
75 const DistilledArticleProto& proto); 76 const DistilledArticleProto& proto);
76 77
77 void EraseUrlToIdMapping(const DistilledArticleProto& proto); 78 void EraseUrlToIdMapping(const DistilledArticleProto& proto);
78 79
79 typedef base::MRUCache<std::string, 80 typedef base::MRUCache<std::string,
80 scoped_ptr<DistilledArticleProto, CacheDeletor>> 81 std::unique_ptr<DistilledArticleProto, CacheDeletor>>
81 82
82 ContentMap; 83 ContentMap;
83 typedef base::hash_map<std::string, std::string> UrlMap; 84 typedef base::hash_map<std::string, std::string> UrlMap;
84 85
85 ContentMap cache_; 86 ContentMap cache_;
86 UrlMap url_to_id_; 87 UrlMap url_to_id_;
87 }; 88 };
88 89
89 } // dom_distiller 90 } // dom_distiller
90 91
91 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ 92 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698