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

Side by Side Diff: chrome/browser/bitmap_fetcher/bitmap_fetcher_service.cc

Issue 1878153002: Revert of Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/storage_partition.h"
15 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
17 16
18 namespace { 17 namespace {
19 18
20 const size_t kMaxRequests = 25; // Maximum number of inflight requests allowed. 19 const size_t kMaxRequests = 25; // Maximum number of inflight requests allowed.
21 const int kMaxCacheEntries = 5; // Maximum number of cache entries. 20 const int kMaxCacheEntries = 5; // Maximum number of cache entries.
22 21
23 } // namespace. 22 } // namespace.
24 23
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (url.is_valid()) 121 if (url.is_valid())
123 EnsureFetcherForUrl(url); 122 EnsureFetcherForUrl(url);
124 } 123 }
125 124
126 scoped_ptr<chrome::BitmapFetcher> BitmapFetcherService::CreateFetcher( 125 scoped_ptr<chrome::BitmapFetcher> BitmapFetcherService::CreateFetcher(
127 const GURL& url) { 126 const GURL& url) {
128 scoped_ptr<chrome::BitmapFetcher> new_fetcher( 127 scoped_ptr<chrome::BitmapFetcher> new_fetcher(
129 new chrome::BitmapFetcher(url, this)); 128 new chrome::BitmapFetcher(url, this));
130 129
131 new_fetcher->Init( 130 new_fetcher->Init(
132 content::BrowserContext::GetDefaultStoragePartition(context_)-> 131 context_->GetRequestContext(),
133 GetURLRequestContext(),
134 std::string(), 132 std::string(),
135 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 133 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
136 net::LOAD_NORMAL); 134 net::LOAD_NORMAL);
137 new_fetcher->Start(); 135 new_fetcher->Start();
138 return new_fetcher; 136 return new_fetcher;
139 } 137 }
140 138
141 const chrome::BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl( 139 const chrome::BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl(
142 const GURL& url) { 140 const GURL& url) {
143 const chrome::BitmapFetcher* fetcher = FindFetcherForUrl(url); 141 const chrome::BitmapFetcher* fetcher = FindFetcherForUrl(url);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 184 }
187 185
188 if (bitmap && !bitmap->isNull()) { 186 if (bitmap && !bitmap->isNull()) {
189 scoped_ptr<CacheEntry> entry(new CacheEntry); 187 scoped_ptr<CacheEntry> entry(new CacheEntry);
190 entry->bitmap.reset(new SkBitmap(*bitmap)); 188 entry->bitmap.reset(new SkBitmap(*bitmap));
191 cache_.Put(fetcher->url(), std::move(entry)); 189 cache_.Put(fetcher->url(), std::move(entry));
192 } 190 }
193 191
194 RemoveFetcher(fetcher); 192 RemoveFetcher(fetcher);
195 } 193 }
OLDNEW
« no previous file with comments | « blimp/engine/common/blimp_browser_context.cc ('k') | chrome/browser/browsing_data/browsing_data_remover.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698