Commit 518f9370 authored by bugsnash's avatar bugsnash Committed by Commit bot

Removed local RefPtr created from PassRefPtr arg in generated file.

This is a follow up from https://codereview.chromium.org/2807073002

This patch removed a generated instance of a PassRefPtr object being
copied into a RefPtr object.

All instances of PassRefPtr objects being copied into RefPtr objects
need to be wrapped in std::move to avoid introducing ref churn in
future changes when all PassRefPtr objects will be replaced with RefPtr
objects. In this case creating a local RefPtr just to copy the
PassRefPtr argument into, a std::move wrap doesn't make sense as it
would result in a final state where a RefPtr argument is moved into a
local RefPtr for no reason. So to handle this cases I have converted
the PassRefPtr argument to RefPtr in advance, and removed the local
RefPtr argument, instead using the passed RefPtr in the
method.

This patch
- Changed the argument passed from PassRefPtr to RefPtr
- Removed the logic for creating a local RefPtr argument
- Changed the naming logic to name RefPtr arguments as rpParamTypeName
- Removed the self.value variable and used self.name instead, as
  self.value was only used to store the name of the local RefPtr
  variable separate from the PassRefPtr argument
- Removed the comment in the header about PassRefPtr parameters
- Removed the base_name variable in build_param_name as this was
  causing a presubmit error from clashing with the global base_name

Changes to generated files:
https://gist.github.com/BugsNash/595ec7b86ce850d676aa8722f68abbf8/revisions

BUG=494719

Review-Url: https://codereview.chromium.org/2846723003
Cr-Commit-Position: refs/heads/master@{#467909}
parent 322942d0
......@@ -155,12 +155,6 @@ class Parameter(object):
self.type = param_decl
self.name = build_param_name(self.type)
self.value = self.name
self.is_prp = re.match(r"PassRefPtr<", param_decl) is not None
if self.is_prp:
self.name = "prp" + self.name[0].upper() + self.name[1:]
self.inner_type = re.match(r"PassRefPtr<(.+)>", param_decl).group(1)
if self.type[-1] == "*" and "char" not in self.type:
self.member_type = "Member<%s>" % self.type[:-1]
else:
......@@ -168,8 +162,7 @@ class Parameter(object):
def build_param_name(param_type):
base_name = re.match(r"(const |PassRefPtr<)?(\w*)", param_type).group(2)
return "param" + base_name
return "param" + re.match(r"(const |RefPtr<)?(\w*)", param_type).group(2)
def load_config(file_name):
......
......@@ -54,11 +54,6 @@ namespace probe {
{{sink_class}}* sink = To{{sink_class}}({{probe.params[0].name}});
if (!sink)
return;
{% for param in probe.params %}
{% if param.is_prp %}
RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}};
{% endif %}
{% endfor %}
{% for agent in probe.agents %}
{% set class_name = agent | agent_name_to_class %}
if (sink->has{{class_name}}s()) {
......@@ -90,7 +85,7 @@ CORE_EXPORT void {{probe.name}}({{ params_list(probe) }}) {
{% call probe_body(probe, "") %}
{%- for param in probe.params %}
{%- if not loop.first or "Keep" in param.options -%}
{{param.value}}
{{param.name}}
{%- if not loop.last %}, {% endif -%}
{%- endif -%}
{%- endfor %}
......
......@@ -49,9 +49,6 @@
*
* paramList: C++ parameter list with optional names. Names will be deduced from types if omitted but you have to
* specify explicit names for multiple parameters of the same type.
*
* Parameters with type PassRefPtr<T> are converted to raw pointers,
* so reference will not be passed or released until all agents are notified.
*/
interface CoreProbes {
......@@ -104,7 +101,7 @@ interface CoreProbes {
void willSendEventSourceRequest(ExecutionContext*, ThreadableLoaderClient* eventSource);
void willDispatchEventSourceEvent(ExecutionContext*, ThreadableLoaderClient* eventSource, const AtomicString& eventName, const AtomicString& eventId, const String& data);
void didFinishEventSourceRequest(ExecutionContext*, ThreadableLoaderClient* eventSource);
void willLoadXHR(ExecutionContext*, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const KURL& url, bool async, PassRefPtr<EncodedFormData>, const HTTPHeaderMap& headers, bool includeCredentials);
void willLoadXHR(ExecutionContext*, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const KURL& url, bool async, RefPtr<EncodedFormData>, const HTTPHeaderMap& headers, bool includeCredentials);
void didFailXHRLoading([Keep] ExecutionContext*, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const String& url);
void didFinishXHRLoading([Keep] ExecutionContext*, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const String& url);
void willStartFetch(ExecutionContext*, ThreadableLoaderClient*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment