diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 20:42:56 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 20:42:56 +0000 |
commit | ce208f877048d4c7bbb57e0df045f0f39a9c80bf (patch) | |
tree | 24210ee34fc2c341d9d45c722e2941c9ab8ce768 /content/public/common/webkit_param_traits.cc | |
parent | d1f43abcb958e76806007d59f75f2da6078be89e (diff) | |
download | chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.zip chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.tar.gz chromium_src-ce208f877048d4c7bbb57e0df045f0f39a9c80bf.tar.bz2 |
Refactor Pickle Read methods to use higher performance PickleIterator.
There was a lot of redundant error checking and initialization code in all Pickle Read methods because of the void** iterator type. This change replaces the void* iterator with PickleIterator, which encapsulates the read pointer so that less error checking and initialization code is needed for reading.
PickleIterator has all the necessary data to do the actual reading. The advantage of having it provide Read methods (as opposed to leaving them solely in the Pickle interface) is that the callers do not need to pass around the const Pickle* once they have a PickleIterator.
Followup CLs will refactor the call sites to remove const Pickle* arguments where they are now unnecessary. Then the Pickle::Read* methods can be removed entirely.
The alternative approach would have been to change the Pickle::Read methods to non-const and remove the iterator parameter (making Read methods advance an internal read pointer). Unfortunately, the const Read with iterator design is entrenched throughout the chromium code, making this a much more complex change with the same performance outcome.
BUG=13108
Review URL: https://chromiumcodereview.appspot.com/9447084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public/common/webkit_param_traits.cc')
-rw-r--r-- | content/public/common/webkit_param_traits.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/content/public/common/webkit_param_traits.cc b/content/public/common/webkit_param_traits.cc index 5d4e059..5d586d8 100644 --- a/content/public/common/webkit_param_traits.cc +++ b/content/public/common/webkit_param_traits.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -57,7 +57,7 @@ void ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Write( } bool ParamTraits<webkit_glue::ResourceLoadTimingInfo>::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { bool is_null; if (!ReadParam(m, iter, &is_null)) return false; @@ -128,7 +128,7 @@ void ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Write( } bool ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> >::Read( - const Message* m, void** iter, param_type* r) { + const Message* m, PickleIterator* iter, param_type* r) { bool has_object; if (!ReadParam(m, iter, &has_object)) return false; @@ -177,7 +177,7 @@ void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { } bool ParamTraits<NPVariant_Param>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { int type; if (!ReadParam(m, iter, &type)) @@ -230,9 +230,9 @@ void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) { } bool ParamTraits<NPIdentifier_Param>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* r) { - return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier); + return webkit_glue::DeserializeNPIdentifier(iter, &r->identifier); } void ParamTraits<NPIdentifier_Param>::Log(const param_type& p, std::string* l) { @@ -256,7 +256,7 @@ void ParamTraits<webkit::WebPluginMimeType>::Write(Message* m, } bool ParamTraits<webkit::WebPluginMimeType>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->mime_type) && @@ -288,7 +288,7 @@ void ParamTraits<webkit::WebPluginInfo>::Write(Message* m, } bool ParamTraits<webkit::WebPluginInfo>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->name) && @@ -328,7 +328,7 @@ void ParamTraits<webkit::forms::PasswordForm>::Write(Message* m, } bool ParamTraits<webkit::forms::PasswordForm>::Read(const Message* m, - void** iter, + PickleIterator* iter, param_type* p) { return ReadParam(m, iter, &p->signon_realm) && |