OLD | NEW |
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 <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/json/json_string_value_serializer.h" | 13 #include "base/json/json_string_value_serializer.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/time/clock.h" | 16 #include "base/time/clock.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" | 18 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
24 using content::BrowserThread; | |
25 | |
26 namespace constants = activity_log_constants; | 24 namespace constants = activity_log_constants; |
27 | 25 |
28 namespace extensions { | 26 namespace extensions { |
29 | 27 |
30 ActivityLogPolicy::ActivityLogPolicy(Profile* profile) {} | 28 ActivityLogPolicy::ActivityLogPolicy(Profile* profile) {} |
31 | 29 |
32 ActivityLogPolicy::~ActivityLogPolicy() {} | 30 ActivityLogPolicy::~ActivityLogPolicy() {} |
33 | 31 |
34 void ActivityLogPolicy::SetClockForTesting(std::unique_ptr<base::Clock> clock) { | 32 void ActivityLogPolicy::SetClockForTesting(std::unique_ptr<base::Clock> clock) { |
35 testing_clock_ = std::move(clock); | 33 testing_clock_ = std::move(clock); |
36 } | 34 } |
37 | 35 |
38 base::Time ActivityLogPolicy::Now() const { | 36 base::Time ActivityLogPolicy::Now() const { |
39 if (testing_clock_) | 37 if (testing_clock_) |
40 return testing_clock_->Now(); | 38 return testing_clock_->Now(); |
41 return base::Time::Now(); | 39 return base::Time::Now(); |
42 } | 40 } |
43 | 41 |
44 ActivityLogDatabasePolicy::ActivityLogDatabasePolicy( | 42 ActivityLogDatabasePolicy::ActivityLogDatabasePolicy( |
45 Profile* profile, | 43 Profile* profile, |
46 const base::FilePath& database_name) | 44 const base::FilePath& database_name) |
47 : ActivityLogPolicy(profile) { | 45 : ActivityLogPolicy(profile) { |
48 CHECK(profile); | 46 CHECK(profile); |
49 base::FilePath profile_base_path = profile->GetPath(); | 47 base::FilePath profile_base_path = profile->GetPath(); |
50 db_ = new ActivityDatabase(this); | 48 db_ = new ActivityDatabase(this); |
51 database_path_ = profile_base_path.Append(database_name); | 49 database_path_ = profile_base_path.Append(database_name); |
52 } | 50 } |
53 | 51 |
54 void ActivityLogDatabasePolicy::Init() { | 52 void ActivityLogDatabasePolicy::Init() { |
| 53 LOG(WARNING) << "Scheduling init"; |
55 ScheduleAndForget(db_, &ActivityDatabase::Init, database_path_); | 54 ScheduleAndForget(db_, &ActivityDatabase::Init, database_path_); |
56 } | 55 } |
57 | 56 |
58 void ActivityLogDatabasePolicy::Flush() { | 57 void ActivityLogDatabasePolicy::Flush() { |
59 ScheduleAndForget(activity_database(), | 58 ScheduleAndForget(activity_database(), |
60 &ActivityDatabase::AdviseFlush, | 59 &ActivityDatabase::AdviseFlush, |
61 ActivityDatabase::kFlushImmediately); | 60 ActivityDatabase::kFlushImmediately); |
62 } | 61 } |
63 | 62 |
64 sql::Connection* ActivityLogDatabasePolicy::GetDatabaseConnection() const { | 63 sql::Connection* ActivityLogDatabasePolicy::GetDatabaseConnection() const { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 *late_bound = base::Time::Max().ToInternalValue(); | 147 *late_bound = base::Time::Max().ToInternalValue(); |
149 } else { | 148 } else { |
150 base::Time early_time = Util::AddDays(morning_midnight, -days_ago); | 149 base::Time early_time = Util::AddDays(morning_midnight, -days_ago); |
151 base::Time late_time = Util::AddDays(early_time, 1); | 150 base::Time late_time = Util::AddDays(early_time, 1); |
152 *early_bound = early_time.ToInternalValue(); | 151 *early_bound = early_time.ToInternalValue(); |
153 *late_bound = late_time.ToInternalValue(); | 152 *late_bound = late_time.ToInternalValue(); |
154 } | 153 } |
155 } | 154 } |
156 | 155 |
157 } // namespace extensions | 156 } // namespace extensions |
OLD | NEW |