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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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 "extensions/browser/api/messaging/native_message_host.h" 5 #include "extensions/browser/api/messaging/native_message_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ProcessEcho(*request); 63 ProcessEcho(*request);
64 } 64 }
65 }; 65 };
66 66
67 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override { 67 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override {
68 return base::ThreadTaskRunnerHandle::Get(); 68 return base::ThreadTaskRunnerHandle::Get();
69 }; 69 };
70 70
71 private: 71 private:
72 void ProcessEcho(const base::DictionaryValue& request) { 72 void ProcessEcho(const base::DictionaryValue& request) {
73 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); 73 base::DictionaryValue response;
74 response->SetInteger("id", ++message_number_); 74 response.SetInteger("id", ++message_number_);
75 response->Set("echo", request.DeepCopy()); 75 response.Set("echo", request.CreateDeepCopy());
76 response->SetString("caller_url", kEchoHostOrigins[0]); 76 response.SetString("caller_url", kEchoHostOrigins[0]);
77 std::string response_string; 77 std::string response_string;
78 base::JSONWriter::Write(response.get(), &response_string); 78 base::JSONWriter::Write(response, &response_string);
79 client_->PostMessageFromNativeHost(response_string); 79 client_->PostMessageFromNativeHost(response_string);
80 } 80 }
81 81
82 int message_number_; 82 int message_number_;
83 Client* client_; 83 Client* client_;
84 84
85 DISALLOW_COPY_AND_ASSIGN(EchoHost); 85 DISALLOW_COPY_AND_ASSIGN(EchoHost);
86 }; 86 };
87 87
88 struct BuiltInHost { 88 struct BuiltInHost {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 *error = kForbiddenError; 166 *error = kForbiddenError;
167 return nullptr; 167 return nullptr;
168 } 168 }
169 } 169 }
170 *error = kNotFoundError; 170 *error = kNotFoundError;
171 return nullptr; 171 return nullptr;
172 } 172 }
173 173
174 } // namespace extensions 174 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698