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

Unified Diff: chrome/browser/extensions/activity_log/activity_actions.cc

Issue 21646004: Compressed activity log database storage (Closed) Base URL: http://git.chromium.org/chromium/src.git@refactor-cleanups
Patch Set: Factor out dropping of obsolete tables and use in all policies Created 7 years, 4 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: chrome/browser/extensions/activity_log/activity_actions.cc
diff --git a/chrome/browser/extensions/activity_log/activity_actions.cc b/chrome/browser/extensions/activity_log/activity_actions.cc
index 1d792255900452d326b57088ac45880b9416e6d4..b83aab32034ce8de09375fe6330eaa3e8f3f6f88 100644
--- a/chrome/browser/extensions/activity_log/activity_actions.cc
+++ b/chrome/browser/extensions/activity_log/activity_actions.cc
@@ -13,7 +13,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/activity_log/activity_action_constants.h"
-#include "chrome/browser/extensions/activity_log/api_name_constants.h"
#include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
@@ -36,63 +35,6 @@ std::string Serialize(const base::Value* value) {
return value_as_text;
}
-// Sets up the hashmap for mapping extension strings to "ints". The hashmap is
-// only set up once because it's quite long; the value is then cached.
-class APINameMap {
- public:
- APINameMap() {
- SetupMap();
- }
-
- // activity_log_api_name_constants.h lists all known API calls as of 5/17.
- // This code maps each of those API calls (and events) to short strings
- // (integers converted to strings). They're all strings because (1) sqlite
- // databases are all strings underneath anyway and (2) the Lookup function
- // will simply return the original api_call string if we don't have it in our
- // lookup table.
- void SetupMap() {
- for (size_t i = 0;
- i < arraysize(activity_log_api_name_constants::kNames);
- ++i) {
- std::string name =
- std::string(activity_log_api_name_constants::kNames[i]);
- std::string num = base::IntToString(i);
- names_to_nums_[name] = num;
- nums_to_names_[num] = name;
- }
- }
-
- static APINameMap* GetInstance() {
- return Singleton<APINameMap>::get();
- }
-
- // This matches an api call to a number, if it's in the lookup table. If not,
- // it returns the original api call.
- const std::string& ApiToShortname(const std::string& api_call) {
- std::map<std::string, std::string>::iterator it =
- names_to_nums_.find(api_call);
- if (it == names_to_nums_.end())
- return api_call;
- else
- return it->second;
- }
-
- // This matches a number to an API call -- it's the opposite of
- // ApiToShortname.
- const std::string& ShortnameToApi(const std::string& shortname) {
- std::map<std::string, std::string>::iterator it =
- nums_to_names_.find(shortname);
- if (it == nums_to_names_.end())
- return shortname;
- else
- return it->second;
- }
-
- private:
- std::map<std::string, std::string> names_to_nums_; // <name, number label>
- std::map<std::string, std::string> nums_to_names_; // <number label, name>
-};
-
} // namespace
namespace extensions {
@@ -246,7 +188,7 @@ scoped_ptr<ExtensionActivity> Action::ConvertToExtensionActivity() {
return result.Pass();
}
-std::string Action::PrintForDebug() {
+std::string Action::PrintForDebug() const {
std::string result = "ID=" + extension_id() + " CATEGORY=";
switch (action_type_) {
case ACTION_API_CALL:

Powered by Google App Engine
This is Rietveld 408576698