summaryrefslogtreecommitdiffstats
path: root/url/mojo/url_gurl_struct_traits.h
diff options
context:
space:
mode:
authorjam <jam@chromium.org>2016-03-03 20:00:49 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-04 04:03:35 +0000
commit48bad7d8bdba983529cbdba6713ed94e89d15598 (patch)
tree50fd88d1f4fd08f65d78e420f624a7172122efb8 /url/mojo/url_gurl_struct_traits.h
parent62f11383f7caf145bbb3cb7c336c3fea14558eaf (diff)
downloadchromium_src-48bad7d8bdba983529cbdba6713ed94e89d15598.zip
chromium_src-48bad7d8bdba983529cbdba6713ed94e89d15598.tar.gz
chromium_src-48bad7d8bdba983529cbdba6713ed94e89d15598.tar.bz2
Add mojo struct traits for url::Origin so that it can be sent over mojoms.
BUG=586194 Review URL: https://codereview.chromium.org/1760333002 Cr-Commit-Position: refs/heads/master@{#379200}
Diffstat (limited to 'url/mojo/url_gurl_struct_traits.h')
-rw-r--r--url/mojo/url_gurl_struct_traits.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/url/mojo/url_gurl_struct_traits.h b/url/mojo/url_gurl_struct_traits.h
index 1894baf..4bad7d7 100644
--- a/url/mojo/url_gurl_struct_traits.h
+++ b/url/mojo/url_gurl_struct_traits.h
@@ -2,20 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef URL_MOJO_URL_GURL_STRUCT_TRAITS_H_
+#define URL_MOJO_URL_GURL_STRUCT_TRAITS_H_
+
#include "base/strings/string_piece.h"
#include "url/gurl.h"
#include "url/mojo/url.mojom.h"
+#include "url/url_constants.h"
namespace mojo {
-// copied from content/public/common/content_constants.cc: make that file use
-// this definition.
-const size_t kMaxUrlChars = 2 * 1024 * 1024;
-
template <>
struct StructTraits<url::mojom::Url, GURL> {
static base::StringPiece url(const GURL& r) {
- if (r.possibly_invalid_spec().length() > kMaxUrlChars || !r.is_valid()) {
+ if (r.possibly_invalid_spec().length() > url::kMaxURLChars ||
+ !r.is_valid()) {
return base::StringPiece();
}
@@ -23,7 +24,7 @@ struct StructTraits<url::mojom::Url, GURL> {
r.possibly_invalid_spec().length());
}
static bool Read(url::mojom::Url::Reader r, GURL* out) {
- if (r.url().length() > kMaxUrlChars) {
+ if (r.url().length() > url::kMaxURLChars) {
*out = GURL();
return false;
}
@@ -37,3 +38,5 @@ struct StructTraits<url::mojom::Url, GURL> {
};
}
+
+#endif // URL_MOJO_URL_GURL_STRUCT_TRAITS_H_