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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 10898002: Refactor BrowsingDataRemover creation for clarity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating callsites. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 base::Time removal_begin, 93 base::Time removal_begin,
94 int removal_mask, 94 int removal_mask,
95 int origin_set_mask) 95 int origin_set_mask)
96 : removal_begin(removal_begin), 96 : removal_begin(removal_begin),
97 removal_mask(removal_mask), 97 removal_mask(removal_mask),
98 origin_set_mask(origin_set_mask) { 98 origin_set_mask(origin_set_mask) {
99 } 99 }
100 100
101 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {} 101 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {}
102 102
103 // TODO(mkwst): We should have one constructor, not two. http://crbug.com/130732 103 // Static.
104 BrowsingDataRemover* BrowsingDataRemover::CreateForUnboundedRange(
105 Profile* profile) {
106 return new BrowsingDataRemover(profile, base::Time(), base::Time::Max());
107 }
108
109 // Static.
110 BrowsingDataRemover* BrowsingDataRemover::CreateForRange(Profile* profile,
111 base::Time start, base::Time end) {
112 return new BrowsingDataRemover(profile, start, end);
113 }
114
115 // Static.
116 BrowsingDataRemover* BrowsingDataRemover::CreateForPeriod(Profile* profile,
117 TimePeriod time_period) {
118 return new BrowsingDataRemover(profile,
119 BrowsingDataRemover::CalculateBeginDeleteTime(time_period),
120 base::Time::Max());
121 }
122
104 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, 123 BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
105 base::Time delete_begin, 124 base::Time delete_begin,
106 base::Time delete_end) 125 base::Time delete_end)
107 : profile_(profile), 126 : profile_(profile),
108 quota_manager_(NULL), 127 quota_manager_(NULL),
109 dom_storage_context_(NULL), 128 dom_storage_context_(NULL),
110 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), 129 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
111 delete_begin_(delete_begin), 130 delete_begin_(delete_begin),
112 delete_end_(delete_end), 131 delete_end_(delete_end),
113 next_cache_state_(STATE_NONE), 132 next_cache_state_(STATE_NONE),
114 cache_(NULL), 133 cache_(NULL),
115 main_context_getter_(profile->GetRequestContext()),
116 media_context_getter_(profile->GetMediaRequestContext()),
117 deauthorize_content_licenses_request_id_(0),
118 waiting_for_clear_cache_(false),
119 waiting_for_clear_nacl_cache_(false),
120 waiting_for_clear_cookies_count_(0),
121 waiting_for_clear_history_(false),
122 waiting_for_clear_local_storage_(false),
123 waiting_for_clear_networking_history_(false),
124 waiting_for_clear_server_bound_certs_(false),
125 waiting_for_clear_plugin_data_(false),
126 waiting_for_clear_quota_managed_data_(false),
127 waiting_for_clear_content_licenses_(false),
128 waiting_for_clear_form_(false),
129 remove_mask_(0),
130 remove_origin_(GURL()),
131 origin_set_mask_(0) {
132 DCHECK(profile);
133 // crbug.com/140910: Many places were calling this with base::Time() as
134 // delete_end, even though they should've used base::Time::Now(). Work around
135 // it here. New code should use base::Time::Now().
136 DCHECK(delete_end_ != base::Time());
137 if (delete_end_ == base::Time())
138 delete_end_ = base::Time::Now();
139 }
140
141 BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
142 TimePeriod time_period,
143 base::Time delete_end)
144 : profile_(profile),
145 quota_manager_(NULL),
146 dom_storage_context_(NULL),
147 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
148 delete_begin_(CalculateBeginDeleteTime(time_period)),
149 delete_end_(delete_end),
150 next_cache_state_(STATE_NONE),
151 cache_(NULL),
152 main_context_getter_(profile->GetRequestContext()), 134 main_context_getter_(profile->GetRequestContext()),
153 media_context_getter_(profile->GetMediaRequestContext()), 135 media_context_getter_(profile->GetMediaRequestContext()),
154 deauthorize_content_licenses_request_id_(0), 136 deauthorize_content_licenses_request_id_(0),
155 waiting_for_clear_cache_(false), 137 waiting_for_clear_cache_(false),
156 waiting_for_clear_nacl_cache_(false), 138 waiting_for_clear_nacl_cache_(false),
157 waiting_for_clear_cookies_count_(0), 139 waiting_for_clear_cookies_count_(0),
158 waiting_for_clear_history_(false), 140 waiting_for_clear_history_(false),
159 waiting_for_clear_local_storage_(false), 141 waiting_for_clear_local_storage_(false),
160 waiting_for_clear_networking_history_(false), 142 waiting_for_clear_networking_history_(false),
161 waiting_for_clear_server_bound_certs_(false), 143 waiting_for_clear_server_bound_certs_(false),
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 BrowserThread::UI, FROM_HERE, 908 BrowserThread::UI, FROM_HERE,
927 base::Bind(&BrowsingDataRemover::OnClearedFormData, 909 base::Bind(&BrowsingDataRemover::OnClearedFormData,
928 base::Unretained(this))); 910 base::Unretained(this)));
929 } 911 }
930 912
931 void BrowsingDataRemover::OnClearedFormData() { 913 void BrowsingDataRemover::OnClearedFormData() {
932 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 914 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
933 waiting_for_clear_form_ = false; 915 waiting_for_clear_form_ = false;
934 NotifyAndDeleteIfDone(); 916 NotifyAndDeleteIfDone();
935 } 917 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698