| 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/bitmap_fetcher/bitmap_fetcher_service.h" | 5 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 | 115 |
| 116 void BitmapFetcherService::Prefetch(const GURL& url) { | 116 void BitmapFetcherService::Prefetch(const GURL& url) { |
| 117 if (url.is_valid()) | 117 if (url.is_valid()) |
| 118 EnsureFetcherForUrl(url); | 118 EnsureFetcherForUrl(url); |
| 119 } | 119 } |
| 120 | 120 |
| 121 chrome::BitmapFetcher* BitmapFetcherService::CreateFetcher(const GURL& url) { | 121 chrome::BitmapFetcher* BitmapFetcherService::CreateFetcher(const GURL& url) { |
| 122 chrome::BitmapFetcher* new_fetcher = new chrome::BitmapFetcher(url, this); | 122 chrome::BitmapFetcher* new_fetcher = new chrome::BitmapFetcher(url, this); |
| 123 | 123 |
| 124 new_fetcher->Start( | 124 new_fetcher->Init( |
| 125 context_->GetRequestContext(), | 125 context_->GetRequestContext(), |
| 126 std::string(), | 126 std::string(), |
| 127 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 127 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 128 net::LOAD_NORMAL); | 128 net::LOAD_NORMAL); |
| 129 new_fetcher->Start(); |
| 129 return new_fetcher; | 130 return new_fetcher; |
| 130 } | 131 } |
| 131 | 132 |
| 132 const chrome::BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl( | 133 const chrome::BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl( |
| 133 const GURL& url) { | 134 const GURL& url) { |
| 134 const chrome::BitmapFetcher* fetcher = FindFetcherForUrl(url); | 135 const chrome::BitmapFetcher* fetcher = FindFetcherForUrl(url); |
| 135 if (fetcher) | 136 if (fetcher) |
| 136 return fetcher; | 137 return fetcher; |
| 137 | 138 |
| 138 chrome::BitmapFetcher* new_fetcher = CreateFetcher(url); | 139 chrome::BitmapFetcher* new_fetcher = CreateFetcher(url); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 183 } |
| 183 | 184 |
| 184 if (!bitmap->isNull()) { | 185 if (!bitmap->isNull()) { |
| 185 CacheEntry* entry = new CacheEntry; | 186 CacheEntry* entry = new CacheEntry; |
| 186 entry->bitmap.reset(new SkBitmap(*bitmap)); | 187 entry->bitmap.reset(new SkBitmap(*bitmap)); |
| 187 cache_.Put(fetcher->url(), entry); | 188 cache_.Put(fetcher->url(), entry); |
| 188 } | 189 } |
| 189 | 190 |
| 190 RemoveFetcher(fetcher); | 191 RemoveFetcher(fetcher); |
| 191 } | 192 } |
| OLD | NEW |