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

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

Issue 18660004: Extension activity log database refactoring (step 1) (Closed) Base URL: http://git.chromium.org/chromium/src.git@incognito-tests
Patch Set: Delegate renaming and comment cleanup Created 7 years, 5 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 (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
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 // Deleting the old policy takes place asynchronously, on the database
136 // thread. Initializing a new policy below similarly happens
137 // asynchronously. Since the two operations are both queued for the
138 // database, the queue ordering should ensure that the deletion completes
139 // before database initialization occurs.
140 //
141 // However, changing policies at runtime is still not recommended, and
142 // likely only should be done for unit tests.
143 if (policy_)
144 policy_->Close();
145
136 switch (policy_type) { 146 switch (policy_type) {
137 case ActivityLogPolicy::POLICY_FULLSTREAM: 147 case ActivityLogPolicy::POLICY_FULLSTREAM:
138 policy_ = new FullStreamUIPolicy(profile_); 148 policy_ = new FullStreamUIPolicy(profile_);
139 break; 149 break;
140 case ActivityLogPolicy::POLICY_NOARGS: 150 case ActivityLogPolicy::POLICY_NOARGS:
141 policy_ = new StreamWithoutArgsUIPolicy(profile_); 151 policy_ = new StreamWithoutArgsUIPolicy(profile_);
142 break; 152 break;
143 default: 153 default:
144 NOTREACHED(); 154 NOTREACHED();
145 } 155 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); 210 SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM);
201 else 211 else
202 SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); 212 SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS);
203 } 213 }
204 214
205 void ActivityLog::Shutdown() { 215 void ActivityLog::Shutdown() {
206 if (tracker_) tracker_->RemoveObserver(this); 216 if (tracker_) tracker_->RemoveObserver(this);
207 } 217 }
208 218
209 ActivityLog::~ActivityLog() { 219 ActivityLog::~ActivityLog() {
210 // TODO(felt): Turn policy_ into a scoped_ptr. 220 if (policy_)
211 delete policy_; 221 policy_->Close();
212 } 222 }
213 223
214 bool ActivityLog::IsLogEnabled() { 224 bool ActivityLog::IsLogEnabled() {
215 if (!has_threads_ || !initialized_) return false; 225 if (!has_threads_ || !initialized_) return false;
216 return enabled_; 226 return enabled_;
217 } 227 }
218 228
219 void ActivityLog::OnExtensionInstalled(const Extension* extension) { 229 void ActivityLog::OnExtensionInstalled(const Extension* extension) {
220 if (extension->id() != kActivityLogExtensionId) return; 230 if (extension->id() != kActivityLogExtensionId) return;
221 enabled_ = true; 231 enabled_ = true;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 web_contents->GetTitle(), 514 web_contents->GetTitle(),
505 std::string(), // no api call here 515 std::string(), // no api call here
506 script_names.get(), 516 script_names.get(),
507 DomActionType::INSERTED, 517 DomActionType::INSERTED,
508 extra); 518 extra);
509 } 519 }
510 } 520 }
511 } 521 }
512 522
513 } // namespace extensions 523 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/activity_log.h ('k') | chrome/browser/extensions/activity_log/activity_log_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698