| Index: components/update_client/persisted_data.h
|
| diff --git a/components/update_client/persisted_data.h b/components/update_client/persisted_data.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..91af14f35fd947e2aa0b42981eb2e77bb4f71114
|
| --- /dev/null
|
| +++ b/components/update_client/persisted_data.h
|
| @@ -0,0 +1,77 @@
|
| +// 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_PERSISTED_DATA_H_
|
| +#define COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_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 PersistedData 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 PersistedData : public base::RefCountedThreadSafe<PersistedData> {
|
| + public:
|
| + // Constructs a provider that uses a file at the specified |path|. The
|
| + // |task_runner| will be used to serialize the data.
|
| + PersistedData(
|
| + 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
|
| + // non-negative integer: calls with a negative |datenum| are simply ignored.
|
| + // Calls to SetDateLastRollCall that occur prior to the persisted data store
|
| + // has been fully initialized are ignored.
|
| + void SetDateLastRollCall(const std::vector<std::string>& ids, int datenum);
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<PersistedData>;
|
| +
|
| + ~PersistedData();
|
| +
|
| + void Initialize(
|
| + const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner);
|
| + void LoadFromFile();
|
| + void Ready();
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + const base::FilePath path_;
|
| + base::ImportantFileWriter file_writer_;
|
| + scoped_ptr<base::DictionaryValue> metadata_;
|
| + bool ready_;
|
| + const scoped_refptr<base::SequencedTaskRunner> task_runner_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PersistedData);
|
| +};
|
| +
|
| +} // namespace update_client
|
| +
|
| +#endif // COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_
|
|
|