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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/activity_log/activity_log.cc
diff --git a/chrome/browser/extensions/activity_log/activity_log.cc b/chrome/browser/extensions/activity_log/activity_log.cc
index f2b38ba97372581f83387c85c23dc65cb37cadb7..78a07be9f9d085a69daabc92c766839081ebf52e 100644
--- a/chrome/browser/extensions/activity_log/activity_log.cc
+++ b/chrome/browser/extensions/activity_log/activity_log.cc
@@ -132,7 +132,17 @@ ActivityLogFactory::~ActivityLogFactory() {
void ActivityLog::SetDefaultPolicy(ActivityLogPolicy::PolicyType policy_type) {
// Can't use IsLogEnabled() here because this is called from inside Init.
if (policy_type != policy_type_ && enabled_) {
- delete policy_;
+ // Deleting the old policy takes place asynchronously, on the database
+ // thread. Initializing a new policy below similarly happens
+ // asynchronously. Since the two operations are both queued for the
+ // database, the queue ordering should ensure that the deletion completes
+ // before database initialization occurs.
+ //
+ // However, changing policies at runtime is still not recommended, and
+ // likely only should be done for unit tests.
+ if (policy_)
+ policy_->Close();
+
switch (policy_type) {
case ActivityLogPolicy::POLICY_FULLSTREAM:
policy_ = new FullStreamUIPolicy(profile_);
@@ -207,8 +217,8 @@ void ActivityLog::Shutdown() {
}
ActivityLog::~ActivityLog() {
- // TODO(felt): Turn policy_ into a scoped_ptr.
- delete policy_;
+ if (policy_)
+ policy_->Close();
}
bool ActivityLog::IsLogEnabled() {
« 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