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

Side by Side Diff: net/disk_cache/simple/simple_backend_impl.cc

Issue 511163002: Net-related fixups for scoped_refptr conversion operator cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix naming to match Created 6 years, 3 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/disk_cache/simple/simple_backend_impl.h ('k') | net/disk_cache/simple/simple_index.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/disk_cache/simple/simple_backend_impl.h" 5 #include "net/disk_cache/simple/simple_backend_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <functional> 9 #include <functional>
10 10
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return; 649 return;
650 } 650 }
651 } 651 }
652 } 652 }
653 callback.Run(net::ERR_FAILED); 653 callback.Run(net::ERR_FAILED);
654 } 654 }
655 655
656 void SimpleBackendImpl::OnEntryOpenedFromHash( 656 void SimpleBackendImpl::OnEntryOpenedFromHash(
657 uint64 hash, 657 uint64 hash,
658 Entry** entry, 658 Entry** entry,
659 scoped_refptr<SimpleEntryImpl> simple_entry, 659 const scoped_refptr<SimpleEntryImpl>& simple_entry,
660 const CompletionCallback& callback, 660 const CompletionCallback& callback,
661 int error_code) { 661 int error_code) {
662 if (error_code != net::OK) { 662 if (error_code != net::OK) {
663 callback.Run(error_code); 663 callback.Run(error_code);
664 return; 664 return;
665 } 665 }
666 DCHECK(*entry); 666 DCHECK(*entry);
667 std::pair<EntryMap::iterator, bool> insert_result = 667 std::pair<EntryMap::iterator, bool> insert_result =
668 active_entries_.insert(EntryMap::value_type(hash, simple_entry)); 668 active_entries_.insert(EntryMap::value_type(hash, simple_entry.get()));
669 EntryMap::iterator& it = insert_result.first; 669 EntryMap::iterator& it = insert_result.first;
670 const bool did_insert = insert_result.second; 670 const bool did_insert = insert_result.second;
671 if (did_insert) { 671 if (did_insert) {
672 // There was no active entry corresponding to this hash. We've already put 672 // There was no active entry corresponding to this hash. We've already put
673 // the entry opened from hash in the |active_entries_|. We now provide the 673 // the entry opened from hash in the |active_entries_|. We now provide the
674 // proxy object to the entry. 674 // proxy object to the entry.
675 it->second->SetActiveEntryProxy(ActiveEntryProxy::Create(hash, this)); 675 it->second->SetActiveEntryProxy(ActiveEntryProxy::Create(hash, this));
676 callback.Run(net::OK); 676 callback.Run(net::OK);
677 } else { 677 } else {
678 // The entry was made active while we waiting for the open from hash to 678 // The entry was made active while we waiting for the open from hash to
679 // finish. The entry created from hash needs to be closed, and the one 679 // finish. The entry created from hash needs to be closed, and the one
680 // in |active_entries_| can be returned to the caller. 680 // in |active_entries_| can be returned to the caller.
681 simple_entry->Close(); 681 simple_entry->Close();
682 it->second->OpenEntry(entry, callback); 682 it->second->OpenEntry(entry, callback);
683 } 683 }
684 } 684 }
685 685
686 void SimpleBackendImpl::OnEntryOpenedFromKey( 686 void SimpleBackendImpl::OnEntryOpenedFromKey(
687 const std::string key, 687 const std::string key,
688 Entry** entry, 688 Entry** entry,
689 scoped_refptr<SimpleEntryImpl> simple_entry, 689 const scoped_refptr<SimpleEntryImpl>& simple_entry,
690 const CompletionCallback& callback, 690 const CompletionCallback& callback,
691 int error_code) { 691 int error_code) {
692 int final_code = error_code; 692 int final_code = error_code;
693 if (final_code == net::OK) { 693 if (final_code == net::OK) {
694 bool key_matches = key.compare(simple_entry->key()) == 0; 694 bool key_matches = key.compare(simple_entry->key()) == 0;
695 if (!key_matches) { 695 if (!key_matches) {
696 // TODO(clamy): Add a unit test to check this code path. 696 // TODO(clamy): Add a unit test to check this code path.
697 DLOG(WARNING) << "Key mismatch on open."; 697 DLOG(WARNING) << "Key mismatch on open.";
698 simple_entry->Doom(); 698 simple_entry->Doom();
699 simple_entry->Close(); 699 simple_entry->Close();
(...skipping 28 matching lines...) Expand all
728 this)); 728 this));
729 callback.Run(result); 729 callback.Run(result);
730 } 730 }
731 731
732 void SimpleBackendImpl::FlushWorkerPoolForTesting() { 732 void SimpleBackendImpl::FlushWorkerPoolForTesting() {
733 if (g_sequenced_worker_pool) 733 if (g_sequenced_worker_pool)
734 g_sequenced_worker_pool->FlushForTesting(); 734 g_sequenced_worker_pool->FlushForTesting();
735 } 735 }
736 736
737 } // namespace disk_cache 737 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.h ('k') | net/disk_cache/simple/simple_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698