Skip to content

Commit

Permalink
url: Build it as a static library.
Browse files Browse the repository at this point in the history
This is temporary just to avoid weird link issues in Windows XP.

- Update the gyp file.
- Rename the gyp file from googleurl.gyp to url.gyp, so it matches the directory
name.
- Update the header include paths.
- Update the header include guards.
- Rename the target name from googleurl to url and googleurl_unittests to
url_unittests.
- Remove GURL_API (this will be replaced by URL_EXPORT when we componentize it again).
- Remove url_common.h (will be replaced by url_export.h when we componentize it again).

BUG=229660
TEST=url_unittests
R=brettw@chromium.org

Review URL: https://codereview.chromium.org/13998025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195005 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Apr 18, 2013
1 parent 3c9185a commit 318076b
Show file tree
Hide file tree
Showing 37 changed files with 648 additions and 716 deletions.
109 changes: 0 additions & 109 deletions url/googleurl.gyp

This file was deleted.

6 changes: 3 additions & 3 deletions url/gurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
#include <algorithm>
#include <ostream>

#include "googleurl/src/gurl.h"
#include "url/gurl.h"

#include "base/logging.h"
#include "googleurl/src/url_canon_stdstring.h"
#include "googleurl/src/url_util.h"
#include "url/url_canon_stdstring.h"
#include "url/url_util.h"

namespace {

Expand Down
75 changes: 37 additions & 38 deletions url/gurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,28 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef GOOGLEURL_SRC_GURL_H__
#define GOOGLEURL_SRC_GURL_H__
#ifndef URL_GURL_H_
#define URL_GURL_H_

#include <iosfwd>
#include <string>

#include "base/string16.h"
#include "googleurl/src/url_canon.h"
#include "googleurl/src/url_canon_stdstring.h"
#include "googleurl/src/url_common.h"
#include "googleurl/src/url_parse.h"
#include "url/url_canon.h"
#include "url/url_canon_stdstring.h"
#include "url/url_parse.h"

class GURL {
public:
typedef url_canon::StdStringReplacements<std::string> Replacements;
typedef url_canon::StdStringReplacements<string16> ReplacementsW;

// Creates an empty, invalid URL.
GURL_API GURL();
GURL();

// Copy construction is relatively inexpensive, with most of the time going
// to reallocating the string. It does not re-parse.
GURL_API GURL(const GURL& other);
GURL(const GURL& other);

// The narrow version requires the input be UTF-8. Invalid UTF-8 input will
// result in an invalid URL.
Expand All @@ -58,20 +57,20 @@ class GURL {
// encode the query parameters. It is probably sufficient for the narrow
// version to assume the query parameter encoding should be the same as the
// input encoding.
GURL_API explicit GURL(const std::string& url_string
/*, output_param_encoding*/);
GURL_API explicit GURL(const string16& url_string
/*, output_param_encoding*/);
explicit GURL(const std::string& url_string
/*, output_param_encoding*/);
explicit GURL(const string16& url_string
/*, output_param_encoding*/);

// Constructor for URLs that have already been parsed and canonicalized. This
// is used for conversions from KURL, for example. The caller must supply all
// information associated with the URL, which must be correct and consistent.
GURL_API GURL(const char* canonical_spec, size_t canonical_spec_len,
const url_parse::Parsed& parsed, bool is_valid);
GURL(const char* canonical_spec, size_t canonical_spec_len,
const url_parse::Parsed& parsed, bool is_valid);

GURL_API ~GURL();
~GURL();

GURL_API GURL& operator=(const GURL& other);
GURL& operator=(const GURL& other);

// Returns true when this object represents a valid parsed URL. When not
// valid, other functions will still succeed, but you will not get canonical
Expand Down Expand Up @@ -103,7 +102,7 @@ class GURL {
// Used invalid_spec() below to get the unusable spec of an invalid URL. This
// separation is designed to prevent errors that may cause security problems
// that could result from the mistaken use of an invalid URL.
GURL_API const std::string& spec() const;
const std::string& spec() const;

// Returns the potentially invalid spec for a the URL. This spec MUST NOT be
// modified or sent over the network. It is designed to be displayed in error
Expand Down Expand Up @@ -155,8 +154,8 @@ class GURL {
//
// It is an error to resolve a URL relative to an invalid URL. The result
// will be the empty URL.
GURL_API GURL Resolve(const std::string& relative) const;
GURL_API GURL Resolve(const string16& relative) const;
GURL Resolve(const std::string& relative) const;
GURL Resolve(const string16& relative) const;

// Like Resolve() above but takes a character set encoder which will be used
// for any query text specified in the input. The charset converter parameter
Expand All @@ -165,10 +164,10 @@ class GURL {
// TODO(brettw): These should be replaced with versions that take something
// more friendly than a raw CharsetConverter (maybe like an ICU character set
// name).
GURL_API GURL ResolveWithCharsetConverter(
GURL ResolveWithCharsetConverter(
const std::string& relative,
url_canon::CharsetConverter* charset_converter) const;
GURL_API GURL ResolveWithCharsetConverter(
GURL ResolveWithCharsetConverter(
const string16& relative,
url_canon::CharsetConverter* charset_converter) const;

Expand All @@ -183,9 +182,9 @@ class GURL {
//
// Note that we use the more general url_canon::Replacements type to give
// callers extra flexibility rather than our override.
GURL_API GURL ReplaceComponents(
GURL ReplaceComponents(
const url_canon::Replacements<char>& replacements) const;
GURL_API GURL ReplaceComponents(
GURL ReplaceComponents(
const url_canon::Replacements<char16>& replacements) const;

// A helper function that is equivalent to replacing the path with a slash
Expand All @@ -197,7 +196,7 @@ class GURL {
//
// It is an error to get an empty path on an invalid URL. The result
// will be the empty URL.
GURL_API GURL GetWithEmptyPath() const;
GURL GetWithEmptyPath() const;

// A helper function to return a GURL containing just the scheme, host,
// and port from a URL. Equivalent to clearing any username and password,
Expand All @@ -208,19 +207,19 @@ class GURL {
//
// It is an error to get the origin of an invalid URL. The result
// will be the empty URL.
GURL_API GURL GetOrigin() const;
GURL GetOrigin() const;

// Returns true if the scheme for the current URL is a known "standard"
// scheme. Standard schemes have an authority and a path section. This
// includes file: and filesystem:, which some callers may want to filter out
// explicitly by calling SchemeIsFile[System].
GURL_API bool IsStandard() const;
bool IsStandard() const;

// Returns true if the given parameter (should be lower-case ASCII to match
// the canonicalized scheme) is the scheme for this URL. This call is more
// efficient than getting the scheme and comparing it because no copies or
// object constructions are done.
GURL_API bool SchemeIs(const char* lower_ascii_scheme) const;
bool SchemeIs(const char* lower_ascii_scheme) const;

// We often need to know if this is a file URL. File URLs are "standard", but
// are often treated separately by some programs.
Expand All @@ -242,7 +241,7 @@ class GURL {
// Returns true if the hostname is an IP address. Note: this function isn't
// as cheap as a simple getter because it re-parses the hostname to verify.
// This currently identifies only IPv4 addresses (bug 822685).
GURL_API bool HostIsIPAddress() const;
bool HostIsIPAddress() const;

// Getters for various components of the URL. The returned string will be
// empty if the component is empty or is not present.
Expand Down Expand Up @@ -308,24 +307,24 @@ class GURL {

// Returns a parsed version of the port. Can also be any of the special
// values defined in Parsed for ExtractPort.
GURL_API int IntPort() const;
int IntPort() const;

// Returns the port number of the url, or the default port number.
// If the scheme has no concept of port (or unknown default) returns
// PORT_UNSPECIFIED.
GURL_API int EffectiveIntPort() const;
int EffectiveIntPort() const;

// Extracts the filename portion of the path and returns it. The filename
// is everything after the last slash in the path. This may be empty.
GURL_API std::string ExtractFileName() const;
std::string ExtractFileName() const;

// Returns the path that should be sent to the server. This is the path,
// parameter, and query portions of the URL. It is guaranteed to be ASCII.
GURL_API std::string PathForRequest() const;
std::string PathForRequest() const;

// Returns the host, excluding the square brackets surrounding IPv6 address
// literals. This can be useful for passing to getaddrinfo().
GURL_API std::string HostNoBrackets() const;
std::string HostNoBrackets() const;

// Returns true if this URL's host matches or is in the same domain as
// the given input string. For example if this URL was "www.google.com",
Expand All @@ -337,7 +336,7 @@ class GURL {
//
// If function DomainIs has parameter domain_len, which means the parameter
// lower_ascii_domain does not gurantee to terminate with NULL character.
GURL_API bool DomainIs(const char* lower_ascii_domain, int domain_len) const;
bool DomainIs(const char* lower_ascii_domain, int domain_len) const;

// If function DomainIs only has parameter lower_ascii_domain, which means
// domain string should be terminate with NULL character.
Expand All @@ -348,12 +347,12 @@ class GURL {

// Swaps the contents of this GURL object with the argument without doing
// any memory allocations.
GURL_API void Swap(GURL* other);
void Swap(GURL* other);

// Returns a reference to a singleton empty GURL. This object is for callers
// who return references but don't have anything to return in some cases.
// This function may be called from any thread.
GURL_API static const GURL& EmptyGURL();
static const GURL& EmptyGURL();

// Returns the inner URL of a nested URL [currently only non-null for
// filesystem: URLs].
Expand Down Expand Up @@ -387,6 +386,6 @@ class GURL {
};

// Stream operator so GURL can be used in assertion statements.
GURL_API std::ostream& operator<<(std::ostream& out, const GURL& url);
std::ostream& operator<<(std::ostream& out, const GURL& url);

#endif // GOOGLEURL_SRC_GURL_H__
#endif // URL_GURL_H_
6 changes: 3 additions & 3 deletions url/gurl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "googleurl/src/gurl.h"
#include "googleurl/src/url_canon.h"
#include "googleurl/src/url_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/url_canon.h"
#include "url/url_test_utils.h"

// Some implementations of base/basictypes.h may define ARRAYSIZE.
// If it's not defined, we define it to the ARRAYSIZE_UNSAFE macro
Expand Down
Loading

0 comments on commit 318076b

Please sign in to comment.