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/predictors/resource_prefetcher_manager.h" | 5 #include "chrome/browser/predictors/resource_prefetcher_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 if (it != prefetcher_map_.end() && | 75 if (it != prefetcher_map_.end() && |
76 it->second->main_frame_url() == main_frame_url) { | 76 it->second->main_frame_url() == main_frame_url) { |
77 it->second->Stop(); | 77 it->second->Stop(); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 void ResourcePrefetcherManager::ResourcePrefetcherFinished( | 81 void ResourcePrefetcherManager::ResourcePrefetcherFinished( |
82 ResourcePrefetcher* resource_prefetcher) { | 82 ResourcePrefetcher* resource_prefetcher) { |
83 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 83 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
84 | 84 |
85 const std::string key = resource_prefetcher->main_frame_url().host(); | 85 const GURL main_frame_url = resource_prefetcher->main_frame_url(); |
86 const std::string key = main_frame_url.host(); | |
86 auto it = prefetcher_map_.find(key); | 87 auto it = prefetcher_map_.find(key); |
87 DCHECK(it != prefetcher_map_.end()); | 88 DCHECK(it != prefetcher_map_.end()); |
88 prefetcher_map_.erase(it); | 89 prefetcher_map_.erase(it); |
90 | |
91 BrowserThread::PostTask( | |
alexilin
2016/12/06 12:44:17
Probably we don't want to send this message to oth
| |
92 BrowserThread::UI, FROM_HERE, | |
93 base::Bind(&ResourcePrefetchPredictor::OnPrefetchingFinished, | |
94 base::Unretained(predictor_), main_frame_url)); | |
alexilin
2016/12/06 12:44:17
I'm not sure that base::Unretained is safe here. P
| |
89 } | 95 } |
90 | 96 |
91 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { | 97 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { |
92 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 98 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
93 | 99 |
94 return context_getter_->GetURLRequestContext(); | 100 return context_getter_->GetURLRequestContext(); |
95 } | 101 } |
96 | 102 |
97 } // namespace predictors | 103 } // namespace predictors |
OLD | NEW |