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

Side by Side Diff: third_party/WebKit/Source/platform/mojo/KURLStructTraits.h

Issue 2668903003: Replace WTF::emptyString{16Bit}() with a static global (Closed)
Patch Set: Replace WTF::emptyString{16Bit}() with a static global Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef KURLStructTraits_h 5 #ifndef KURLStructTraits_h
6 #define KURLStructTraits_h 6 #define KURLStructTraits_h
7 7
8 #include "platform/weborigin/KURL.h" 8 #include "platform/weborigin/KURL.h"
9 #include "url/mojo/url.mojom-blink.h" 9 #include "url/mojo/url.mojom-blink.h"
10 #include "url/url_constants.h" 10 #include "url/url_constants.h"
11 #include "wtf/text/WTFString.h" 11 #include "wtf/text/WTFString.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 14
15 template <> 15 template <>
16 struct StructTraits<url::mojom::blink::Url::DataView, ::blink::KURL> { 16 struct StructTraits<url::mojom::blink::Url::DataView, ::blink::KURL> {
17 static WTF::String url(const ::blink::KURL& blinkUrl) { 17 static WTF::String url(const ::blink::KURL& blinkUrl) {
18 if (!blinkUrl.isValid() || 18 if (!blinkUrl.isValid() ||
19 blinkUrl.getString().length() > url::kMaxURLChars) { 19 blinkUrl.getString().length() > url::kMaxURLChars) {
20 return emptyString(); 20 return emptyString;
21 } 21 }
22 22
23 return blinkUrl.getString(); 23 return blinkUrl.getString();
24 } 24 }
25 static bool Read(url::mojom::blink::Url::DataView data, ::blink::KURL* out) { 25 static bool Read(url::mojom::blink::Url::DataView data, ::blink::KURL* out) {
26 WTF::String urlString; 26 WTF::String urlString;
27 if (!data.ReadUrl(&urlString)) 27 if (!data.ReadUrl(&urlString))
28 return false; 28 return false;
29 29
30 if (urlString.length() > url::kMaxURLChars) 30 if (urlString.length() > url::kMaxURLChars)
31 return false; 31 return false;
32 32
33 *out = ::blink::KURL(::blink::KURL(), urlString); 33 *out = ::blink::KURL(::blink::KURL(), urlString);
34 if (!urlString.isEmpty() && !out->isValid()) 34 if (!urlString.isEmpty() && !out->isValid())
35 return false; 35 return false;
36 36
37 return true; 37 return true;
38 } 38 }
39 }; 39 };
40 } 40 }
41 41
42 #endif // KURLStructTraits_h 42 #endif // KURLStructTraits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698