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

Side by Side Diff: chrome/browser/extensions/api/gcd_private/privet_v3_session.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return response.GetString(key, &base64) && base::Base64Decode(base64, value); 71 return response.GetString(key, &base64) && base::Base64Decode(base64, value);
72 } 72 }
73 73
74 bool ContainsString(const base::DictionaryValue& dictionary, 74 bool ContainsString(const base::DictionaryValue& dictionary,
75 const std::string& key, 75 const std::string& key,
76 const std::string& expected_value) { 76 const std::string& expected_value) {
77 const base::ListValue* list_of_string = nullptr; 77 const base::ListValue* list_of_string = nullptr;
78 if (!dictionary.GetList(key, &list_of_string)) 78 if (!dictionary.GetList(key, &list_of_string))
79 return false; 79 return false;
80 80
81 for (const base::Value* value : *list_of_string) { 81 for (const auto& value : *list_of_string) {
82 std::string string_value; 82 std::string string_value;
83 if (value->GetAsString(&string_value) && string_value == expected_value) 83 if (value->GetAsString(&string_value) && string_value == expected_value)
84 return true; 84 return true;
85 } 85 }
86 return false; 86 return false;
87 } 87 }
88 88
89 std::unique_ptr<base::DictionaryValue> GetJson(const net::URLFetcher* source) { 89 std::unique_ptr<base::DictionaryValue> GetJson(const net::URLFetcher* source) {
90 if (!source->GetStatus().is_success()) 90 if (!source->GetStatus().is_success())
91 return nullptr; 91 return nullptr;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // Only session with pairing in process needs to be canceled. Paired sessions 507 // Only session with pairing in process needs to be canceled. Paired sessions
508 // (in https mode) does not need to be canceled. 508 // (in https mode) does not need to be canceled.
509 if (session_id_.empty() || use_https_) 509 if (session_id_.empty() || use_https_)
510 return; 510 return;
511 base::DictionaryValue input; 511 base::DictionaryValue input;
512 input.SetString(kPrivetV3KeySessionId, session_id_); 512 input.SetString(kPrivetV3KeySessionId, session_id_);
513 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback()); 513 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback());
514 } 514 }
515 515
516 } // namespace extensions 516 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698