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

Side by Side Diff: chrome/browser/sessions/session_data_deleter.cc

Issue 511473002: Remove implicit conversions from scoped_refptr to T* in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move download out Created 6 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
« no previous file with comments | « chrome/browser/search/search_unittest.cc ('k') | chrome/browser/signin/easy_unlock_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "chrome/browser/browser_shutdown.h" 8 #include "chrome/browser/browser_shutdown.h"
9 #include "chrome/browser/prefs/session_startup_pref.h" 9 #include "chrome/browser/prefs/session_startup_pref.h"
10 #include "chrome/browser/profiles/profile_io_data.h" 10 #include "chrome/browser/profiles/profile_io_data.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 SessionDataDeleter::SessionDataDeleter( 68 SessionDataDeleter::SessionDataDeleter(
69 storage::SpecialStoragePolicy* storage_policy, 69 storage::SpecialStoragePolicy* storage_policy,
70 bool delete_only_by_session_only_policy) 70 bool delete_only_by_session_only_policy)
71 : storage_policy_(storage_policy), 71 : storage_policy_(storage_policy),
72 delete_only_by_session_only_policy_(delete_only_by_session_only_policy) { 72 delete_only_by_session_only_policy_(delete_only_by_session_only_policy) {
73 } 73 }
74 74
75 void SessionDataDeleter::Run(content::StoragePartition* storage_partition, 75 void SessionDataDeleter::Run(content::StoragePartition* storage_partition,
76 ProfileIOData* profile_io_data) { 76 ProfileIOData* profile_io_data) {
77 if (storage_policy_ && storage_policy_->HasSessionOnlyOrigins()) { 77 if (storage_policy_.get() && storage_policy_->HasSessionOnlyOrigins()) {
78 storage_partition->GetDOMStorageContext()->GetLocalStorageUsage( 78 storage_partition->GetDOMStorageContext()->GetLocalStorageUsage(
79 base::Bind(&SessionDataDeleter::ClearSessionOnlyLocalStorage, 79 base::Bind(&SessionDataDeleter::ClearSessionOnlyLocalStorage,
80 this, 80 this,
81 storage_partition)); 81 storage_partition));
82 } 82 }
83 content::BrowserThread::PostTask( 83 content::BrowserThread::PostTask(
84 content::BrowserThread::IO, 84 content::BrowserThread::IO,
85 FROM_HERE, 85 FROM_HERE,
86 base::Bind(&SessionDataDeleter::DeleteSessionCookiesOnIOThread, 86 base::Bind(&SessionDataDeleter::DeleteSessionCookiesOnIOThread,
87 this, 87 this,
88 profile_io_data)); 88 profile_io_data));
89 } 89 }
90 90
91 SessionDataDeleter::~SessionDataDeleter() {} 91 SessionDataDeleter::~SessionDataDeleter() {}
92 92
93 void SessionDataDeleter::ClearSessionOnlyLocalStorage( 93 void SessionDataDeleter::ClearSessionOnlyLocalStorage(
94 content::StoragePartition* storage_partition, 94 content::StoragePartition* storage_partition,
95 const std::vector<content::LocalStorageUsageInfo>& usages) { 95 const std::vector<content::LocalStorageUsageInfo>& usages) {
96 DCHECK(storage_policy_); 96 DCHECK(storage_policy_.get());
97 DCHECK(storage_policy_->HasSessionOnlyOrigins()); 97 DCHECK(storage_policy_->HasSessionOnlyOrigins());
98 for (size_t i = 0; i < usages.size(); ++i) { 98 for (size_t i = 0; i < usages.size(); ++i) {
99 const content::LocalStorageUsageInfo& usage = usages[i]; 99 const content::LocalStorageUsageInfo& usage = usages[i];
100 if (!storage_policy_->IsStorageSessionOnly(usage.origin)) 100 if (!storage_policy_->IsStorageSessionOnly(usage.origin))
101 continue; 101 continue;
102 storage_partition->GetDOMStorageContext()->DeleteLocalStorage(usage.origin); 102 storage_partition->GetDOMStorageContext()->DeleteLocalStorage(usage.origin);
103 } 103 }
104 } 104 }
105 105
106 void SessionDataDeleter::DeleteSessionCookiesOnIOThread( 106 void SessionDataDeleter::DeleteSessionCookiesOnIOThread(
(...skipping 11 matching lines...) Expand all
118 } 118 }
119 } 119 }
120 120
121 void SessionDataDeleter::DeleteSessionCookiesDone(int num_deleted) { 121 void SessionDataDeleter::DeleteSessionCookiesDone(int num_deleted) {
122 cookie_monster_->GetAllCookiesAsync( 122 cookie_monster_->GetAllCookiesAsync(
123 base::Bind(&SessionDataDeleter::DeleteSessionOnlyOriginCookies, this)); 123 base::Bind(&SessionDataDeleter::DeleteSessionOnlyOriginCookies, this));
124 } 124 }
125 125
126 void SessionDataDeleter::DeleteSessionOnlyOriginCookies( 126 void SessionDataDeleter::DeleteSessionOnlyOriginCookies(
127 const net::CookieList& cookies) { 127 const net::CookieList& cookies) {
128 if (!storage_policy_ || !storage_policy_->HasSessionOnlyOrigins()) 128 if (!storage_policy_.get() || !storage_policy_->HasSessionOnlyOrigins())
129 return; 129 return;
130 130
131 for (net::CookieList::const_iterator it = cookies.begin(); 131 for (net::CookieList::const_iterator it = cookies.begin();
132 it != cookies.end(); 132 it != cookies.end();
133 ++it) { 133 ++it) {
134 GURL url = 134 GURL url =
135 net::cookie_util::CookieOriginToURL(it->Domain(), it->IsSecure()); 135 net::cookie_util::CookieOriginToURL(it->Domain(), it->IsSecure());
136 if (!storage_policy_->IsStorageSessionOnly(url)) 136 if (!storage_policy_->IsStorageSessionOnly(url))
137 continue; 137 continue;
138 cookie_monster_->DeleteCanonicalCookieAsync(*it, base::Bind(CookieDeleted)); 138 cookie_monster_->DeleteCanonicalCookieAsync(*it, base::Bind(CookieDeleted));
(...skipping 16 matching lines...) Expand all
155 *CommandLine::ForCurrentProcess(), profile).type; 155 *CommandLine::ForCurrentProcess(), profile).type;
156 #endif 156 #endif
157 157
158 scoped_refptr<SessionDataDeleter> deleter( 158 scoped_refptr<SessionDataDeleter> deleter(
159 new SessionDataDeleter(profile->GetSpecialStoragePolicy(), 159 new SessionDataDeleter(profile->GetSpecialStoragePolicy(),
160 startup_pref_type == SessionStartupPref::LAST)); 160 startup_pref_type == SessionStartupPref::LAST));
161 deleter->Run( 161 deleter->Run(
162 Profile::GetDefaultStoragePartition(profile), 162 Profile::GetDefaultStoragePartition(profile),
163 ProfileIOData::FromResourceContext(profile->GetResourceContext())); 163 ProfileIOData::FromResourceContext(profile->GetResourceContext()));
164 } 164 }
OLDNEW
« no previous file with comments | « chrome/browser/search/search_unittest.cc ('k') | chrome/browser/signin/easy_unlock_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698