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

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: 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::create(Profile* profile,
105 base::Time delete_begin, base::Time delete_end) {
106 return new BrowsingDataRemover(profile, delete_begin, delete_end);
107 }
108
109 // static
110 BrowsingDataRemover* BrowsingDataRemover::create(Profile* profile,
111 TimePeriod time_period) {
112 return new BrowsingDataRemover(profile,
113 BrowsingDataRemover::CalculateBeginDeleteTime(time_period),
114 base::Time::Max());
115 }
116
104 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, 117 BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
105 base::Time delete_begin, 118 base::Time delete_begin,
106 base::Time delete_end) 119 base::Time delete_end)
107 : profile_(profile), 120 : profile_(profile),
108 quota_manager_(NULL), 121 quota_manager_(NULL),
109 dom_storage_context_(NULL), 122 dom_storage_context_(NULL),
110 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), 123 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
111 delete_begin_(delete_begin), 124 delete_begin_(delete_begin),
112 delete_end_(delete_end), 125 delete_end_(delete_end),
113 next_cache_state_(STATE_NONE), 126 next_cache_state_(STATE_NONE),
114 cache_(NULL), 127 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()), 128 main_context_getter_(profile->GetRequestContext()),
153 media_context_getter_(profile->GetMediaRequestContext()), 129 media_context_getter_(profile->GetMediaRequestContext()),
154 deauthorize_content_licenses_request_id_(0), 130 deauthorize_content_licenses_request_id_(0),
155 waiting_for_clear_cache_(false), 131 waiting_for_clear_cache_(false),
156 waiting_for_clear_nacl_cache_(false), 132 waiting_for_clear_nacl_cache_(false),
157 waiting_for_clear_cookies_count_(0), 133 waiting_for_clear_cookies_count_(0),
158 waiting_for_clear_history_(false), 134 waiting_for_clear_history_(false),
159 waiting_for_clear_local_storage_(false), 135 waiting_for_clear_local_storage_(false),
160 waiting_for_clear_networking_history_(false), 136 waiting_for_clear_networking_history_(false),
161 waiting_for_clear_server_bound_certs_(false), 137 waiting_for_clear_server_bound_certs_(false),
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 BrowserThread::UI, FROM_HERE, 902 BrowserThread::UI, FROM_HERE,
927 base::Bind(&BrowsingDataRemover::OnClearedFormData, 903 base::Bind(&BrowsingDataRemover::OnClearedFormData,
928 base::Unretained(this))); 904 base::Unretained(this)));
929 } 905 }
930 906
931 void BrowsingDataRemover::OnClearedFormData() { 907 void BrowsingDataRemover::OnClearedFormData() {
932 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 908 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
933 waiting_for_clear_form_ = false; 909 waiting_for_clear_form_ = false;
934 NotifyAndDeleteIfDone(); 910 NotifyAndDeleteIfDone();
935 } 911 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698