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

Side by Side Diff: jingle/notifier/listener/notification_defines.cc

Issue 100823007: Stop doing unnecessary UTF-8 to UTF-16 conversions in JSONWriter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS page encodings Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.cc ('k') | net/base/net_util.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 "jingle/notifier/listener/notification_defines.h" 5 #include "jingle/notifier/listener/notification_defines.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 Notification::~Notification() {} 58 Notification::~Notification() {}
59 59
60 bool Notification::Equals(const Notification& other) const { 60 bool Notification::Equals(const Notification& other) const {
61 return 61 return
62 channel == other.channel && 62 channel == other.channel &&
63 data == other.data && 63 data == other.data &&
64 RecipientListsEqual(recipients, other.recipients); 64 RecipientListsEqual(recipients, other.recipients);
65 } 65 }
66 66
67 std::string Notification::ToString() const { 67 std::string Notification::ToString() const {
68 // |channel| or |data| could hold binary data, so use GetDoubleQuotedJson() 68 // |channel| or |data| could hold binary data, so convert all non-ASCII
69 // to escape them. 69 // characters to escape sequences.
70 const std::string& printable_channel = base::GetDoubleQuotedJson(channel); 70 const std::string& printable_channel =
71 const std::string& printable_data = base::GetDoubleQuotedJson(data); 71 base::EscapeBytesAsInvalidJSONString(channel, true /* put_in_quotes */);
72 const std::string& printable_data =
73 base::EscapeBytesAsInvalidJSONString(data, true /* put_in_quotes */);
72 return 74 return
73 "{ channel: " + printable_channel + ", data: " + printable_data + " }"; 75 "{ channel: " + printable_channel + ", data: " + printable_data + " }";
74 } 76 }
75 77
76 } // namespace notifier 78 } // namespace notifier
OLDNEW
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698