Internal change

PiperOrigin-RevId: 247953370
Change-Id: I7e7fb17f113d1a0b1e6523c91d32b5f3acea4ca8
diff --git a/src/base/component_export.h b/src/base/component_export.h
new file mode 100644
index 0000000..f2b202f
--- /dev/null
+++ b/src/base/component_export.h
@@ -0,0 +1,68 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#ifndef BASE_COMPONENT_EXPORT_H_
+#define BASE_COMPONENT_EXPORT_H_
+#include "build/build_config.h"
+// Used to annotate symbols which are exported by the component named
+// |component|. Note that this only does the right thing if the corresponding
+// component target's sources are compiled with |IS_$component_IMPL| defined
+// as 1. For example:
+//
+//   class COMPONENT_EXPORT(FOO) Bar {};
+//
+// If IS_FOO_IMPL=1 at compile time, then Bar will be annotated using the
+// COMPONENT_EXPORT_ANNOTATION macro defined below. Otherwise it will be
+// annotated using the COMPONENT_IMPORT_ANNOTATION macro.
+#define COMPONENT_EXPORT(component)                         \
+  COMPONENT_MACRO_CONDITIONAL_(IS_##component##_IMPL,       \
+                               COMPONENT_EXPORT_ANNOTATION, \
+                               COMPONENT_IMPORT_ANNOTATION)
+// Indicates whether the current compilation unit is being compiled as part of
+// the implementation of the component named |component|. Expands to |1| if
+// |IS_$component_IMPL| is defined as |1|; expands to |0| otherwise.
+//
+// Note in particular that if |IS_$component_IMPL| is not defined at all, it is
+// still fine to test INSIDE_COMPONENT_IMPL(component), which expands to |0| as
+// expected.
+#define INSIDE_COMPONENT_IMPL(component) \
+  COMPONENT_MACRO_CONDITIONAL_(IS_##component##_IMPL, 1, 0)
+// Compiler-specific macros to annotate for export or import of a symbol. No-op
+// in non-component builds. These should not see much if any direct use.
+// Instead use the COMPONENT_EXPORT macro defined above.
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+#define COMPONENT_EXPORT_ANNOTATION __declspec(dllexport)
+#define COMPONENT_IMPORT_ANNOTATION __declspec(dllimport)
+#else  // defined(WIN32)
+#define COMPONENT_EXPORT_ANNOTATION __attribute__((visibility("default")))
+#define COMPONENT_IMPORT_ANNOTATION
+#endif  // defined(WIN32)
+#else   // defined(COMPONENT_BUILD)
+#define COMPONENT_EXPORT_ANNOTATION
+#define COMPONENT_IMPORT_ANNOTATION
+#endif  // defined(COMPONENT_BUILD)
+// Below this point are several internal utility macros used for the
+// implementation of the above macros. Not intended for external use.
+// Helper for conditional expansion to one of two token strings. If |condition|
+// expands to |1| then this macro expands to |consequent|; otherwise it expands
+// to |alternate|.
+#define COMPONENT_MACRO_CONDITIONAL_(condition, consequent, alternate) \
+  COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_(                              \
+      COMPONENT_MACRO_CONDITIONAL_COMMA_(condition), consequent, alternate)
+// Expands to a comma (,) iff its first argument expands to |1|. Used in
+// conjunction with |COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_()|, as the presence
+// or absense of an extra comma can be used to conditionally shift subsequent
+// argument positions and thus influence which argument is selected.
+#define COMPONENT_MACRO_CONDITIONAL_COMMA_(...) \
+  COMPONENT_MACRO_CONDITIONAL_COMMA_IMPL_(__VA_ARGS__,)
+#define COMPONENT_MACRO_CONDITIONAL_COMMA_IMPL_(x, ...) \
+  COMPONENT_MACRO_CONDITIONAL_COMMA_##x##_
+#define COMPONENT_MACRO_CONDITIONAL_COMMA_1_ ,
+// Helper which simply selects its third argument. Used in conjunction with
+// |COMPONENT_MACRO_CONDITIONAL_COMMA_()| above to implement conditional macro
+// expansion.
+#define COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_(...) \
+  COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_IMPL_(__VA_ARGS__)
+#define COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_IMPL_(a, b, c, ...) c
+#endif  // BASE_COMPONENT_EXPORT_H_
diff --git a/src/url/third_party/mozilla/url_parse.cc b/src/url/third_party/mozilla/url_parse.cc
index d77fb5f..bf4396d 100644
--- a/src/url/third_party/mozilla/url_parse.cc
+++ b/src/url/third_party/mozilla/url_parse.cc
@@ -33,25 +33,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
-
 #include "url/third_party/mozilla/url_parse.h"
-
 #include <stdlib.h>
-
 #include "base/logging.h"
 #include "url/url_parse_internal.h"
 #include "url/url_util.h"
 #include "url/url_util_internal.h"
-
 namespace url {
-
 namespace {
-
 // Returns true if the given character is a valid digit to use in a port.
 inline bool IsPortDigit(base::char16 ch) {
   return ch >= '0' && ch <= '9';
 }
-
 // Returns the offset of the next authority terminator in the input starting
 // from start_offset. If no terminator is found, the return value will be equal
 // to spec_len.
@@ -65,7 +58,6 @@
   }
   return spec_len;  // Not found.
 }
-
 template<typename CHAR>
 void ParseUserInfo(const CHAR* spec,
                    const Component& user,
@@ -76,7 +68,6 @@
   int colon_offset = 0;
   while (colon_offset < user.len && spec[user.begin + colon_offset] != ':')
     colon_offset++;
-
   if (colon_offset < user.len) {
     // Found separator: <username>:<password>
     *username = Component(user.begin, colon_offset);
@@ -88,7 +79,6 @@
     *password = Component();
   }
 }
-
 template<typename CHAR>
 void ParseServerInfo(const CHAR* spec,
                      const Component& serverinfo,
@@ -100,7 +90,6 @@
     port_num->reset();
     return;
   }
-
   // If the host starts with a left-bracket, assume the entire host is an
   // IPv6 literal.  Otherwise, assume none of the host is an IPv6 literal.
   // This assumption will be overridden if we find a right-bracket.
@@ -109,7 +98,6 @@
   // but the ability to locate an incomplete address can still be useful.
   int ipv6_terminator = spec[serverinfo.begin] == '[' ? serverinfo.end() : -1;
   int colon = -1;
-
   // Find the last right-bracket, and the last colon.
   for (int i = serverinfo.begin; i < serverinfo.end(); i++) {
     switch (spec[i]) {
@@ -121,7 +109,6 @@
         break;
     }
   }
-
   if (colon > ipv6_terminator) {
     // Found a port number: <hostname>:<port>
     *hostname = MakeRange(serverinfo.begin, colon);
@@ -134,7 +121,6 @@
     port_num->reset();
   }
 }
-
 // Given an already-identified auth section, breaks it into its consituent
 // parts. The port number will be parsed and the resulting integer will be
 // filled into the given *port variable, or -1 if there is no port number or it
@@ -154,13 +140,11 @@
     port_num->reset();
     return;
   }
-
   // Search backwards for @, which is the separator between the user info and
   // the server info.
   int i = auth.begin + auth.len - 1;
   while (i > auth.begin && spec[i] != '@')
     i--;
-
   if (spec[i] == '@') {
     // Found user info: <user-info>@<server-info>
     ParseUserInfo(spec, Component(auth.begin, i - auth.begin),
@@ -174,7 +158,6 @@
     ParseServerInfo(spec, auth, hostname, port_num);
   }
 }
-
 template <typename CHAR>
 inline void FindQueryAndRefParts(const CHAR* spec,
                           const Component& path,
@@ -199,7 +182,6 @@
     }
   }
 }
-
 template<typename CHAR>
 void ParsePath(const CHAR* spec,
                const Component& path,
@@ -207,7 +189,6 @@
                Component* query,
                Component* ref) {
   // path = [/]<segment1>/<segment2>/<...>/<segmentN>;<param>?<query>#<ref>
-
   // Special case when there is no path.
   if (path.len == -1) {
     filepath->reset();
@@ -216,17 +197,14 @@
     return;
   }
   DCHECK(path.len > 0) << "We should never have 0 length paths";
-
   // Search for first occurrence of either ? or #.
   int query_separator = -1;  // Index of the '?'
   int ref_separator = -1;    // Index of the '#'
   FindQueryAndRefParts(spec, path, &query_separator, &ref_separator);
-
   // Markers pointing to the character after each of these corresponding
   // components. The code below words from the end back to the beginning,
   // and will update these indices as it finds components that exist.
   int file_end, query_end;
-
   // Ref fragment: from the # to the end of the path.
   int path_end = path.begin + path.len;
   if (ref_separator >= 0) {
@@ -236,7 +214,6 @@
     file_end = query_end = path_end;
     ref->reset();
   }
-
   // Query fragment: everything from the ? to the next boundary (either the end
   // of the path or the ref fragment).
   if (query_separator >= 0) {
@@ -245,14 +222,12 @@
   } else {
     query->reset();
   }
-
   // File path: treat an empty file path as no file path.
   if (file_end != path.begin)
     *filepath = MakeRange(path.begin, file_end);
   else
     filepath->reset();
 }
-
 template<typename CHAR>
 bool DoExtractScheme(const CHAR* url,
                      int url_len,
@@ -263,7 +238,6 @@
     begin++;
   if (begin == url_len)
     return false;  // Input is empty or all whitespace.
-
   // Find the first colon character.
   for (int i = begin; i < url_len; i++) {
     if (url[i] == ':') {
@@ -273,7 +247,6 @@
   }
   return false;  // No colon found: no scheme
 }
-
 // Fills in all members of the Parsed structure except for the scheme.
 //
 // |spec| is the full spec being parsed, of length |spec_len|.
@@ -299,39 +272,32 @@
                         Parsed* parsed) {
   int num_slashes = CountConsecutiveSlashes(spec, after_scheme, spec_len);
   int after_slashes = after_scheme + num_slashes;
-
   // First split into two main parts, the authority (username, password, host,
   // and port) and the full path (path, query, and reference).
   Component authority;
   Component full_path;
-
   // Found "//<some data>", looks like an authority section. Treat everything
   // from there to the next slash (or end of spec) to be the authority. Note
   // that we ignore the number of slashes and treat it as the authority.
   int end_auth = FindNextAuthorityTerminator(spec, after_slashes, spec_len);
   authority = Component(after_slashes, end_auth - after_slashes);
-
   if (end_auth == spec_len)  // No beginning of path found.
     full_path = Component();
   else  // Everything starting from the slash to the end is the path.
     full_path = Component(end_auth, spec_len - end_auth);
-
   // Now parse those two sub-parts.
   DoParseAuthority(spec, authority, &parsed->username, &parsed->password,
                    &parsed->host, &parsed->port);
   ParsePath(spec, full_path, &parsed->path, &parsed->query, &parsed->ref);
 }
-
 // The main parsing function for standard URLs. Standard URLs have a scheme,
 // host, path, etc.
 template<typename CHAR>
 void DoParseStandardURL(const CHAR* spec, int spec_len, Parsed* parsed) {
   DCHECK(spec_len >= 0);
-
   // Strip leading & trailing spaces and control characters.
   int begin = 0;
   TrimURL(spec, &begin, &spec_len);
-
   int after_scheme;
   if (DoExtractScheme(spec, spec_len, &parsed->scheme)) {
     after_scheme = parsed->scheme.end() + 1;  // Skip past the colon.
@@ -344,12 +310,9 @@
   }
   DoParseAfterScheme(spec, spec_len, after_scheme, parsed);
 }
-
-#ifndef NO_FILESYSTEMURL_SUPPORT
 template<typename CHAR>
 void DoParseFileSystemURL(const CHAR* spec, int spec_len, Parsed* parsed) {
   DCHECK(spec_len >= 0);
-
   // Get the unused parts of the URL out of the way.
   parsed->username.reset();
   parsed->password.reset();
@@ -359,42 +322,33 @@
   parsed->ref.reset();    // May use this; reset for convenience.
   parsed->query.reset();  // May use this; reset for convenience.
   parsed->clear_inner_parsed();  // May use this; reset for convenience.
-
   // Strip leading & trailing spaces and control characters.
   int begin = 0;
   TrimURL(spec, &begin, &spec_len);
-
   // Handle empty specs or ones that contain only whitespace or control chars.
   if (begin == spec_len) {
     parsed->scheme.reset();
     return;
   }
-
   int inner_start = -1;
-
   // Extract the scheme.  We also handle the case where there is no scheme.
   if (DoExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) {
     // Offset the results since we gave ExtractScheme a substring.
     parsed->scheme.begin += begin;
-
     if (parsed->scheme.end() == spec_len - 1)
       return;
-
     inner_start = parsed->scheme.end() + 1;
   } else {
     // No scheme found; that's not valid for filesystem URLs.
     parsed->scheme.reset();
     return;
   }
-
   Component inner_scheme;
   const CHAR* inner_spec = &spec[inner_start];
   int inner_spec_len = spec_len - inner_start;
-
   if (DoExtractScheme(inner_spec, inner_spec_len, &inner_scheme)) {
     // Offset the results since we gave ExtractScheme a substring.
     inner_scheme.begin += inner_start;
-
     if (inner_scheme.end() == spec_len - 1)
       return;
   } else {
@@ -402,9 +356,7 @@
     // The best we can do is return "filesystem://".
     return;
   }
-
   Parsed inner_parsed;
-
   if (CompareSchemeComponent(spec, inner_scheme, kFileScheme)) {
     // File URLs are special.
     ParseFileURL(inner_spec, inner_spec_len, &inner_parsed);
@@ -417,7 +369,6 @@
   } else {
     return;
   }
-
   // All members of inner_parsed need to be offset by inner_start.
   // If we had any scheme that supported nesting more than one level deep,
   // we'd have to recurse into the inner_parsed's inner_parsed when
@@ -430,19 +381,16 @@
   inner_parsed.query.begin += inner_start;
   inner_parsed.ref.begin += inner_start;
   inner_parsed.path.begin += inner_start;
-
   // Query and ref move from inner_parsed to parsed.
   parsed->query = inner_parsed.query;
   inner_parsed.query.reset();
   parsed->ref = inner_parsed.ref;
   inner_parsed.ref.reset();
-
   parsed->set_inner_parsed(inner_parsed);
   if (!inner_parsed.scheme.is_valid() || !inner_parsed.path.is_valid() ||
       inner_parsed.inner_parsed()) {
     return;
   }
-
   // The path in inner_parsed should start with a slash, then have a filesystem
   // type followed by a slash.  From the first slash up to but excluding the
   // second should be what it keeps; the rest goes to parsed.  If the path ends
@@ -460,8 +408,6 @@
   parsed->path.len = inner_parsed.path.len - new_inner_path_length;
   parsed->inner_parsed()->path.len = new_inner_path_length;
 }
-#endif
-
 // Initializes a path URL which is merely a scheme followed by a path. Examples
 // include "about:foo" and "javascript:alert('bar');"
 template<typename CHAR>
@@ -477,18 +423,15 @@
   parsed->path.reset();
   parsed->query.reset();
   parsed->ref.reset();
-
   // Strip leading & trailing spaces and control characters.
   int scheme_begin = 0;
   TrimURL(spec, &scheme_begin, &spec_len, trim_path_end);
-
   // Handle empty specs or ones that contain only whitespace or control chars.
   if (scheme_begin == spec_len) {
     parsed->scheme.reset();
     parsed->path.reset();
     return;
   }
-
   int path_begin;
   // Extract the scheme, with the path being everything following. We also
   // handle the case where there is no scheme.
@@ -502,22 +445,18 @@
     parsed->scheme.reset();
     path_begin = scheme_begin;
   }
-
   if (path_begin == spec_len)
     return;
   DCHECK_LT(path_begin, spec_len);
-
   ParsePath(spec,
             MakeRange(path_begin, spec_len),
             &parsed->path,
             &parsed->query,
             &parsed->ref);
 }
-
 template<typename CHAR>
 void DoParseMailtoURL(const CHAR* spec, int spec_len, Parsed* parsed) {
   DCHECK(spec_len >= 0);
-
   // Get the non-path and non-scheme parts of the URL out of the way, we never
   // use them.
   parsed->username.reset();
@@ -526,27 +465,22 @@
   parsed->port.reset();
   parsed->ref.reset();
   parsed->query.reset();  // May use this; reset for convenience.
-
   // Strip leading & trailing spaces and control characters.
   int begin = 0;
   TrimURL(spec, &begin, &spec_len);
-
   // Handle empty specs or ones that contain only whitespace or control chars.
   if (begin == spec_len) {
     parsed->scheme.reset();
     parsed->path.reset();
     return;
   }
-
   int path_begin = -1;
   int path_end = -1;
-
   // Extract the scheme, with the path being everything following. We also
   // handle the case where there is no scheme.
   if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) {
     // Offset the results since we gave ExtractScheme a substring.
     parsed->scheme.begin += begin;
-
     if (parsed->scheme.end() != spec_len - 1) {
       path_begin = parsed->scheme.end() + 1;
       path_end = spec_len;
@@ -557,7 +491,6 @@
     path_begin = begin;
     path_end = spec_len;
   }
-
   // Split [path_begin, path_end) into a path + query.
   for (int i = path_begin; i < path_end; ++i) {
     if (spec[i] == '?') {
@@ -566,7 +499,6 @@
       break;
     }
   }
-
   // For compatability with the standard URL parser, treat no path as
   // -1, rather than having a length of 0
   if (path_begin == path_end) {
@@ -575,7 +507,6 @@
     parsed->path = MakeRange(path_begin, path_end);
   }
 }
-
 // Converts a port number in a string to an integer. We'd like to just call
 // sscanf but our input is not NULL-terminated, which sscanf requires. Instead,
 // we copy the digits to a small stack buffer (since we know the maximum number
@@ -586,7 +517,6 @@
   const int kMaxDigits = 5;
   if (!component.is_nonempty())
     return PORT_UNSPECIFIED;
-
   // Skip over any leading 0s.
   Component digits_comp(component.end(), 0);
   for (int i = 0; i < component.len; i++) {
@@ -597,12 +527,10 @@
   }
   if (digits_comp.len == 0)
     return 0;  // All digits were 0.
-
   // Verify we don't have too many digits (we'll be copying to our buffer so
   // we need to double-check).
   if (digits_comp.len > kMaxDigits)
     return PORT_INVALID;
-
   // Copy valid digits to the buffer.
   char digits[kMaxDigits + 1];  // +1 for null terminator
   for (int i = 0; i < digits_comp.len; i++) {
@@ -613,7 +541,6 @@
     }
     digits[i] = static_cast<char>(ch);
   }
-
   // Null-terminate the string and convert to integer. Since we guarantee
   // only digits, atoi's lack of error handling is OK.
   digits[digits_comp.len] = 0;
@@ -622,7 +549,6 @@
     return PORT_INVALID;  // Out of range.
   return port;
 }
-
 template<typename CHAR>
 void DoExtractFileName(const CHAR* spec,
                        const Component& path,
@@ -632,7 +558,6 @@
     file_name->reset();
     return;
   }
-
   // Extract the filename range from the path which is between
   // the last slash and the following semicolon.
   int file_end = path.end();
@@ -645,13 +570,11 @@
       return;
     }
   }
-
   // No slash found, this means the input was degenerate (generally paths
   // will start with a slash). Let's call everything the file name.
   *file_name = MakeRange(path.begin, file_end);
   return;
 }
-
 template<typename CHAR>
 bool DoExtractQueryKeyValue(const CHAR* spec,
                             Component* query,
@@ -659,41 +582,32 @@
                             Component* value) {
   if (!query->is_nonempty())
     return false;
-
   int start = query->begin;
   int cur = start;
   int end = query->end();
-
   // We assume the beginning of the input is the beginning of the "key" and we
   // skip to the end of it.
   key->begin = cur;
   while (cur < end && spec[cur] != '&' && spec[cur] != '=')
     cur++;
   key->len = cur - key->begin;
-
   // Skip the separator after the key (if any).
   if (cur < end && spec[cur] == '=')
     cur++;
-
   // Find the value part.
   value->begin = cur;
   while (cur < end && spec[cur] != '&')
     cur++;
   value->len = cur - value->begin;
-
   // Finally skip the next separator if any
   if (cur < end && spec[cur] == '&')
     cur++;
-
   // Save the new query
   *query = MakeRange(cur, end);
   return true;
 }
-
 }  // namespace
-
 Parsed::Parsed() : potentially_dangling_markup(false), inner_parsed_(NULL) {}
-
 Parsed::Parsed(const Parsed& other)
     : scheme(other.scheme),
       username(other.username),
@@ -708,7 +622,6 @@
   if (other.inner_parsed_)
     set_inner_parsed(*other.inner_parsed_);
 }
-
 Parsed& Parsed::operator=(const Parsed& other) {
   if (this != &other) {
     scheme = other.scheme;
@@ -727,46 +640,38 @@
   }
   return *this;
 }
-
 Parsed::~Parsed() {
   delete inner_parsed_;
 }
-
 int Parsed::Length() const {
   if (ref.is_valid())
     return ref.end();
   return CountCharactersBefore(REF, false);
 }
-
 int Parsed::CountCharactersBefore(ComponentType type,
                                   bool include_delimiter) const {
   if (type == SCHEME)
     return scheme.begin;
-
   // There will be some characters after the scheme like "://" and we don't
   // know how many. Search forwards for the next thing until we find one.
   int cur = 0;
   if (scheme.is_valid())
     cur = scheme.end() + 1;  // Advance over the ':' at the end of the scheme.
-
   if (username.is_valid()) {
     if (type <= USERNAME)
       return username.begin;
     cur = username.end() + 1;  // Advance over the '@' or ':' at the end.
   }
-
   if (password.is_valid()) {
     if (type <= PASSWORD)
       return password.begin;
     cur = password.end() + 1;  // Advance over the '@' at the end.
   }
-
   if (host.is_valid()) {
     if (type <= HOST)
       return host.begin;
     cur = host.end();
   }
-
   if (port.is_valid()) {
     if (type < PORT || (type == PORT && include_delimiter))
       return port.begin - 1;  // Back over delimiter.
@@ -774,13 +679,11 @@
       return port.begin;  // Don't want delimiter counted.
     cur = port.end();
   }
-
   if (path.is_valid()) {
     if (type <= PATH)
       return path.begin;
     cur = path.end();
   }
-
   if (query.is_valid()) {
     if (type < QUERY || (type == QUERY && include_delimiter))
       return query.begin - 1;  // Back over delimiter.
@@ -788,19 +691,15 @@
       return query.begin;  // Don't want delimiter counted.
     cur = query.end();
   }
-
   if (ref.is_valid()) {
     if (type == REF && !include_delimiter)
       return ref.begin;  // Back over delimiter.
-
     // When there is a ref and we get here, the component we wanted was before
     // this and not found, so we always know the beginning of the ref is right.
     return ref.begin - 1;  // Don't want delimiter counted.
   }
-
   return cur;
 }
-
 Component Parsed::GetContent() const {
   const int begin = CountCharactersBefore(USERNAME, false);
   const int len = Length() - begin;
@@ -809,47 +708,39 @@
   // much for these non-standard URLs).
   return len ? Component(begin, len) : Component();
 }
-
 bool ExtractScheme(const char* url, int url_len, Component* scheme) {
   return DoExtractScheme(url, url_len, scheme);
 }
-
 bool ExtractScheme(const base::char16* url, int url_len, Component* scheme) {
   return DoExtractScheme(url, url_len, scheme);
 }
-
 // This handles everything that may be an authority terminator, including
 // backslash. For special backslash handling see DoParseAfterScheme.
 bool IsAuthorityTerminator(base::char16 ch) {
   return IsURLSlash(ch) || ch == '?' || ch == '#';
 }
-
 void ExtractFileName(const char* url,
                      const Component& path,
                      Component* file_name) {
   DoExtractFileName(url, path, file_name);
 }
-
 void ExtractFileName(const base::char16* url,
                      const Component& path,
                      Component* file_name) {
   DoExtractFileName(url, path, file_name);
 }
-
 bool ExtractQueryKeyValue(const char* url,
                           Component* query,
                           Component* key,
                           Component* value) {
   return DoExtractQueryKeyValue(url, query, key, value);
 }
-
 bool ExtractQueryKeyValue(const base::char16* url,
                           Component* query,
                           Component* key,
                           Component* value) {
   return DoExtractQueryKeyValue(url, query, key, value);
 }
-
 void ParseAuthority(const char* spec,
                     const Component& auth,
                     Component* username,
@@ -858,7 +749,6 @@
                     Component* port_num) {
   DoParseAuthority(spec, auth, username, password, hostname, port_num);
 }
-
 void ParseAuthority(const base::char16* spec,
                     const Component& auth,
                     Component* username,
@@ -867,65 +757,42 @@
                     Component* port_num) {
   DoParseAuthority(spec, auth, username, password, hostname, port_num);
 }
-
 int ParsePort(const char* url, const Component& port) {
   return DoParsePort(url, port);
 }
-
 int ParsePort(const base::char16* url, const Component& port) {
   return DoParsePort(url, port);
 }
-
 void ParseStandardURL(const char* url, int url_len, Parsed* parsed) {
   DoParseStandardURL(url, url_len, parsed);
 }
-
 void ParseStandardURL(const base::char16* url, int url_len, Parsed* parsed) {
   DoParseStandardURL(url, url_len, parsed);
 }
-
 void ParsePathURL(const char* url,
                   int url_len,
                   bool trim_path_end,
                   Parsed* parsed) {
   DoParsePathURL(url, url_len, trim_path_end, parsed);
 }
-
 void ParsePathURL(const base::char16* url,
                   int url_len,
                   bool trim_path_end,
                   Parsed* parsed) {
   DoParsePathURL(url, url_len, trim_path_end, parsed);
 }
-
 void ParseFileSystemURL(const char* url, int url_len, Parsed* parsed) {
-#ifndef NO_FILESYSTEMURL_SUPPORT
   DoParseFileSystemURL(url, url_len, parsed);
-#else
-  // Should not reach here if the client doesn't want to support file system
-  // URL.
-  DCHECK(false);
-#endif
 }
-
 void ParseFileSystemURL(const base::char16* url, int url_len, Parsed* parsed) {
-#ifndef NO_FILESYSTEMURL_SUPPORT
   DoParseFileSystemURL(url, url_len, parsed);
-#else
-  // Should not reach here if the client doesn't want to support file system
-  // URL.
-  DCHECK(false);
-#endif
 }
-
 void ParseMailtoURL(const char* url, int url_len, Parsed* parsed) {
   DoParseMailtoURL(url, url_len, parsed);
 }
-
 void ParseMailtoURL(const base::char16* url, int url_len, Parsed* parsed) {
   DoParseMailtoURL(url, url_len, parsed);
 }
-
 void ParsePathInternal(const char* spec,
                        const Component& path,
                        Component* filepath,
@@ -933,7 +800,6 @@
                        Component* ref) {
   ParsePath(spec, path, filepath, query, ref);
 }
-
 void ParsePathInternal(const base::char16* spec,
                        const Component& path,
                        Component* filepath,
@@ -941,19 +807,16 @@
                        Component* ref) {
   ParsePath(spec, path, filepath, query, ref);
 }
-
 void ParseAfterScheme(const char* spec,
                       int spec_len,
                       int after_scheme,
                       Parsed* parsed) {
   DoParseAfterScheme(spec, spec_len, after_scheme, parsed);
 }
-
 void ParseAfterScheme(const base::char16* spec,
                       int spec_len,
                       int after_scheme,
                       Parsed* parsed) {
   DoParseAfterScheme(spec, spec_len, after_scheme, parsed);
 }
-
 }  // namespace url
diff --git a/src/url/third_party/mozilla/url_parse.h b/src/url/third_party/mozilla/url_parse.h
index 6d40d3f..2b4fe3e 100644
--- a/src/url/third_party/mozilla/url_parse.h
+++ b/src/url/third_party/mozilla/url_parse.h
@@ -1,61 +1,46 @@
 // Copyright 2013 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
-
 #ifndef URL_THIRD_PARTY_MOZILLA_URL_PARSE_H_
 #define URL_THIRD_PARTY_MOZILLA_URL_PARSE_H_
-
+#include "base/component_export.h"
 #include "base/strings/string16.h"
-#include "url/url_export.h"
-
 namespace url {
-
 // Component ------------------------------------------------------------------
-
 // Represents a substring for URL parsing.
 struct Component {
   Component() : begin(0), len(-1) {}
-
   // Normal constructor: takes an offset and a length.
   Component(int b, int l) : begin(b), len(l) {}
-
   int end() const {
     return begin + len;
   }
-
   // Returns true if this component is valid, meaning the length is given. Even
   // valid components may be empty to record the fact that they exist.
   bool is_valid() const {
     return (len != -1);
   }
-
   // Returns true if the given component is specified on false, the component
   // is either empty or invalid.
   bool is_nonempty() const {
     return (len > 0);
   }
-
   void reset() {
     begin = 0;
     len = -1;
   }
-
   bool operator==(const Component& other) const {
     return begin == other.begin && len == other.len;
   }
-
   int begin;  // Byte offset in the string of this component.
   int len;    // Will be -1 if the component is unspecified.
 };
-
 // Helper that returns a component created with the given begin and ending
 // points. The ending point is non-inclusive.
 inline Component MakeRange(int begin, int end) {
   return Component(begin, end - begin);
 }
-
 // Parsed ---------------------------------------------------------------------
-
 // A structure that holds the identified parts of an input URL. This structure
 // does NOT store the URL itself. The caller will have to store the URL text
 // and its corresponding Parsed structure separately.
@@ -74,7 +59,7 @@
 //    else
 //      ParsePathURL(url, url_len, &parsed);
 //
-struct URL_EXPORT Parsed {
+struct COMPONENT_EXPORT(URL) Parsed {
   // Identifies different components.
   enum ComponentType {
     SCHEME,
@@ -86,14 +71,12 @@
     QUERY,
     REF,
   };
-
   // The default constructor is sufficient for the components, but inner_parsed_
   // requires special handling.
   Parsed();
   Parsed(const Parsed&);
   Parsed& operator=(const Parsed&);
   ~Parsed();
-
   // Returns the length of the URL (the end of the last component).
   //
   // Note that for some invalid, non-canonical URLs, this may not be the length
@@ -101,7 +84,6 @@
   // contain an entry for the four-character scheme, and it doesn't know about
   // the "://". For all other last-components, it will return the real length.
   int Length() const;
-
   // Returns the number of characters before the given component if it exists,
   // or where the component would be if it did exist. This will return the
   // string length if the component would be appended to the end.
@@ -129,29 +111,23 @@
   //        *REF: 20                   20
   //
   int CountCharactersBefore(ComponentType type, bool include_delimiter) const;
-
   // Scheme without the colon: "http://foo"/ would have a scheme of "http".
   // The length will be -1 if no scheme is specified ("foo.com"), or 0 if there
   // is a colon but no scheme (":foo"). Note that the scheme is not guaranteed
   // to start at the beginning of the string if there are preceeding whitespace
   // or control characters.
   Component scheme;
-
   // Username. Specified in URLs with an @ sign before the host. See |password|
   Component username;
-
   // Password. The length will be -1 if unspecified, 0 if specified but empty.
   // Not all URLs with a username have a password, as in "http://me@host/".
   // The password is separated form the username with a colon, as in
   // "http://me:secret@host/"
   Component password;
-
   // Host name.
   Component host;
-
   // Port number.
   Component port;
-
   // Path, this is everything following the host name, stopping at the query of
   // ref delimiter (if any). Length will be -1 if unspecified. This includes
   // the preceeding slash, so the path on http://www.google.com/asdf" is
@@ -159,31 +135,26 @@
   // be -1 in cases like "http://host?foo".
   // Note that we treat backslashes the same as slashes.
   Component path;
-
   // Stuff between the ? and the # after the path. This does not include the
   // preceeding ? character. Length will be -1 if unspecified, 0 if there is
   // a question mark but no query string.
   Component query;
-
   // Indicated by a #, this is everything following the hash sign (not
   // including it). If there are multiple hash signs, we'll use the last one.
   // Length will be -1 if there is no hash sign, or 0 if there is one but
   // nothing follows it.
   Component ref;
-
   // The URL spec from the character after the scheme: until the end of the
   // URL, regardless of the scheme. This is mostly useful for 'opaque' non-
   // hierarchical schemes like data: and javascript: as a convient way to get
   // the string with the scheme stripped off.
   Component GetContent() const;
-
   // True if the URL's source contained a raw `<` character, and whitespace was
   // removed from the URL during parsing
   //
   // TODO(mkwst): Link this to something in a spec if
   // https://github.com/whatwg/url/pull/284 lands.
   bool potentially_dangling_markup;
-
   // This is used for nested URL types, currently only filesystem.  If you
   // parse a filesystem URL, the resulting Parsed will have a nested
   // inner_parsed_ to hold the parsed inner URL's component information.
@@ -191,25 +162,21 @@
   Parsed* inner_parsed() const {
     return inner_parsed_;
   }
-
   void set_inner_parsed(const Parsed& inner_parsed) {
     if (!inner_parsed_)
       inner_parsed_ = new Parsed(inner_parsed);
     else
       *inner_parsed_ = inner_parsed;
   }
-
   void clear_inner_parsed() {
     if (inner_parsed_) {
       delete inner_parsed_;
       inner_parsed_ = NULL;
     }
   }
-
  private:
   Parsed* inner_parsed_;  // This object is owned and managed by this struct.
 };
-
 // Initialization functions ---------------------------------------------------
 //
 // These functions parse the given URL, filling in all of the structure's
@@ -223,53 +190,44 @@
 // in any way. See the comment above the struct.
 //
 // The 8-bit versions require UTF-8 encoding.
-
 // StandardURL is for when the scheme is known to be one that has an
 // authority (host) like "http". This function will not handle weird ones
 // like "about:" and "javascript:", or do the right thing for "file:" URLs.
-URL_EXPORT void ParseStandardURL(const char* url,
-                                 int url_len,
-                                 Parsed* parsed);
-URL_EXPORT void ParseStandardURL(const base::char16* url,
-                                 int url_len,
-                                 Parsed* parsed);
-
+COMPONENT_EXPORT(URL)
+void ParseStandardURL(const char* url, int url_len, Parsed* parsed);
+COMPONENT_EXPORT(URL)
+void ParseStandardURL(const base::char16* url, int url_len, Parsed* parsed);
 // PathURL is for when the scheme is known not to have an authority (host)
 // section but that aren't file URLs either. The scheme is parsed, and
 // everything after the scheme is considered as the path. This is used for
 // things like "about:" and "javascript:"
-URL_EXPORT void ParsePathURL(const char* url,
-                             int url_len,
-                             bool trim_path_end,
-                             Parsed* parsed);
-URL_EXPORT void ParsePathURL(const base::char16* url,
-                             int url_len,
-                             bool trim_path_end,
-                             Parsed* parsed);
-
+COMPONENT_EXPORT(URL)
+void ParsePathURL(const char* url,
+                  int url_len,
+                  bool trim_path_end,
+                  Parsed* parsed);
+COMPONENT_EXPORT(URL)
+void ParsePathURL(const base::char16* url,
+                  int url_len,
+                  bool trim_path_end,
+                  Parsed* parsed);
 // FileURL is for file URLs. There are some special rules for interpreting
 // these.
-URL_EXPORT void ParseFileURL(const char* url, int url_len, Parsed* parsed);
-URL_EXPORT void ParseFileURL(const base::char16* url,
-                             int url_len,
-                             Parsed* parsed);
-
+COMPONENT_EXPORT(URL)
+void ParseFileURL(const char* url, int url_len, Parsed* parsed);
+COMPONENT_EXPORT(URL)
+void ParseFileURL(const base::char16* url, int url_len, Parsed* parsed);
 // Filesystem URLs are structured differently than other URLs.
-URL_EXPORT void ParseFileSystemURL(const char* url,
-                                   int url_len,
-                                   Parsed* parsed);
-URL_EXPORT void ParseFileSystemURL(const base::char16* url,
-                                   int url_len,
-                                   Parsed* parsed);
-
+COMPONENT_EXPORT(URL)
+void ParseFileSystemURL(const char* url, int url_len, Parsed* parsed);
+COMPONENT_EXPORT(URL)
+void ParseFileSystemURL(const base::char16* url, int url_len, Parsed* parsed);
 // MailtoURL is for mailto: urls. They are made up scheme,path,query
-URL_EXPORT void ParseMailtoURL(const char* url, int url_len, Parsed* parsed);
-URL_EXPORT void ParseMailtoURL(const base::char16* url,
-                               int url_len,
-                               Parsed* parsed);
-
+COMPONENT_EXPORT(URL)
+void ParseMailtoURL(const char* url, int url_len, Parsed* parsed);
+COMPONENT_EXPORT(URL)
+void ParseMailtoURL(const base::char16* url, int url_len, Parsed* parsed);
 // Helper functions -----------------------------------------------------------
-
 // Locates the scheme according to the URL  parser's rules. This function is
 // designed so the caller can find the scheme and call the correct Init*
 // function according to their known scheme types.
@@ -290,32 +248,29 @@
 // end of the string).
 //
 // The 8-bit version requires UTF-8 encoding.
-URL_EXPORT bool ExtractScheme(const char* url,
-                              int url_len,
-                              Component* scheme);
-URL_EXPORT bool ExtractScheme(const base::char16* url,
-                              int url_len,
-                              Component* scheme);
-
+COMPONENT_EXPORT(URL)
+bool ExtractScheme(const char* url, int url_len, Component* scheme);
+COMPONENT_EXPORT(URL)
+bool ExtractScheme(const base::char16* url, int url_len, Component* scheme);
 // Returns true if ch is a character that terminates the authority segment
 // of a URL.
-URL_EXPORT bool IsAuthorityTerminator(base::char16 ch);
-
+COMPONENT_EXPORT(URL) bool IsAuthorityTerminator(base::char16 ch);
 // Does a best effort parse of input |spec|, in range |auth|. If a particular
 // component is not found, it will be set to invalid.
-URL_EXPORT void ParseAuthority(const char* spec,
-                               const Component& auth,
-                               Component* username,
-                               Component* password,
-                               Component* hostname,
-                               Component* port_num);
-URL_EXPORT void ParseAuthority(const base::char16* spec,
-                               const Component& auth,
-                               Component* username,
-                               Component* password,
-                               Component* hostname,
-                               Component* port_num);
-
+COMPONENT_EXPORT(URL)
+void ParseAuthority(const char* spec,
+                    const Component& auth,
+                    Component* username,
+                    Component* password,
+                    Component* hostname,
+                    Component* port_num);
+COMPONENT_EXPORT(URL)
+void ParseAuthority(const base::char16* spec,
+                    const Component& auth,
+                    Component* username,
+                    Component* password,
+                    Component* hostname,
+                    Component* port_num);
 // Computes the integer port value from the given port component. The port
 // component should have been identified by one of the init functions on
 // |Parsed| for the given input url.
@@ -323,9 +278,9 @@
 // The return value will be a positive integer between 0 and 64K, or one of
 // the two special values below.
 enum SpecialPort { PORT_UNSPECIFIED = -1, PORT_INVALID = -2 };
-URL_EXPORT int ParsePort(const char* url, const Component& port);
-URL_EXPORT int ParsePort(const base::char16* url, const Component& port);
-
+COMPONENT_EXPORT(URL) int ParsePort(const char* url, const Component& port);
+COMPONENT_EXPORT(URL)
+int ParsePort(const base::char16* url, const Component& port);
 // Extracts the range of the file name in the given url. The path must
 // already have been computed by the parse function, and the matching URL
 // and extracted path are provided to this function. The filename is
@@ -336,13 +291,14 @@
 // following the last slash.
 //
 // The 8-bit version requires UTF-8 encoding.
-URL_EXPORT void ExtractFileName(const char* url,
-                                const Component& path,
-                                Component* file_name);
-URL_EXPORT void ExtractFileName(const base::char16* url,
-                                const Component& path,
-                                Component* file_name);
-
+COMPONENT_EXPORT(URL)
+void ExtractFileName(const char* url,
+                     const Component& path,
+                     Component* file_name);
+COMPONENT_EXPORT(URL)
+void ExtractFileName(const base::char16* url,
+                     const Component& path,
+                     Component* file_name);
 // Extract the first key/value from the range defined by |*query|. Updates
 // |*query| to start at the end of the extracted key/value pair. This is
 // designed for use in a loop: you can keep calling it with the same query
@@ -358,15 +314,15 @@
 //
 // If no key/value are found |*key| and |*value| will be unchanged and it will
 // return false.
-URL_EXPORT bool ExtractQueryKeyValue(const char* url,
-                                     Component* query,
-                                     Component* key,
-                                     Component* value);
-URL_EXPORT bool ExtractQueryKeyValue(const base::char16* url,
-                                     Component* query,
-                                     Component* key,
-                                     Component* value);
-
+COMPONENT_EXPORT(URL)
+bool ExtractQueryKeyValue(const char* url,
+                          Component* query,
+                          Component* key,
+                          Component* value);
+COMPONENT_EXPORT(URL)
+bool ExtractQueryKeyValue(const base::char16* url,
+                          Component* query,
+                          Component* key,
+                          Component* value);
 }  // namespace url
-
 #endif  // URL_THIRD_PARTY_MOZILLA_URL_PARSE_H_