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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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/http/mock_http_cache.cc ('k') | net/http/transport_security_state.cc » ('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/http/transport_security_persister.h" 5 #include "net/http/transport_security_persister.h"
6 6
7 #include <utility>
8
7 #include "base/base64.h" 9 #include "base/base64.h"
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
11 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
13 #include "base/location.h" 15 #include "base/location.h"
14 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
15 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
16 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 serialized->SetString(kMode, kForceHTTPS); 157 serialized->SetString(kMode, kForceHTTPS);
156 break; 158 break;
157 case TransportSecurityState::STSState::MODE_DEFAULT: 159 case TransportSecurityState::STSState::MODE_DEFAULT:
158 serialized->SetString(kMode, kDefault); 160 serialized->SetString(kMode, kDefault);
159 break; 161 break;
160 default: 162 default:
161 NOTREACHED() << "STSState with unknown mode"; 163 NOTREACHED() << "STSState with unknown mode";
162 continue; 164 continue;
163 } 165 }
164 166
165 toplevel.Set(key, serialized.Pass()); 167 toplevel.Set(key, std::move(serialized));
166 } 168 }
167 169
168 TransportSecurityState::PKPStateIterator pkp_iterator( 170 TransportSecurityState::PKPStateIterator pkp_iterator(
169 *transport_security_state_); 171 *transport_security_state_);
170 for (; pkp_iterator.HasNext(); pkp_iterator.Advance()) { 172 for (; pkp_iterator.HasNext(); pkp_iterator.Advance()) {
171 const std::string& hostname = pkp_iterator.hostname(); 173 const std::string& hostname = pkp_iterator.hostname();
172 const TransportSecurityState::PKPState& pkp_state = 174 const TransportSecurityState::PKPState& pkp_state =
173 pkp_iterator.domain_state(); 175 pkp_iterator.domain_state();
174 176
175 // See if the current |hostname| already has STS state and, if so, update 177 // See if the current |hostname| already has STS state and, if so, update
176 // that entry. 178 // that entry.
177 const std::string key = HashedDomainToExternalString(hostname); 179 const std::string key = HashedDomainToExternalString(hostname);
178 base::DictionaryValue* serialized = nullptr; 180 base::DictionaryValue* serialized = nullptr;
179 if (!toplevel.GetDictionary(key, &serialized)) { 181 if (!toplevel.GetDictionary(key, &serialized)) {
180 scoped_ptr<base::DictionaryValue> serialized_scoped( 182 scoped_ptr<base::DictionaryValue> serialized_scoped(
181 new base::DictionaryValue); 183 new base::DictionaryValue);
182 serialized = serialized_scoped.get(); 184 serialized = serialized_scoped.get();
183 PopulateEntryWithDefaults(serialized); 185 PopulateEntryWithDefaults(serialized);
184 toplevel.Set(key, serialized_scoped.Pass()); 186 toplevel.Set(key, std::move(serialized_scoped));
185 } 187 }
186 188
187 serialized->SetBoolean(kPkpIncludeSubdomains, pkp_state.include_subdomains); 189 serialized->SetBoolean(kPkpIncludeSubdomains, pkp_state.include_subdomains);
188 serialized->SetDouble(kPkpObserved, pkp_state.last_observed.ToDoubleT()); 190 serialized->SetDouble(kPkpObserved, pkp_state.last_observed.ToDoubleT());
189 serialized->SetDouble(kDynamicSPKIHashesExpiry, 191 serialized->SetDouble(kDynamicSPKIHashesExpiry,
190 pkp_state.expiry.ToDoubleT()); 192 pkp_state.expiry.ToDoubleT());
191 193
192 // TODO(svaldez): Historically, both SHA-1 and SHA-256 hashes were 194 // TODO(svaldez): Historically, both SHA-1 and SHA-256 hashes were
193 // accepted in pins. Per spec, only SHA-256 is accepted now, however 195 // accepted in pins. Per spec, only SHA-256 is accepted now, however
194 // existing serialized pins are still processed. Migrate historical pins 196 // existing serialized pins are still processed. Migrate historical pins
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 bool dirty = false; 375 bool dirty = false;
374 if (!LoadEntries(state, &dirty)) { 376 if (!LoadEntries(state, &dirty)) {
375 LOG(ERROR) << "Failed to deserialize state: " << state; 377 LOG(ERROR) << "Failed to deserialize state: " << state;
376 return; 378 return;
377 } 379 }
378 if (dirty) 380 if (dirty)
379 StateIsDirty(transport_security_state_); 381 StateIsDirty(transport_security_state_);
380 } 382 }
381 383
382 } // namespace net 384 } // namespace net
OLDNEW
« no previous file with comments | « net/http/mock_http_cache.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698