diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 16:00:32 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 16:00:32 +0000 |
commit | 4f4dc2f3fcb01bc6402cbaa83d0935194f992cb5 (patch) | |
tree | 03be2eea80b1048c588f5883247bcc776566f76f /webkit/glue/devtools/devtools_rpc.h | |
parent | 07fc26a8ea76b29d6deb598664ed7b54b9ed2606 (diff) | |
download | chromium_src-4f4dc2f3fcb01bc6402cbaa83d0935194f992cb5.zip chromium_src-4f4dc2f3fcb01bc6402cbaa83d0935194f992cb5.tar.gz chromium_src-4f4dc2f3fcb01bc6402cbaa83d0935194f992cb5.tar.bz2 |
Convert devtools interfaces over to using WebString.
Also converts some internal std::string usage to WebCore::String.
Note: copying WebString to WebCore::String is very cheap (just
increments a reference count).
The ugly WebStringToString and StringToWebString calls inside the
devtools implementation are temporary. Once this code moves into
the WebKit API implementation, those methods will go away.
I thought about changing the devtools IPCs to use string16 instead
of std::string because that would avoid the UTF8 conversions. I'm
not sure if that is worth it though given that UTF16 would increase
the amount of data being sent over IPC. I figure this is something
that could be studied later.
R=pfeldman
BUG=24597
TEST=none
Review URL: http://codereview.chromium.org/264077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29286 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/devtools/devtools_rpc.h')
-rw-r--r-- | webkit/glue/devtools/devtools_rpc.h | 69 |
1 files changed, 27 insertions, 42 deletions
diff --git a/webkit/glue/devtools/devtools_rpc.h b/webkit/glue/devtools/devtools_rpc.h index 6656ad4..f0de3d9 100644 --- a/webkit/glue/devtools/devtools_rpc.h +++ b/webkit/glue/devtools/devtools_rpc.h @@ -50,15 +50,11 @@ #ifndef WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_RPC_H_ #define WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_RPC_H_ -#include <string> - -// Do not remove this one although it is not used. -#include <wtf/OwnPtr.h> +#include "PlatformString.h" +// TODO(darin): Remove these dependencies on Chromium base/. #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "base/string_util.h" -#include "webkit/glue/glue_util.h" namespace WebCore { class String; @@ -77,50 +73,39 @@ struct RpcTypeTrait { template<> struct RpcTypeTrait<bool> { typedef bool ApiType; - static bool Parse(const std::string& t) { - int i; - ALLOW_UNUSED bool success = StringToInt(t, &i); + static bool Parse(const WebCore::String& t) { + ALLOW_UNUSED bool success; + int i = t.toIntStrict(&success); ASSERT(success); return i; } - static std::string ToString(bool b) { - return IntToString(b ? 1 : 0); + static WebCore::String ToString(bool b) { + return WebCore::String::number(b ? 1 : 0); } }; template<> struct RpcTypeTrait<int> { typedef int ApiType; - static int Parse(const std::string& t) { - int i; - ALLOW_UNUSED bool success = StringToInt(t, &i); + static int Parse(const WebCore::String& t) { + ALLOW_UNUSED bool success; + int i = t.toIntStrict(&success); ASSERT(success); return i; } - static std::string ToString(int i) { - return IntToString(i); + static WebCore::String ToString(int i) { + return WebCore::String::number(i); } }; template<> struct RpcTypeTrait<String> { typedef const String& ApiType; - static String Parse(const std::string& t) { - return webkit_glue::StdStringToString(t); - } - static std::string ToString(const String& t) { - return webkit_glue::StringToStdString(t); - } -}; - -template<> -struct RpcTypeTrait<std::string> { - typedef const std::string& ApiType; - static std::string Parse(const std::string& s) { - return s; + static String Parse(const WebCore::String& t) { + return t; } - static std::string ToString(const std::string& s) { - return s; + static WebCore::String ToString(const String& t) { + return t; } }; @@ -233,7 +218,7 @@ class Class {\ TOOLS_RPC_API_METHOD1, \ TOOLS_RPC_API_METHOD2, \ TOOLS_RPC_API_METHOD3) \ - std::string class_name; \ + WebCore::String class_name; \ private: \ DISALLOW_COPY_AND_ASSIGN(Class); \ }; \ @@ -258,11 +243,11 @@ class Class##Dispatch { \ virtual ~Class##Dispatch() {} \ \ static bool Dispatch(Class* delegate, \ - const std::string& class_name, \ - const std::string& method_name, \ - const std::string& p1, \ - const std::string& p2, \ - const std::string& p3) { \ + const WebCore::String& class_name, \ + const WebCore::String& method_name, \ + const WebCore::String& p1, \ + const WebCore::String& p2, \ + const WebCore::String& p3) { \ if (class_name != #Class) { \ return false; \ } \ @@ -286,11 +271,11 @@ class DevToolsRpc { public: Delegate() {} virtual ~Delegate() {} - virtual void SendRpcMessage(const std::string& class_name, - const std::string& method_name, - const std::string& p1 = "", - const std::string& p2 = "", - const std::string& p3 = "") = 0; + virtual void SendRpcMessage(const WebCore::String& class_name, + const WebCore::String& method_name, + const WebCore::String& p1 = "", + const WebCore::String& p2 = "", + const WebCore::String& p3 = "") = 0; private: DISALLOW_COPY_AND_ASSIGN(Delegate); }; |