Index: components/update_client/component_metadata.h |
diff --git a/components/update_client/component_metadata.h b/components/update_client/component_metadata.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..328eb9c92dff500959167ff5f357a331c2f6491b |
--- /dev/null |
+++ b/components/update_client/component_metadata.h |
@@ -0,0 +1,74 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_UPDATE_CLIENT_COMPONENT_METADATA_H_ |
+#define COMPONENTS_UPDATE_CLIENT_COMPONENT_METADATA_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/files/file_path.h" |
+#include "base/files/important_file_writer.h" |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/threading/thread_checker.h" |
+#include "base/values.h" |
+ |
+namespace base { |
+ |
+class SequencedTaskRunner; |
+class SingleThreadTaskRunner; |
+ |
+} // namespace base |
+ |
+namespace update_client { |
+ |
+// A ComponentMetadata is a storer and provider of any per-component metadata |
+// that outlives the browser process and isn't exposed outside of update_client. |
+// |
+// It implements an in-memory data structure that is initialized from disk upon |
+// startup. Writes to the data structure are written to the disk. |
+// |
+// The public methods of this class should be called only on the thread that |
+// initializes it. |
+class ComponentMetadata : public base::RefCountedThreadSafe<ComponentMetadata> { |
+ public: |
+ // Constructs a provider that uses a file at the specified |path|. The |
+ // |task_runner| will be used to serialize the data. |
+ ComponentMetadata( |
+ const base::FilePath& path, |
+ const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
+ |
+ // Returns the DateLastRollCall of the specified |id|. -2 indicates that there |
+ // is no record of the app. |
+ int DateLastRollCall(const std::string& id) const; |
+ |
+ // 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.
|
+ // positive integer. |
+ void SetDateLastRollCall(const std::vector<std::string>& ids, int datenum); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<ComponentMetadata>; |
+ |
+ 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.
|
+ |
+ void Initialize( |
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner); |
+ void LoadFromFile(); |
+ void Ready(); |
+ |
+ const base::FilePath path_; |
+ base::ImportantFileWriter file_writer_; |
+ scoped_ptr<base::DictionaryValue> metadata_; |
+ bool ready_; |
+ const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
+ 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.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ComponentMetadata); |
+}; |
+ |
+} // namespace update_client |
+ |
+#endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_METADATA_H_ |