Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 125 } |
| 126 | 126 |
| 127 ActivityLogFactory::~ActivityLogFactory() { | 127 ActivityLogFactory::~ActivityLogFactory() { |
| 128 } | 128 } |
| 129 | 129 |
| 130 // ActivityLog | 130 // ActivityLog |
| 131 | 131 |
| 132 void ActivityLog::SetDefaultPolicy(ActivityLogPolicy::PolicyType policy_type) { | 132 void ActivityLog::SetDefaultPolicy(ActivityLogPolicy::PolicyType policy_type) { |
| 133 // Can't use IsLogEnabled() here because this is called from inside Init. | 133 // Can't use IsLogEnabled() here because this is called from inside Init. |
| 134 if (policy_type != policy_type_ && enabled_) { | 134 if (policy_type != policy_type_ && enabled_) { |
| 135 delete policy_; | 135 // Changing policies once one has been installed is not currently |
| 136 // supported. After calling Close() on the old policy, there is no way to | |
| 137 // wait for changes to be flushed to disk to know that it is safe to | |
| 138 // potentially reopen the database with a new policy. | |
| 139 CHECK(policy_ == NULL); | |
|
felt
2013/07/10 18:35:17
Can you make this a DCHECK?
| |
| 136 switch (policy_type) { | 140 switch (policy_type) { |
| 137 case ActivityLogPolicy::POLICY_FULLSTREAM: | 141 case ActivityLogPolicy::POLICY_FULLSTREAM: |
| 138 policy_ = new FullStreamUIPolicy(profile_); | 142 policy_ = new FullStreamUIPolicy(profile_); |
| 139 break; | 143 break; |
| 140 case ActivityLogPolicy::POLICY_NOARGS: | 144 case ActivityLogPolicy::POLICY_NOARGS: |
| 141 policy_ = new StreamWithoutArgsUIPolicy(profile_); | 145 policy_ = new StreamWithoutArgsUIPolicy(profile_); |
| 142 break; | 146 break; |
| 143 default: | 147 default: |
| 144 NOTREACHED(); | 148 NOTREACHED(); |
| 145 } | 149 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); | 204 SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
| 201 else | 205 else |
| 202 SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); | 206 SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); |
| 203 } | 207 } |
| 204 | 208 |
| 205 void ActivityLog::Shutdown() { | 209 void ActivityLog::Shutdown() { |
| 206 if (tracker_) tracker_->RemoveObserver(this); | 210 if (tracker_) tracker_->RemoveObserver(this); |
| 207 } | 211 } |
| 208 | 212 |
| 209 ActivityLog::~ActivityLog() { | 213 ActivityLog::~ActivityLog() { |
| 210 // TODO(felt): Turn policy_ into a scoped_ptr. | 214 policy_->Close(); |
| 211 delete policy_; | |
| 212 } | 215 } |
| 213 | 216 |
| 214 bool ActivityLog::IsLogEnabled() { | 217 bool ActivityLog::IsLogEnabled() { |
| 215 if (!has_threads_ || !initialized_) return false; | 218 if (!has_threads_ || !initialized_) return false; |
| 216 return enabled_; | 219 return enabled_; |
| 217 } | 220 } |
| 218 | 221 |
| 219 void ActivityLog::OnExtensionInstalled(const Extension* extension) { | 222 void ActivityLog::OnExtensionInstalled(const Extension* extension) { |
| 220 if (extension->id() != kActivityLogExtensionId) return; | 223 if (extension->id() != kActivityLogExtensionId) return; |
| 221 enabled_ = true; | 224 enabled_ = true; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 web_contents->GetTitle(), | 507 web_contents->GetTitle(), |
| 505 std::string(), // no api call here | 508 std::string(), // no api call here |
| 506 script_names.get(), | 509 script_names.get(), |
| 507 DomActionType::INSERTED, | 510 DomActionType::INSERTED, |
| 508 extra); | 511 extra); |
| 509 } | 512 } |
| 510 } | 513 } |
| 511 } | 514 } |
| 512 | 515 |
| 513 } // namespace extensions | 516 } // namespace extensions |
| OLD | NEW |