OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_UPDATE_CLIENT_COMPONENT_METADATA_H_ | |
6 #define COMPONENTS_UPDATE_CLIENT_COMPONENT_METADATA_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/files/file_path.h" | |
12 #include "base/files/important_file_writer.h" | |
13 #include "base/macros.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/threading/thread_checker.h" | |
17 #include "base/values.h" | |
18 | |
19 namespace base { | |
20 | |
21 class SequencedTaskRunner; | |
22 class SingleThreadTaskRunner; | |
23 | |
24 } // namespace base | |
25 | |
26 namespace update_client { | |
27 | |
28 // A ComponentMetadata is a storer and provider of any per-component metadata | |
29 // that outlives the browser process and isn't exposed outside of update_client. | |
30 // | |
31 // It implements an in-memory data structure that is initialized from disk upon | |
32 // startup. Writes to the data structure are written to the disk. | |
33 // | |
34 // The public methods of this class should be called only on the thread that | |
35 // initializes it. | |
36 class ComponentMetadata : public base::RefCountedThreadSafe<ComponentMetadata> { | |
37 public: | |
38 // Constructs a provider that uses a file at the specified |path|. The | |
39 // |task_runner| will be used to serialize the data. | |
40 ComponentMetadata( | |
41 const base::FilePath& path, | |
42 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | |
43 | |
44 // Returns the DateLastRollCall of the specified |id|. -2 indicates that there | |
45 // is no record of the app. | |
46 int DateLastRollCall(const std::string& id) const; | |
47 | |
48 // Records the DateLastRollCall for the specified |ids|. |datenum| must be a | |
Sorin Jianu
2016/04/07 04:03:19
assert in the implementation?
waffles
2016/04/07 17:04:43
Done.
| |
49 // positive integer. | |
50 void SetDateLastRollCall(const std::vector<std::string>& ids, int datenum); | |
51 | |
52 private: | |
53 friend class base::RefCountedThreadSafe<ComponentMetadata>; | |
54 | |
55 virtual ~ComponentMetadata(); | |
Sorin Jianu
2016/04/07 04:03:19
This class has no virtual function, why the virtua
waffles
2016/04/07 17:04:43
Done.
| |
56 | |
57 void Initialize( | |
58 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner); | |
59 void LoadFromFile(); | |
60 void Ready(); | |
61 | |
62 const base::FilePath path_; | |
63 base::ImportantFileWriter file_writer_; | |
64 scoped_ptr<base::DictionaryValue> metadata_; | |
65 bool ready_; | |
66 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
67 const base::ThreadChecker thread_checker_; | |
Sorin Jianu
2016/04/07 04:03:19
do we want the thread_checker_ to be declared as t
waffles
2016/04/07 17:04:43
Done.
| |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(ComponentMetadata); | |
70 }; | |
71 | |
72 } // namespace update_client | |
73 | |
74 #endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_METADATA_H_ | |
OLD | NEW |