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

Side by Side Diff: components/domain_reliability/context_manager.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/domain_reliability/context_manager.h" 5 #include "components/domain_reliability/context_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 namespace domain_reliability { 9 namespace domain_reliability {
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void DomainReliabilityContextManager::RemoveAllContexts() { 92 void DomainReliabilityContextManager::RemoveAllContexts() {
93 STLDeleteContainerPairSecondPointers( 93 STLDeleteContainerPairSecondPointers(
94 contexts_.begin(), contexts_.end()); 94 contexts_.begin(), contexts_.end());
95 contexts_.clear(); 95 contexts_.clear();
96 } 96 }
97 97
98 std::unique_ptr<base::Value> DomainReliabilityContextManager::GetWebUIData() 98 std::unique_ptr<base::Value> DomainReliabilityContextManager::GetWebUIData()
99 const { 99 const {
100 std::unique_ptr<base::ListValue> contexts_value(new base::ListValue()); 100 std::unique_ptr<base::ListValue> contexts_value(new base::ListValue());
101 for (const auto& context_entry : contexts_) 101 for (const auto& context_entry : contexts_)
102 contexts_value->Append(context_entry.second->GetWebUIData().release()); 102 contexts_value->Append(context_entry.second->GetWebUIData());
103 return std::move(contexts_value); 103 return std::move(contexts_value);
104 } 104 }
105 105
106 DomainReliabilityContext* DomainReliabilityContextManager::GetContextForHost( 106 DomainReliabilityContext* DomainReliabilityContextManager::GetContextForHost(
107 const std::string& host) { 107 const std::string& host) {
108 ContextMap::const_iterator context_it; 108 ContextMap::const_iterator context_it;
109 109
110 context_it = contexts_.find(host); 110 context_it = contexts_.find(host);
111 if (context_it != contexts_.end()) 111 if (context_it != contexts_.end())
112 return context_it->second; 112 return context_it->second;
113 113
114 size_t dot_pos = host.find('.'); 114 size_t dot_pos = host.find('.');
115 if (dot_pos == std::string::npos) 115 if (dot_pos == std::string::npos)
116 return nullptr; 116 return nullptr;
117 117
118 // TODO(juliatuttle): Make sure parent is not in PSL before using. 118 // TODO(juliatuttle): Make sure parent is not in PSL before using.
119 119
120 std::string parent_host = host.substr(dot_pos + 1); 120 std::string parent_host = host.substr(dot_pos + 1);
121 context_it = contexts_.find(parent_host); 121 context_it = contexts_.find(parent_host);
122 if (context_it != contexts_.end() 122 if (context_it != contexts_.end()
123 && context_it->second->config().include_subdomains) { 123 && context_it->second->config().include_subdomains) {
124 return context_it->second; 124 return context_it->second;
125 } 125 }
126 126
127 return nullptr; 127 return nullptr;
128 } 128 }
129 129
130 } // namespace domain_reliability 130 } // namespace domain_reliability
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698