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

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log_policy.cc

Issue 2318833003: Remove activity_log's Util::DropObsoleteTables(). (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" 5 #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/stringprintf.h"
15 #include "base/time/clock.h" 14 #include "base/time/clock.h"
16 #include "base/time/time.h" 15 #include "base/time/time.h"
17 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" 16 #include "chrome/browser/extensions/activity_log/activity_action_constants.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
21 #include "url/gurl.h" 20 #include "url/gurl.h"
22 21
23 using content::BrowserThread; 22 using content::BrowserThread;
24 23
25 namespace constants = activity_log_constants; 24 namespace constants = activity_log_constants;
26 25
27 namespace {
28 // Obsolete database tables: these should be dropped from the database if
29 // found.
Lei Zhang 2016/09/07 08:17:44 This probably should have had a TODO attached to r
30 const char* const kObsoleteTables[] = {"activitylog_apis",
31 "activitylog_blocked",
32 "activitylog_urls"};
33 } // namespace
34
35 namespace extensions { 26 namespace extensions {
36 27
37 ActivityLogPolicy::ActivityLogPolicy(Profile* profile) {} 28 ActivityLogPolicy::ActivityLogPolicy(Profile* profile) {}
38 29
39 ActivityLogPolicy::~ActivityLogPolicy() {} 30 ActivityLogPolicy::~ActivityLogPolicy() {}
40 31
41 void ActivityLogPolicy::SetClockForTesting(std::unique_ptr<base::Clock> clock) { 32 void ActivityLogPolicy::SetClockForTesting(std::unique_ptr<base::Clock> clock) {
42 testing_clock_.reset(clock.release()); 33 testing_clock_.reset(clock.release());
43 } 34 }
44 35
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 *early_bound = morning_midnight.ToInternalValue(); 148 *early_bound = morning_midnight.ToInternalValue();
158 *late_bound = base::Time::Max().ToInternalValue(); 149 *late_bound = base::Time::Max().ToInternalValue();
159 } else { 150 } else {
160 base::Time early_time = Util::AddDays(morning_midnight, -days_ago); 151 base::Time early_time = Util::AddDays(morning_midnight, -days_ago);
161 base::Time late_time = Util::AddDays(early_time, 1); 152 base::Time late_time = Util::AddDays(early_time, 1);
162 *early_bound = early_time.ToInternalValue(); 153 *early_bound = early_time.ToInternalValue();
163 *late_bound = late_time.ToInternalValue(); 154 *late_bound = late_time.ToInternalValue();
164 } 155 }
165 } 156 }
166 157
167 // static
168 bool ActivityLogPolicy::Util::DropObsoleteTables(sql::Connection* db) {
169 for (size_t i = 0; i < arraysize(kObsoleteTables); i++) {
170 const char* table_name = kObsoleteTables[i];
171 if (db->DoesTableExist(table_name)) {
172 std::string drop_statement =
173 base::StringPrintf("DROP TABLE %s", table_name);
174 if (!db->Execute(drop_statement.c_str())) {
175 return false;
176 }
177 }
178 }
179 return true;
180 }
181
182 } // namespace extensions 158 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698