Rewrite most `Foo* field_` pointer fields to `raw_ptr<Foo> field_`.
DO NOT REVERT (unless absolutely necessary)! Report build breaks to keishi@(APAC)/glazunov@(EMEA)/sebmarchand@(NA) as soon as you see them. Fixes are expected to be trivial.
This commit was generated automatically, by running the following script: tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh on commit fe74bc434e5b7e92d13a328362fcb6df15d8847e
For more information, see MiraclePtr One Pager [1], the PSA at chromium-dev@ [2], and the raw_ptr documentation in //base/memory/raw_ptr.md.
FYI This CL does not enable MiraclePtr protection and we expect no behavior change from this.
[1] https://docs.google.com/document/d/1pnnOAIz_DMWDI4oIOFoMAqLnf_MZ2GsrJNb_dbQ3ZBg/edit?usp=sharing
[2] https://groups.google.com/a/chromium.org/g/chromium-dev/c/vAEeVifyf78/m/SkBUc6PhBAAJ
Binary-Size: Increase of around 500kb was approved for MiraclePtr
Include-Ci-Only-Tests: true
No-Tree-Checks: true
No-Presubmit: true
Bug: 1272324, 1073933
Change-Id: I05c86a83bbb4b3f4b017f361dd7f4e7437697f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3305132
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Owners-Override: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#945735}
diff --git a/gin/arguments.h b/gin/arguments.h
index eaded13..307108c 100644
--- a/gin/arguments.h
+++ b/gin/arguments.h
@@ -5,6 +5,7 @@
#ifndef GIN_ARGUMENTS_H_
#define GIN_ARGUMENTS_H_
+#include "base/memory/raw_ptr.h"
#include "gin/converter.h"
#include "gin/gin_export.h"
@@ -109,7 +110,7 @@
bool IsConstructCall() const;
private:
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
union {
const v8::FunctionCallbackInfo<v8::Value>* info_for_function_;
const v8::PropertyCallbackInfo<v8::Value>* info_for_property_;
diff --git a/gin/data_object_builder.h b/gin/data_object_builder.h
index 7e0e719..b735963 100644
--- a/gin/data_object_builder.h
+++ b/gin/data_object_builder.h
@@ -8,6 +8,7 @@
#include <utility>
#include "base/check.h"
+#include "base/memory/raw_ptr.h"
#include "base/strings/string_piece.h"
#include "gin/converter.h"
#include "gin/gin_export.h"
@@ -70,7 +71,7 @@
}
private:
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
v8::Local<v8::Context> context_;
v8::Local<v8::Object> object_;
};
diff --git a/gin/dictionary.h b/gin/dictionary.h
index 8ccf55b..947694b 100644
--- a/gin/dictionary.h
+++ b/gin/dictionary.h
@@ -5,6 +5,7 @@
#ifndef GIN_DICTIONARY_H_
#define GIN_DICTIONARY_H_
+#include "base/memory/raw_ptr.h"
#include "gin/converter.h"
#include "gin/gin_export.h"
@@ -58,7 +59,7 @@
friend struct Converter<Dictionary>;
// TODO(aa): Remove this. Instead, get via FromV8(), Set(), and Get().
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
v8::Local<v8::Object> object_;
};
diff --git a/gin/function_template.h b/gin/function_template.h
index db630d2..61b2064b 100644
--- a/gin/function_template.h
+++ b/gin/function_template.h
@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/check.h"
+#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "gin/arguments.h"
#include "gin/converter.h"
@@ -187,7 +188,7 @@
return arg1 && And(args...);
}
- Arguments* args_;
+ raw_ptr<Arguments> args_;
};
// DispatchToCallback converts all the JavaScript arguments to C++ types and
diff --git a/gin/handle.h b/gin/handle.h
index 8a27f91..2be9ac6 100644
--- a/gin/handle.h
+++ b/gin/handle.h
@@ -5,6 +5,7 @@
#ifndef GIN_HANDLE_H_
#define GIN_HANDLE_H_
+#include "base/memory/raw_ptr.h"
#include "gin/converter.h"
namespace gin {
@@ -36,7 +37,7 @@
private:
v8::Local<v8::Value> wrapper_;
- T* object_;
+ raw_ptr<T> object_;
};
template<typename T>
diff --git a/gin/interceptor.h b/gin/interceptor.h
index ff6dcc3..73560e4 100644
--- a/gin/interceptor.h
+++ b/gin/interceptor.h
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "base/memory/raw_ptr.h"
#include "gin/gin_export.h"
#include "v8/include/v8-forward.h"
@@ -36,8 +37,8 @@
v8::Isolate* isolate);
private:
- v8::Isolate* isolate_;
- WrappableBase* base_;
+ raw_ptr<v8::Isolate> isolate_;
+ raw_ptr<WrappableBase> base_;
};
class GIN_EXPORT IndexedPropertyInterceptor {
@@ -58,8 +59,8 @@
v8::Isolate* isolate);
private:
- v8::Isolate* isolate_;
- WrappableBase* base_;
+ raw_ptr<v8::Isolate> isolate_;
+ raw_ptr<WrappableBase> base_;
};
} // namespace gin
diff --git a/gin/object_template_builder.h b/gin/object_template_builder.h
index 33bfd24..60265ea 100644
--- a/gin/object_template_builder.h
+++ b/gin/object_template_builder.h
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/memory/raw_ptr.h"
#include "base/strings/string_piece.h"
#include "gin/converter.h"
#include "gin/function_template.h"
@@ -129,7 +130,7 @@
v8::AccessorNameGetterCallback callback,
v8::Local<v8::Value> data);
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
// If provided, |type_name_| will be used to give a user-friendly error
// message if a member function is invoked on the wrong type of object.
diff --git a/gin/per_context_data.h b/gin/per_context_data.h
index 4ce53d80..33968322 100644
--- a/gin/per_context_data.h
+++ b/gin/per_context_data.h
@@ -5,6 +5,7 @@
#ifndef GIN_PER_CONTEXT_DATA_H_
#define GIN_PER_CONTEXT_DATA_H_
+#include "base/memory/raw_ptr.h"
#include "base/supports_user_data.h"
#include "gin/gin_export.h"
#include "v8/include/v8-forward.h"
@@ -38,8 +39,8 @@
ContextHolder* context_holder() { return context_holder_; }
private:
- ContextHolder* context_holder_;
- Runner* runner_;
+ raw_ptr<ContextHolder> context_holder_;
+ raw_ptr<Runner> runner_;
};
} // namespace gin
diff --git a/gin/per_isolate_data.h b/gin/per_isolate_data.h
index ae47f04..8d7c725 100644
--- a/gin/per_isolate_data.h
+++ b/gin/per_isolate_data.h
@@ -8,6 +8,7 @@
#include <map>
#include <memory>
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/task/single_thread_task_runner.h"
#include "gin/gin_export.h"
@@ -87,8 +88,8 @@
// PerIsolateData doesn't actually own |isolate_|. Instead, the isolate is
// owned by the IsolateHolder, which also owns the PerIsolateData.
- v8::Isolate* isolate_;
- v8::ArrayBuffer::Allocator* allocator_;
+ raw_ptr<v8::Isolate> isolate_;
+ raw_ptr<v8::ArrayBuffer::Allocator> allocator_;
ObjectTemplateMap object_templates_;
FunctionTemplateMap function_templates_;
IndexedPropertyInterceptorMap indexed_interceptors_;
diff --git a/gin/public/context_holder.h b/gin/public/context_holder.h
index b71e495..3d403c05 100644
--- a/gin/public/context_holder.h
+++ b/gin/public/context_holder.h
@@ -8,6 +8,7 @@
#include <list>
#include <memory>
+#include "base/memory/raw_ptr.h"
#include "gin/gin_export.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-forward.h"
@@ -43,7 +44,7 @@
void SetContext(v8::Local<v8::Context> context);
private:
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
v8::UniquePersistent<v8::Context> context_;
std::unique_ptr<PerContextData> data_;
};
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index cb1da2ca..78133f9b 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -7,6 +7,7 @@
#include <memory>
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "gin/gin_export.h"
#include "gin/public/v8_idle_task_runner.h"
@@ -130,7 +131,7 @@
void SetUp(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
std::unique_ptr<v8::SnapshotCreator> snapshot_creator_;
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
std::unique_ptr<PerIsolateData> isolate_data_;
std::unique_ptr<V8IsolateMemoryDumpProvider> isolate_memory_dump_provider_;
AccessMode access_mode_;
diff --git a/gin/shell_runner.h b/gin/shell_runner.h
index 82d72a3..95ddd26 100644
--- a/gin/shell_runner.h
+++ b/gin/shell_runner.h
@@ -7,6 +7,7 @@
#include <memory>
+#include "base/memory/raw_ptr.h"
#include "gin/runner.h"
namespace gin {
@@ -56,7 +57,7 @@
void Run(v8::Local<v8::Script> script);
- ShellRunnerDelegate* delegate_;
+ raw_ptr<ShellRunnerDelegate> delegate_;
std::unique_ptr<ContextHolder> context_holder_;
};
diff --git a/gin/try_catch.h b/gin/try_catch.h
index 4f0656cb..edacbec8 100644
--- a/gin/try_catch.h
+++ b/gin/try_catch.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/memory/raw_ptr.h"
#include "gin/gin_export.h"
#include "v8/include/v8-exception.h"
@@ -24,7 +25,7 @@
std::string GetStackTrace();
private:
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
v8::TryCatch try_catch_;
};
diff --git a/gin/v8_foreground_task_runner_with_locker.cc b/gin/v8_foreground_task_runner_with_locker.cc
index 576178ee..4451bfc 100644
--- a/gin/v8_foreground_task_runner_with_locker.cc
+++ b/gin/v8_foreground_task_runner_with_locker.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
+#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "v8/include/v8-locker.h"
@@ -43,7 +44,7 @@
}
private:
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
std::unique_ptr<v8::IdleTask> task_;
};
diff --git a/gin/v8_foreground_task_runner_with_locker.h b/gin/v8_foreground_task_runner_with_locker.h
index 9d1ebbdf..78c81a2 100644
--- a/gin/v8_foreground_task_runner_with_locker.h
+++ b/gin/v8_foreground_task_runner_with_locker.h
@@ -5,6 +5,7 @@
#ifndef GIN_V8_FOREGROUND_TASK_RUNNER_WITH_LOCKER_H_
#define GIN_V8_FOREGROUND_TASK_RUNNER_WITH_LOCKER_H_
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "gin/v8_foreground_task_runner_base.h"
@@ -35,7 +36,7 @@
bool NonNestableTasksEnabled() const override;
private:
- v8::Isolate* isolate_;
+ raw_ptr<v8::Isolate> isolate_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
};
diff --git a/gin/v8_isolate_memory_dump_provider.h b/gin/v8_isolate_memory_dump_provider.h
index c22cb74..b3ca74a 100644
--- a/gin/v8_isolate_memory_dump_provider.h
+++ b/gin/v8_isolate_memory_dump_provider.h
@@ -5,6 +5,7 @@
#ifndef GIN_V8_ISOLATE_MEMORY_DUMP_PROVIDER_H_
#define GIN_V8_ISOLATE_MEMORY_DUMP_PROVIDER_H_
+#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_provider.h"
#include "gin/gin_export.h"
@@ -36,7 +37,7 @@
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* process_memory_dump);
- IsolateHolder* isolate_holder_; // Not owned.
+ raw_ptr<IsolateHolder> isolate_holder_; // Not owned.
};
} // namespace gin
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index 94f3fbd7..0ccafbd 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -13,6 +13,7 @@
#include "base/debug/stack_trace.h"
#include "base/location.h"
#include "base/memory/nonscannable_memory.h"
+#include "base/memory/raw_ptr.h"
#include "base/rand_util.h"
#include "base/system/sys_info.h"
#include "base/task/post_job.h"
@@ -209,7 +210,7 @@
bool IsJoiningThread() const override { return delegate_->IsJoiningThread(); }
private:
- base::JobDelegate* delegate_;
+ raw_ptr<base::JobDelegate> delegate_;
};
class JobHandleImpl : public v8::JobHandle {
diff --git a/gin/v8_platform_unittest.cc b/gin/v8_platform_unittest.cc
index 332e0f7..fc74879 100644
--- a/gin/v8_platform_unittest.cc
+++ b/gin/v8_platform_unittest.cc
@@ -7,6 +7,7 @@
#include <atomic>
#include "base/barrier_closure.h"
+#include "base/memory/raw_ptr.h"
#include "base/test/task_environment.h"
#include "base/test/test_waitable_event.h"
#include "base/trace_event/trace_event.h"
@@ -81,7 +82,7 @@
return *num_tasks_to_run;
}
- std::atomic_size_t* num_tasks_to_run;
+ raw_ptr<std::atomic_size_t> num_tasks_to_run;
};
auto handle =
V8Platform::Get()->PostJob(v8::TaskPriority::kUserVisible,
@@ -126,9 +127,9 @@
return *num_tasks_to_run_;
}
- std::atomic_size_t* num_tasks_to_run_;
+ raw_ptr<std::atomic_size_t> num_tasks_to_run_;
base::RepeatingClosure threads_running_barrier_;
- base::TestWaitableEvent* threads_continue_;
+ raw_ptr<base::TestWaitableEvent> threads_continue_;
};
base::test::TaskEnvironment task_environment;