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

Side by Side Diff: remoting/host/pairing_registry_delegate_win.cc

Issue 609923004: Cleanup usage of scoped_ptr<> in remoting for C++11 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "remoting/host/pairing_registry_delegate_win.h" 5 #include "remoting/host/pairing_registry_delegate_win.h"
6 6
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 26 matching lines...) Expand all
37 // Reads value |value_name| from |key| as a JSON string and returns it as 37 // Reads value |value_name| from |key| as a JSON string and returns it as
38 // |base::Value|. 38 // |base::Value|.
39 scoped_ptr<base::DictionaryValue> ReadValue(const base::win::RegKey& key, 39 scoped_ptr<base::DictionaryValue> ReadValue(const base::win::RegKey& key,
40 const wchar_t* value_name) { 40 const wchar_t* value_name) {
41 // presubmit: allow wstring 41 // presubmit: allow wstring
42 std::wstring value_json; 42 std::wstring value_json;
43 LONG result = key.ReadValue(value_name, &value_json); 43 LONG result = key.ReadValue(value_name, &value_json);
44 if (result != ERROR_SUCCESS) { 44 if (result != ERROR_SUCCESS) {
45 SetLastError(result); 45 SetLastError(result);
46 PLOG(ERROR) << "Cannot read value '" << value_name << "'"; 46 PLOG(ERROR) << "Cannot read value '" << value_name << "'";
47 return scoped_ptr<base::DictionaryValue>(); 47 return nullptr;
48 } 48 }
49 49
50 // Parse the value. 50 // Parse the value.
51 std::string value_json_utf8 = base::WideToUTF8(value_json); 51 std::string value_json_utf8 = base::WideToUTF8(value_json);
52 JSONStringValueSerializer serializer(&value_json_utf8); 52 JSONStringValueSerializer serializer(&value_json_utf8);
53 int error_code; 53 int error_code;
54 std::string error_message; 54 std::string error_message;
55 scoped_ptr<base::Value> value(serializer.Deserialize(&error_code, 55 scoped_ptr<base::Value> value(serializer.Deserialize(&error_code,
56 &error_message)); 56 &error_message));
57 if (!value) { 57 if (!value) {
58 LOG(ERROR) << "Failed to parse '" << value_name << "': " << error_message 58 LOG(ERROR) << "Failed to parse '" << value_name << "': " << error_message
59 << " (" << error_code << ")."; 59 << " (" << error_code << ").";
60 return scoped_ptr<base::DictionaryValue>(); 60 return nullptr;
61 } 61 }
62 62
63 if (value->GetType() != base::Value::TYPE_DICTIONARY) { 63 if (value->GetType() != base::Value::TYPE_DICTIONARY) {
64 LOG(ERROR) << "Failed to parse '" << value_name << "': not a dictionary."; 64 LOG(ERROR) << "Failed to parse '" << value_name << "': not a dictionary.";
65 return scoped_ptr<base::DictionaryValue>(); 65 return nullptr;
66 } 66 }
67 67
68 return scoped_ptr<base::DictionaryValue>( 68 return scoped_ptr<base::DictionaryValue>(
69 static_cast<base::DictionaryValue*>(value.release())); 69 static_cast<base::DictionaryValue*>(value.release()));
70 } 70 }
71 71
72 // Serializes |value| into a JSON string and writes it as value |value_name| 72 // Serializes |value| into a JSON string and writes it as value |value_name|
73 // under |key|. 73 // under |key|.
74 bool WriteValue(base::win::RegKey& key, 74 bool WriteValue(base::win::RegKey& key,
75 const wchar_t* value_name, 75 const wchar_t* value_name,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 return true; 262 return true;
263 } 263 }
264 264
265 scoped_ptr<PairingRegistry::Delegate> CreatePairingRegistryDelegate() { 265 scoped_ptr<PairingRegistry::Delegate> CreatePairingRegistryDelegate() {
266 return scoped_ptr<PairingRegistry::Delegate>( 266 return scoped_ptr<PairingRegistry::Delegate>(
267 new PairingRegistryDelegateWin()); 267 new PairingRegistryDelegateWin());
268 } 268 }
269 269
270 } // namespace remoting 270 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698