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

Side by Side Diff: net/url_request/test_url_fetcher_factory.cc

Issue 2378173002: Precache per-resource cap should be applied on network bytes used (Closed)
Patch Set: Created 4 years, 2 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 | « net/tools/get_server_time/get_server_time.cc ('k') | net/url_request/url_fetcher_core.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/url_request/test_url_fetcher_factory.h" 5 #include "net/url_request/test_url_fetcher_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 base::ThreadTaskRunnerHandle::Get()->PostTask( 391 base::ThreadTaskRunnerHandle::Get()->PostTask(
392 FROM_HERE, 392 FROM_HERE,
393 base::Bind(&FakeURLFetcher::RunDelegate, weak_factory_.GetWeakPtr())); 393 base::Bind(&FakeURLFetcher::RunDelegate, weak_factory_.GetWeakPtr()));
394 } 394 }
395 395
396 void FakeURLFetcher::RunDelegate() { 396 void FakeURLFetcher::RunDelegate() {
397 // OnURLFetchDownloadProgress may delete this URLFetcher. We keep track of 397 // OnURLFetchDownloadProgress may delete this URLFetcher. We keep track of
398 // this with a weak pointer, and only call OnURLFetchComplete if this still 398 // this with a weak pointer, and only call OnURLFetchComplete if this still
399 // exists. 399 // exists.
400 auto weak_this = weak_factory_.GetWeakPtr(); 400 auto weak_this = weak_factory_.GetWeakPtr();
401 delegate()->OnURLFetchDownloadProgress(this, response_bytes_, 401 delegate()->OnURLFetchDownloadProgress(this, response_bytes_, response_bytes_,
402 response_bytes_); 402 response_bytes_);
403 if (weak_this.get()) 403 if (weak_this.get())
404 delegate()->OnURLFetchComplete(this); 404 delegate()->OnURLFetchComplete(this);
405 } 405 }
406 406
407 const GURL& FakeURLFetcher::GetURL() const { 407 const GURL& FakeURLFetcher::GetURL() const {
408 return TestURLFetcher::GetOriginalURL(); 408 return TestURLFetcher::GetOriginalURL();
409 } 409 }
410 410
411 FakeURLFetcherFactory::FakeURLFetcherFactory( 411 FakeURLFetcherFactory::FakeURLFetcherFactory(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 std::unique_ptr<URLFetcher> URLFetcherImplFactory::CreateURLFetcher( 482 std::unique_ptr<URLFetcher> URLFetcherImplFactory::CreateURLFetcher(
483 int id, 483 int id,
484 const GURL& url, 484 const GURL& url,
485 URLFetcher::RequestType request_type, 485 URLFetcher::RequestType request_type,
486 URLFetcherDelegate* d) { 486 URLFetcherDelegate* d) {
487 return std::unique_ptr<URLFetcher>(new URLFetcherImpl(url, request_type, d)); 487 return std::unique_ptr<URLFetcher>(new URLFetcherImpl(url, request_type, d));
488 } 488 }
489 489
490 } // namespace net 490 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/get_server_time/get_server_time.cc ('k') | net/url_request/url_fetcher_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698