| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..177e147e1fb2175d5e66ca63e957e204000025e4
|
| --- /dev/null
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2015 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_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STORE_H_
|
| +#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STORE_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +
|
| +namespace data_reduction_proxy {
|
| +
|
| +// Interface for a permanent key value store used by the Data Reduction Proxy
|
| +// component. Clients that do not want to support a permanent store can use
|
| +// the |DummyDataReductionProxyStore| below, which provides no-op methods.
|
| +class DataReductionProxyStore
|
| + : public base::RefCountedThreadSafe<DataReductionProxyStore> {
|
| + public:
|
| + enum Status { OK, NOT_FOUND, ERROR };
|
| +
|
| + // Initializes the store on DB Thread.
|
| + virtual void InitializeOnDBThread() = 0;
|
| +
|
| + // Gets the value from the store for the provided key.
|
| + virtual Status Get(const std::string& key, std::string& value) = 0;
|
| +
|
| + // Persists the provided keys and values into the store.
|
| + virtual Status Put(const std::map<std::string, std::string>* map) = 0;
|
| +
|
| + protected:
|
| + DataReductionProxyStore();
|
| + virtual ~DataReductionProxyStore() = 0;
|
| +
|
| + private:
|
| + // Ref counted classes have private destructors to prevent accidental deletion
|
| + // of the object when there are still references to it.
|
| + friend class base::RefCountedThreadSafe<DataReductionProxyStore>;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DataReductionProxyStore);
|
| +};
|
| +
|
| +// Dummy implementation of |DataReductionProxyStore| with no-op methods.
|
| +class DummyDataReductionProxyStore : public DataReductionProxyStore {
|
| + public:
|
| + DummyDataReductionProxyStore();
|
| + void InitializeOnDBThread() override;
|
| + DataReductionProxyStore::Status Get(const std::string& key,
|
| + std::string& value) override;
|
| + DataReductionProxyStore::Status Put(
|
| + const std::map<std::string, std::string>* map) override;
|
| +
|
| + protected:
|
| + ~DummyDataReductionProxyStore() override;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(DummyDataReductionProxyStore);
|
| +};
|
| +
|
| +} // namespace data_reduction_proxy
|
| +
|
| +#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STORE_H_
|
|
|