| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_channel_id_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" |
| 11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 12 #include "net/ssl/channel_id_service.h" | 14 #include "net/ssl/channel_id_service.h" |
| 13 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
| 15 | 17 |
| 16 using content::BrowserThread; | 18 using content::BrowserThread; |
| 17 | 19 |
| 18 namespace { | 20 namespace { |
| 19 | 21 |
| 20 class BrowsingDataChannelIDHelperImpl | 22 class BrowsingDataChannelIDHelperImpl |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return channel_id_map_.size(); | 187 return channel_id_map_.size(); |
| 186 } | 188 } |
| 187 | 189 |
| 188 void CannedBrowsingDataChannelIDHelper::StartFetching( | 190 void CannedBrowsingDataChannelIDHelper::StartFetching( |
| 189 const FetchResultCallback& callback) { | 191 const FetchResultCallback& callback) { |
| 190 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 192 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 191 if (callback.is_null()) | 193 if (callback.is_null()) |
| 192 return; | 194 return; |
| 193 // We post a task to emulate async fetching behavior. | 195 // We post a task to emulate async fetching behavior. |
| 194 completion_callback_ = callback; | 196 completion_callback_ = callback; |
| 195 base::MessageLoop::current()->PostTask( | 197 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 196 FROM_HERE, | 198 FROM_HERE, |
| 197 base::Bind(&CannedBrowsingDataChannelIDHelper::FinishFetching, | 199 base::Bind(&CannedBrowsingDataChannelIDHelper::FinishFetching, this)); |
| 198 this)); | |
| 199 } | 200 } |
| 200 | 201 |
| 201 void CannedBrowsingDataChannelIDHelper::FinishFetching() { | 202 void CannedBrowsingDataChannelIDHelper::FinishFetching() { |
| 202 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 203 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 203 net::ChannelIDStore::ChannelIDList channel_id_list; | 204 net::ChannelIDStore::ChannelIDList channel_id_list; |
| 204 for (ChannelIDMap::iterator i = channel_id_map_.begin(); | 205 for (ChannelIDMap::iterator i = channel_id_map_.begin(); |
| 205 i != channel_id_map_.end(); ++i) | 206 i != channel_id_map_.end(); ++i) |
| 206 channel_id_list.push_back(i->second); | 207 channel_id_list.push_back(i->second); |
| 207 completion_callback_.Run(channel_id_list); | 208 completion_callback_.Run(channel_id_list); |
| 208 } | 209 } |
| 209 | 210 |
| 210 void CannedBrowsingDataChannelIDHelper::DeleteChannelID( | 211 void CannedBrowsingDataChannelIDHelper::DeleteChannelID( |
| 211 const std::string& server_id) { | 212 const std::string& server_id) { |
| 212 NOTREACHED(); | 213 NOTREACHED(); |
| 213 } | 214 } |
| OLD | NEW |