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

Side by Side Diff: net/http/mock_http_cache.cc

Issue 1298253002: Remove reference counting from HttpNetworkSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test Created 5 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
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/http/mock_http_cache.h" 5 #include "net/http/mock_http_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 512
513 int MockBackendFactory::CreateBackend(NetLog* net_log, 513 int MockBackendFactory::CreateBackend(NetLog* net_log,
514 scoped_ptr<disk_cache::Backend>* backend, 514 scoped_ptr<disk_cache::Backend>* backend,
515 const CompletionCallback& callback) { 515 const CompletionCallback& callback) {
516 backend->reset(new MockDiskCache()); 516 backend->reset(new MockDiskCache());
517 return OK; 517 return OK;
518 } 518 }
519 519
520 //----------------------------------------------------------------------------- 520 //-----------------------------------------------------------------------------
521 521
522 MockHttpCache::MockHttpCache() 522 MockHttpCache::MockHttpCache() : MockHttpCache(new MockBackendFactory()) {}
523 : http_cache_(new MockNetworkLayer(), NULL, new MockBackendFactory()) {
524 }
525 523
526 MockHttpCache::MockHttpCache(HttpCache::BackendFactory* disk_cache_factory) 524 MockHttpCache::MockHttpCache(HttpCache::BackendFactory* disk_cache_factory)
527 : http_cache_(new MockNetworkLayer(), NULL, disk_cache_factory) { 525 : http_cache_(new MockNetworkLayer(), nullptr, disk_cache_factory, true) {}
528 }
529 526
530 disk_cache::Backend* MockHttpCache::backend() { 527 disk_cache::Backend* MockHttpCache::backend() {
531 TestCompletionCallback cb; 528 TestCompletionCallback cb;
532 disk_cache::Backend* backend; 529 disk_cache::Backend* backend;
533 int rv = http_cache_.GetBackend(&backend, cb.callback()); 530 int rv = http_cache_.GetBackend(&backend, cb.callback());
534 rv = cb.GetResult(rv); 531 rv = cb.GetResult(rv);
535 return (rv == OK) ? backend : NULL; 532 return (rv == OK) ? backend : NULL;
536 } 533 }
537 534
538 MockDiskCache* MockHttpCache::disk_cache() { 535 MockDiskCache* MockHttpCache::disk_cache() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 if (!callback_.is_null()) { 658 if (!callback_.is_null()) {
662 if (!fail_) 659 if (!fail_)
663 backend_->reset(new MockDiskCache()); 660 backend_->reset(new MockDiskCache());
664 CompletionCallback cb = callback_; 661 CompletionCallback cb = callback_;
665 callback_.Reset(); 662 callback_.Reset();
666 cb.Run(Result()); // This object can be deleted here. 663 cb.Run(Result()); // This object can be deleted here.
667 } 664 }
668 } 665 }
669 666
670 } // namespace net 667 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_unittest.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698