diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-08 05:35:47 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-08 05:35:47 +0000 |
commit | 70f7efe52831ef7f900c33af139c33d9c95f7dc4 (patch) | |
tree | 42faab048f58f64dec7019190ebe05e6b2627faa /webkit/api | |
parent | 8d3aa94c59b93c15c14e3f31376d5b5b55b9ec6a (diff) | |
download | chromium_src-70f7efe52831ef7f900c33af139c33d9c95f7dc4.zip chromium_src-70f7efe52831ef7f900c33af139c33d9c95f7dc4.tar.gz chromium_src-70f7efe52831ef7f900c33af139c33d9c95f7dc4.tar.bz2 |
Add implicit AtomicString conversion to WebString. Get rid of a couple explicit casts that are no longer needed.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/164221
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api')
-rw-r--r-- | webkit/api/public/WebString.h | 11 | ||||
-rw-r--r-- | webkit/api/src/WebString.cpp | 24 | ||||
-rw-r--r-- | webkit/api/src/WebURLRequest.cpp | 10 | ||||
-rw-r--r-- | webkit/api/src/WebURLResponse.cpp | 10 |
4 files changed, 38 insertions, 17 deletions
diff --git a/webkit/api/public/WebString.h b/webkit/api/public/WebString.h index b0f8e49..8eee441 100644 --- a/webkit/api/public/WebString.h +++ b/webkit/api/public/WebString.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -34,7 +34,7 @@ #include "WebCommon.h" #if WEBKIT_IMPLEMENTATION -namespace WebCore { class String; } +namespace WebCore { class String; class AtomicString; } #else #include <base/string16.h> #endif @@ -84,6 +84,9 @@ namespace WebKit { WebString(const WebCore::String&); WebString& operator=(const WebCore::String&); operator WebCore::String() const; + WebString(const WebCore::AtomicString&); + WebString& operator=(const WebCore::AtomicString&); + operator WebCore::AtomicString() const; #else WebString(const string16& s) : m_private(0) { diff --git a/webkit/api/src/WebString.cpp b/webkit/api/src/WebString.cpp index 08da985..9d1b2d6 100644 --- a/webkit/api/src/WebString.cpp +++ b/webkit/api/src/WebString.cpp @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -32,6 +32,7 @@ #include "WebString.h" #include "PlatformString.h" +#include "AtomicString.h" namespace WebKit { @@ -95,6 +96,23 @@ WebString::operator WebCore::String() const return m_private; } +WebString::WebString(const WebCore::AtomicString& s) + : m_private(0) +{ + assign(s.string()); +} + +WebString& WebString::operator=(const WebCore::AtomicString& s) +{ + assign(s.string()); + return *this; +} + +WebString::operator WebCore::AtomicString() const +{ + return WebCore::AtomicString(static_cast<WebCore::StringImpl *>(m_private)); +} + void WebString::assign(WebStringPrivate* p) { // Take care to handle the case where m_private == p diff --git a/webkit/api/src/WebURLRequest.cpp b/webkit/api/src/WebURLRequest.cpp index 14f5b8d..579b544 100644 --- a/webkit/api/src/WebURLRequest.cpp +++ b/webkit/api/src/WebURLRequest.cpp @@ -127,31 +127,31 @@ void WebURLRequest::setHTTPMethod(const WebString& httpMethod) WebString WebURLRequest::httpHeaderField(const WebString& name) const { - return m_private->m_resourceRequest->httpHeaderField(String(name)); + return m_private->m_resourceRequest->httpHeaderField(name); } void WebURLRequest::setHTTPHeaderField(const WebString& name, const WebString& value) { - m_private->m_resourceRequest->setHTTPHeaderField(String(name), value); + m_private->m_resourceRequest->setHTTPHeaderField(name, value); } void WebURLRequest::addHTTPHeaderField(const WebString& name, const WebString& value) { - m_private->m_resourceRequest->addHTTPHeaderField(String(name), value); + m_private->m_resourceRequest->addHTTPHeaderField(name, value); } void WebURLRequest::clearHTTPHeaderField(const WebString& name) { // FIXME: Add a clearHTTPHeaderField method to ResourceRequest. const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields(); - const_cast<HTTPHeaderMap*>(&map)->remove(String(name)); + const_cast<HTTPHeaderMap*>(&map)->remove(name); } void WebURLRequest::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const { const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) - visitor->visitHeader(String(it->first), it->second); + visitor->visitHeader(it->first, it->second); } WebHTTPBody WebURLRequest::httpBody() const diff --git a/webkit/api/src/WebURLResponse.cpp b/webkit/api/src/WebURLResponse.cpp index 14e95b9..e96a3f0 100644 --- a/webkit/api/src/WebURLResponse.cpp +++ b/webkit/api/src/WebURLResponse.cpp @@ -155,12 +155,12 @@ void WebURLResponse::setHTTPStatusText(const WebString& httpStatusText) WebString WebURLResponse::httpHeaderField(const WebString& name) const { - return m_private->m_resourceResponse->httpHeaderField(String(name)); + return m_private->m_resourceResponse->httpHeaderField(name); } void WebURLResponse::setHTTPHeaderField(const WebString& name, const WebString& value) { - m_private->m_resourceResponse->setHTTPHeaderField(String(name), value); + m_private->m_resourceResponse->setHTTPHeaderField(name, value); } void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& value) @@ -169,7 +169,7 @@ void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); String valueStr(value); pair<HTTPHeaderMap::iterator, bool> result = - const_cast<HTTPHeaderMap*>(&map)->add(String(name), valueStr); + const_cast<HTTPHeaderMap*>(&map)->add(name, valueStr); if (!result.second) result.first->second += ", " + valueStr; } @@ -178,14 +178,14 @@ void WebURLResponse::clearHTTPHeaderField(const WebString& name) { // FIXME: Add a clearHTTPHeaderField method to ResourceResponse. const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); - const_cast<HTTPHeaderMap*>(&map)->remove(String(name)); + const_cast<HTTPHeaderMap*>(&map)->remove(name); } void WebURLResponse::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const { const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) - visitor->visitHeader(String(it->first), it->second); + visitor->visitHeader(it->first, it->second); } double WebURLResponse::lastModifiedDate() const |