OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MODEL_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_MODEL_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_MODEL_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_MODEL_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
12 #include "base/id_map.h" | 15 #include "base/id_map.h" |
| 16 #include "base/macros.h" |
13 #include "components/dom_distiller/core/article_entry.h" | 17 #include "components/dom_distiller/core/article_entry.h" |
14 #include "sync/api/sync_change.h" | 18 #include "sync/api/sync_change.h" |
15 #include "sync/api/sync_change_processor.h" // syncer::SyncChangeList | 19 #include "sync/api/sync_change_processor.h" // syncer::SyncChangeList |
16 #include "sync/api/sync_data.h" | 20 #include "sync/api/sync_data.h" |
17 #include "url/gurl.h" | 21 #include "url/gurl.h" |
18 | 22 |
19 namespace dom_distiller { | 23 namespace dom_distiller { |
20 | 24 |
21 // This stores the in-memory model of the DOM distiller list. Entries can be | 25 // This stores the in-memory model of the DOM distiller list. Entries can be |
22 // looked up by URL or by entry_id. | 26 // looked up by URL or by entry_id. |
(...skipping 27 matching lines...) Expand all Loading... |
50 // the model to |changes_applied|. If conflict resolution does not apply the | 54 // the model to |changes_applied|. If conflict resolution does not apply the |
51 // requested change, then adds the "diff" between what was requested and what | 55 // requested change, then adds the "diff" between what was requested and what |
52 // was actually applied to |changes_missing|. | 56 // was actually applied to |changes_missing|. |
53 // Note: Currently conflicts are resolved by just applying the requested | 57 // Note: Currently conflicts are resolved by just applying the requested |
54 // change. This means nothing will be added to |changes_missing|. | 58 // change. This means nothing will be added to |changes_missing|. |
55 void ApplyChangesToModel(const syncer::SyncChangeList& change_list, | 59 void ApplyChangesToModel(const syncer::SyncChangeList& change_list, |
56 syncer::SyncChangeList* changes_applied, | 60 syncer::SyncChangeList* changes_applied, |
57 syncer::SyncChangeList* changes_missing); | 61 syncer::SyncChangeList* changes_missing); |
58 | 62 |
59 private: | 63 private: |
60 typedef int32 KeyType; | 64 typedef int32_t KeyType; |
61 typedef base::hash_map<KeyType, ArticleEntry> EntryMap; | 65 typedef base::hash_map<KeyType, ArticleEntry> EntryMap; |
62 typedef base::hash_map<std::string, KeyType> StringToKeyMap; | 66 typedef base::hash_map<std::string, KeyType> StringToKeyMap; |
63 | 67 |
64 void AddEntry(const ArticleEntry& entry); | 68 void AddEntry(const ArticleEntry& entry); |
65 void RemoveEntry(const ArticleEntry& entry); | 69 void RemoveEntry(const ArticleEntry& entry); |
66 | 70 |
67 // Lookup an entry's key by ID or URL. Returns whether a corresponding key was | 71 // Lookup an entry's key by ID or URL. Returns whether a corresponding key was |
68 // found. On success, if |key| is not null, it will contain the entry. | 72 // found. On success, if |key| is not null, it will contain the entry. |
69 bool GetKeyById(const std::string& entry_id, KeyType* key) const; | 73 bool GetKeyById(const std::string& entry_id, KeyType* key) const; |
70 bool GetKeyByUrl(const GURL& url, KeyType* key) const; | 74 bool GetKeyByUrl(const GURL& url, KeyType* key) const; |
(...skipping 10 matching lines...) Expand all Loading... |
81 EntryMap entries_; | 85 EntryMap entries_; |
82 StringToKeyMap url_to_key_map_; | 86 StringToKeyMap url_to_key_map_; |
83 StringToKeyMap entry_id_to_key_map_; | 87 StringToKeyMap entry_id_to_key_map_; |
84 | 88 |
85 DISALLOW_COPY_AND_ASSIGN(DomDistillerModel); | 89 DISALLOW_COPY_AND_ASSIGN(DomDistillerModel); |
86 }; | 90 }; |
87 | 91 |
88 } // namespace dom_distiller | 92 } // namespace dom_distiller |
89 | 93 |
90 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_MODEL_H_ | 94 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_MODEL_H_ |
OLD | NEW |