Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h

Issue 1173343009: LevelDB storage for data reduction proxy to store data usage stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use raw pointers for arguments instead of ref counting Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e22b76384f0b2040dbdda9211dc8ac2e57bff2f6
--- /dev/null
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h
@@ -0,0 +1,66 @@
+// 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 <string>
+
+#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
bengr 2015/06/25 23:22:55 key value -> key/value
Not at Google. Contact bengr 2015/06/29 20:53:27 Done.
+// component. Clients that do not want to support a permanent store can use
+// the |DummyDataReductionProxyStore| below, which provides no-op methods.
+class DataReductionProxyStore
bengr 2015/06/25 23:22:55 Why not just have no-op implementations instead of
michaeln 2015/06/26 20:15:01 Is the abstract base class really needed at all?
Not at Google. Contact bengr 2015/06/29 20:53:27 Done.
Not at Google. Contact bengr 2015/06/29 20:53:27 Removed.
+ : public base::RefCountedThreadSafe<DataReductionProxyStore> {
+ public:
+ // Values are used in UMA. Do not change existing values; only append to the
+ // end.
+ enum Status { OK, NOT_FOUND, CORRUPTED, IO_ERROR, MISC_ERROR, STATUS_MAX };
+
+ // 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;
bengr 2015/06/25 23:22:55 Can this method be const?
Not at Google. Contact bengr 2015/06/29 20:53:27 No. Get from level db could return CORRUPTION in w
+
+ // 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);
+};
+
bengr 2015/06/25 23:22:55 Add another blank line.
Not at Google. Contact bengr 2015/06/29 20:53:27 Done.
+// Dummy implementation of |DataReductionProxyStore| with no-op methods.
+class DummyDataReductionProxyStore : public DataReductionProxyStore {
bengr 2015/06/25 23:22:55 I don't think the dummy is needed.
Not at Google. Contact bengr 2015/06/29 20:53:27 Done
+ 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_

Powered by Google App Engine
This is Rietveld 408576698