diff --git a/DEPS b/DEPS index 63628e4..e5863ea2 100644 --- a/DEPS +++ b/DEPS
@@ -40,11 +40,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '86cedfc315886037a0fba6d72ba53bf47bd0b539', + 'skia_revision': '6ad3d2fa38589fafd8b1c203996a402bd8b24362', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '95ddaea4ba5e2a29d7b7cac29123a98889a9a21d', + 'v8_revision': 'c1eee0356bdae023dd05c15e27f02c5db0b17e49', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling swarming_client # and whatever else without interference from each other. @@ -52,7 +52,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': 'f04709744dd7abd4c41371fa3bfcc375fb7030cf', + 'angle_revision': 'd90198385c2ec0429039558b3f2f6b968e5172f4', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling build tools # and whatever else without interference from each other. @@ -96,7 +96,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '70f42a7c55ca69cdeb9aa6ec7e40ff3f155040b9', + 'catapult_revision': 'f3dc14e52faef3d279d6bdab4bff8ec4afd5eb1a', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -368,7 +368,7 @@ Var('chromium_git') + '/external/github.com/material-foundation/material-sprited-animation-view-ios.git' + '@' + 'e240cdcd4538f0763ca5bd8c5afc2991eb482f1a', 'src/ios/third_party/material_text_accessibility_ios/src': - Var('chromium_git') + '/external/github.com/google/material-text-accessibility-ios.git' + '@' + '96d2b0f13976a897bc7a41daf67f36d9548cff94', + Var('chromium_git') + '/external/github.com/material-foundation/material-text-accessibility-ios.git' + '@' + '96d2b0f13976a897bc7a41daf67f36d9548cff94', 'src/ios/third_party/ochamcrest/src': Var('chromium_git') + '/external/github.com/hamcrest/OCHamcrest.git' + '@' + 'd7ee4ecfb6bd13c3c8d364682b6228ccd86e1e1a', @@ -425,6 +425,10 @@ 'src/third_party/minigbm/src': Var('chromium_git') + '/chromiumos/platform/minigbm.git' + '@' + '3345977b5e9ef13f97e2e858241297fc4bfc7401', + # Userspace interface to kernel DRM services. + 'src/third_party/libdrm/src': + Var('chromium_git') + '/chromiumos/third_party/libdrm.git' + '@' + '4c4778123b7b11f750577199644f5d6820851dbb', + # Display server protocol for Linux. 'src/third_party/wayland/src': Var('chromium_git') + '/external/anongit.freedesktop.org/git/wayland/wayland.git' + '@' + '6a18a87727c64719c68168568b9ab1e4d7c2d9c1',
diff --git a/android_webview/tools/system_webview_shell/apk/AndroidManifest.xml b/android_webview/tools/system_webview_shell/apk/AndroidManifest.xml index 8a966ea..1de315de 100644 --- a/android_webview/tools/system_webview_shell/apk/AndroidManifest.xml +++ b/android_webview/tools/system_webview_shell/apk/AndroidManifest.xml
@@ -68,7 +68,7 @@ android:label="@string/title_activity_browser" android:exported="true" android:windowSoftInputMode="adjustResize" - android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"> + android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|density"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
diff --git a/base/bind_unittest.nc b/base/bind_unittest.nc index 46468eca..24a345d2 100644 --- a/base/bind_unittest.nc +++ b/base/bind_unittest.nc
@@ -224,13 +224,27 @@ Closure cb2 = Bind(cb); } -#elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_LVALUE) // [r"static_assert failed \"OnceCallback::Run\(\) may only be invoked on an rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] +#elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_LVALUE) // [r"static_assert failed \"OnceCallback::Run\(\) may only be invoked on a non-const rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] void WontCompile() { OnceClosure cb = Bind([] {}); cb.Run(); } +#elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_CONST_LVALUE) // [r"static_assert failed \"OnceCallback::Run\(\) may only be invoked on a non-const rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] + +void WontCompile() { + const OnceClosure cb = Bind([] {}); + cb.Run(); +} + +#elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_CONST_RVALUE) // [r"static_assert failed \"OnceCallback::Run\(\) may only be invoked on a non-const rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] + +void WontCompile() { + const OnceClosure cb = Bind([] {}); + std::move(cb).Run(); +} + #endif } // namespace base
diff --git a/base/callback.h b/base/callback.h index 344acfe6..9bb0c0f 100644 --- a/base/callback.h +++ b/base/callback.h
@@ -41,7 +41,7 @@ public: using PolymorphicInvoke = R(*)(internal::BindStateBase*, Args&&...); - R Run(Args... args) & { + R Run(Args... args) const & { // Note: even though this static_assert will trivially always fail, it // cannot be simply replaced with static_assert(false, ...) because: // - Per [dcl.dcl]/p4, a program is ill-formed if the constant-expression @@ -53,8 +53,8 @@ // to immediately reject static_assert(false, ...), even inside an // uninstantiated template. static_assert(!IsOnceCallback<CallbackType>::value, - "OnceCallback::Run() may only be invoked on an rvalue, i.e. " - "std::move(callback).Run()."); + "OnceCallback::Run() may only be invoked on a non-const " + "rvalue, i.e. std::move(callback).Run()."); } R Run(Args... args) && {
diff --git a/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc b/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc index 15591d2..ffc8ea1 100644 --- a/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc +++ b/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
@@ -115,7 +115,7 @@ SchedulerWorkerPoolImpl* worker_pool, test::ExecutionMode execution_mode) { // Allow tasks posted to the returned TaskRunner to wait on a WaitableEvent. - const TaskTraits traits = TaskTraits().WithWait(); + const TaskTraits traits = TaskTraits().WithSyncPrimitives(); switch (execution_mode) { case test::ExecutionMode::PARALLEL: return worker_pool->CreateTaskRunnerWithTraits(traits); @@ -543,7 +543,8 @@ std::vector<std::unique_ptr<test::TestTaskFactory>> factories; for (size_t i = 0; i < kNumWorkersInWorkerPool; ++i) { factories.push_back(MakeUnique<test::TestTaskFactory>( - worker_pool_->CreateTaskRunnerWithTraits(TaskTraits().WithWait()), + worker_pool_->CreateTaskRunnerWithTraits( + TaskTraits().WithSyncPrimitives()), test::ExecutionMode::PARALLEL)); ASSERT_TRUE(factories.back()->PostTask( PostNestedTask::NO, @@ -615,7 +616,7 @@ WaitableEvent::InitialState::NOT_SIGNALED); InitializeWorkerPool(TimeDelta::Max(), kNumWorkersInWorkerPool); auto task_runner = worker_pool_->CreateSequencedTaskRunnerWithTraits( - TaskTraits().WithWait()); + TaskTraits().WithSyncPrimitives()); // Post a task. task_runner->PostTask(FROM_HERE, @@ -658,8 +659,8 @@ WaitableEvent tasks_can_exit_event(WaitableEvent::ResetPolicy::MANUAL, WaitableEvent::InitialState::NOT_SIGNALED); InitializeWorkerPool(kReclaimTimeForDetachTests, kNumWorkersInWorkerPool); - auto task_runner = - worker_pool_->CreateTaskRunnerWithTraits(TaskTraits().WithWait()); + auto task_runner = worker_pool_->CreateTaskRunnerWithTraits( + TaskTraits().WithSyncPrimitives()); // Post tasks to saturate the pool. std::vector<std::unique_ptr<WaitableEvent>> task_started_events;
diff --git a/base/task_scheduler/task_scheduler_impl_unittest.cc b/base/task_scheduler/task_scheduler_impl_unittest.cc index 300a439..8e22b69 100644 --- a/base/task_scheduler/task_scheduler_impl_unittest.cc +++ b/base/task_scheduler/task_scheduler_impl_unittest.cc
@@ -67,7 +67,7 @@ #if DCHECK_IS_ON() // The #if above is required because GetIOAllowed() always returns true when // !DCHECK_IS_ON(), even when |traits| don't allow file I/O. - EXPECT_EQ(traits.with_file_io(), GetIOAllowed()); + EXPECT_EQ(traits.may_block(), GetIOAllowed()); #endif // Verify that the thread the task is running on is named as expected. @@ -77,8 +77,8 @@ current_thread_name.find( traits.priority() == TaskPriority::BACKGROUND ? "Background" : "Foreground")); - EXPECT_EQ(traits.with_file_io(), - current_thread_name.find("FileIO") != std::string::npos); + EXPECT_EQ(traits.may_block(), + current_thread_name.find("Blocking") != std::string::npos); } void VerifyTaskEnvironementAndSignalEvent(const TaskTraits& traits, @@ -138,7 +138,7 @@ }; // Returns a vector with a TraitsExecutionModePair for each valid -// combination of {ExecutionMode, TaskPriority, WithFileIO()}. +// combination of {ExecutionMode, TaskPriority, MayBlock()}. std::vector<TraitsExecutionModePair> GetTraitsExecutionModePairs() { std::vector<TraitsExecutionModePair> params; @@ -154,7 +154,7 @@ params.push_back(TraitsExecutionModePair( TaskTraits().WithPriority(priority), execution_mode)); params.push_back(TraitsExecutionModePair( - TaskTraits().WithPriority(priority).WithFileIO(), execution_mode)); + TaskTraits().WithPriority(priority).MayBlock(), execution_mode)); } } @@ -163,16 +163,16 @@ enum WorkerPoolType { BACKGROUND_WORKER_POOL = 0, - BACKGROUND_FILE_IO_WORKER_POOL, + BACKGROUND_BLOCKING_WORKER_POOL, FOREGROUND_WORKER_POOL, - FOREGROUND_FILE_IO_WORKER_POOL, + FOREGROUND_BLOCKING_WORKER_POOL, }; size_t GetThreadPoolIndexForTraits(const TaskTraits& traits) { - if (traits.with_file_io()) { + if (traits.may_block()) { return traits.priority() == TaskPriority::BACKGROUND - ? BACKGROUND_FILE_IO_WORKER_POOL - : FOREGROUND_FILE_IO_WORKER_POOL; + ? BACKGROUND_BLOCKING_WORKER_POOL + : FOREGROUND_BLOCKING_WORKER_POOL; } return traits.priority() == TaskPriority::BACKGROUND ? BACKGROUND_WORKER_POOL : FOREGROUND_WORKER_POOL; @@ -192,16 +192,16 @@ params_vector.emplace_back("Background", ThreadPriority::BACKGROUND, StandbyThreadPolicy::LAZY, 1U, TimeDelta::Max()); - ASSERT_EQ(BACKGROUND_FILE_IO_WORKER_POOL, params_vector.size()); - params_vector.emplace_back("BackgroundFileIO", ThreadPriority::BACKGROUND, + ASSERT_EQ(BACKGROUND_BLOCKING_WORKER_POOL, params_vector.size()); + params_vector.emplace_back("BackgroundBlocking", ThreadPriority::BACKGROUND, StandbyThreadPolicy::LAZY, 3U, TimeDelta::Max()); ASSERT_EQ(FOREGROUND_WORKER_POOL, params_vector.size()); params_vector.emplace_back("Foreground", ThreadPriority::NORMAL, StandbyThreadPolicy::LAZY, 4U, TimeDelta::Max()); - ASSERT_EQ(FOREGROUND_FILE_IO_WORKER_POOL, params_vector.size()); - params_vector.emplace_back("ForegroundFileIO", ThreadPriority::NORMAL, + ASSERT_EQ(FOREGROUND_BLOCKING_WORKER_POOL, params_vector.size()); + params_vector.emplace_back("ForegroundBlocking", ThreadPriority::NORMAL, StandbyThreadPolicy::LAZY, 12U, TimeDelta::Max());
diff --git a/base/task_scheduler/task_tracker.cc b/base/task_scheduler/task_tracker.cc index 447b35a..fbeecd3 100644 --- a/base/task_scheduler/task_tracker.cc +++ b/base/task_scheduler/task_tracker.cc
@@ -225,9 +225,9 @@ task->traits.shutdown_behavior() != TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); const bool previous_io_allowed = - ThreadRestrictions::SetIOAllowed(task->traits.with_file_io()); + ThreadRestrictions::SetIOAllowed(task->traits.may_block()); const bool previous_wait_allowed = - ThreadRestrictions::SetWaitAllowed(task->traits.with_wait()); + ThreadRestrictions::SetWaitAllowed(task->traits.with_sync_primitives()); { ScopedSetSequenceTokenForCurrentThread
diff --git a/base/task_scheduler/task_tracker_unittest.cc b/base/task_scheduler/task_tracker_unittest.cc index e1a4229..c8dbbfd 100644 --- a/base/task_scheduler/task_tracker_unittest.cc +++ b/base/task_scheduler/task_tracker_unittest.cc
@@ -264,7 +264,8 @@ WaitableEvent::InitialState::NOT_SIGNALED); auto blocked_task = base::MakeUnique<Task>( FROM_HERE, Bind(&WaitableEvent::Wait, Unretained(&event)), - TaskTraits().WithWait().WithShutdownBehavior(GetParam()), TimeDelta()); + TaskTraits().WithSyncPrimitives().WithShutdownBehavior(GetParam()), + TimeDelta()); // Inform |task_tracker_| that |blocked_task| will be posted. EXPECT_TRUE(tracker_.WillPostTask(blocked_task.get())); @@ -431,32 +432,32 @@ } } -// Verify that AssertIOAllowed() succeeds only for a WithFileIO() task. +// Verify that AssertIOAllowed() succeeds only for a MayBlock() task. TEST_P(TaskSchedulerTaskTrackerTest, IOAllowed) { TaskTracker tracker; // Unset the IO allowed bit. Expect TaskTracker to set it before running a - // task with the WithFileIO() trait. + // task with the MayBlock() trait. ThreadRestrictions::SetIOAllowed(false); - auto task_with_file_io = MakeUnique<Task>( + auto task_with_may_block = MakeUnique<Task>( FROM_HERE, Bind([]() { // Shouldn't fail. ThreadRestrictions::AssertIOAllowed(); }), - TaskTraits().WithFileIO().WithShutdownBehavior(GetParam()), TimeDelta()); - EXPECT_TRUE(tracker.WillPostTask(task_with_file_io.get())); - tracker.RunTask(std::move(task_with_file_io), SequenceToken::Create()); + TaskTraits().MayBlock().WithShutdownBehavior(GetParam()), TimeDelta()); + EXPECT_TRUE(tracker.WillPostTask(task_with_may_block.get())); + tracker.RunTask(std::move(task_with_may_block), SequenceToken::Create()); // Set the IO allowed bit. Expect TaskTracker to unset it before running a - // task without the WithFileIO() trait. + // task without the MayBlock() trait. ThreadRestrictions::SetIOAllowed(true); - auto task_without_file_io = MakeUnique<Task>( + auto task_without_may_block = MakeUnique<Task>( FROM_HERE, Bind([]() { EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertIOAllowed(); }); }), TaskTraits().WithShutdownBehavior(GetParam()), TimeDelta()); - EXPECT_TRUE(tracker.WillPostTask(task_without_file_io.get())); - tracker.RunTask(std::move(task_without_file_io), SequenceToken::Create()); + EXPECT_TRUE(tracker.WillPostTask(task_without_may_block.get())); + tracker.RunTask(std::move(task_without_may_block), SequenceToken::Create()); } static void RunTaskRunnerHandleVerificationTask( @@ -843,27 +844,29 @@ TaskTracker tracker; // Waiting is allowed by default. Expect TaskTracker to disallow it before - // running a task without the WithWait() trait. + // running a task without the WithSyncPrimitives() trait. ThreadRestrictions::AssertWaitAllowed(); - auto task_without_wait = MakeUnique<Task>( + auto task_without_sync_primitives = MakeUnique<Task>( FROM_HERE, Bind([]() { EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertWaitAllowed(); }); }), TaskTraits(), TimeDelta()); - EXPECT_TRUE(tracker.WillPostTask(task_without_wait.get())); - tracker.RunTask(std::move(task_without_wait), SequenceToken::Create()); + EXPECT_TRUE(tracker.WillPostTask(task_without_sync_primitives.get())); + tracker.RunTask(std::move(task_without_sync_primitives), + SequenceToken::Create()); // Disallow waiting. Expect TaskTracker to allow it before running a task - // with the WithWait() trait. + // with the WithSyncPrimitives() trait. ThreadRestrictions::DisallowWaiting(); - auto task_with_wait = + auto task_with_sync_primitives = MakeUnique<Task>(FROM_HERE, Bind([]() { // Shouldn't fail. ThreadRestrictions::AssertWaitAllowed(); }), - TaskTraits().WithWait(), TimeDelta()); - EXPECT_TRUE(tracker.WillPostTask(task_with_wait.get())); - tracker.RunTask(std::move(task_with_wait), SequenceToken::Create()); + TaskTraits().WithSyncPrimitives(), TimeDelta()); + EXPECT_TRUE(tracker.WillPostTask(task_with_sync_primitives.get())); + tracker.RunTask(std::move(task_with_sync_primitives), + SequenceToken::Create()); } DISALLOW_COPY_AND_ASSIGN(WaitAllowedTestThread); @@ -871,7 +874,7 @@ } // namespace -// Verify that AssertIOAllowed() succeeds for a WithWait() task. +// Verify that AssertIOAllowed() succeeds only for a WithSyncPrimitives() task. TEST(TaskSchedulerTaskTrackerWaitAllowedTest, WaitAllowed) { // Run the test on the separate thread since it is not possible to reset the // "wait allowed" bit of a thread without being a friend of
diff --git a/base/task_scheduler/task_traits.cc b/base/task_scheduler/task_traits.cc index 9ebe821..3cd6a61 100644 --- a/base/task_scheduler/task_traits.cc +++ b/base/task_scheduler/task_traits.cc
@@ -17,23 +17,31 @@ // the header; anything else is subject to change. Tasks should explicitly // request defaults if the behavior is critical to the task. TaskTraits::TaskTraits() - : with_file_io_(false), - with_wait_(false), + : may_block_(false), + with_sync_primitives_(false), priority_(internal::GetTaskPriorityForCurrentThread()), shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {} TaskTraits::~TaskTraits() = default; -TaskTraits& TaskTraits::WithFileIO() { - with_file_io_ = true; +TaskTraits& TaskTraits::MayBlock() { + may_block_ = true; return *this; } -TaskTraits& TaskTraits::WithWait() { - with_wait_ = true; +TaskTraits& TaskTraits::WithSyncPrimitives() { + with_sync_primitives_ = true; return *this; } +TaskTraits& TaskTraits::WithFileIO() { + return MayBlock(); +} + +TaskTraits& TaskTraits::WithWait() { + return MayBlock().WithSyncPrimitives(); +} + TaskTraits& TaskTraits::WithPriority(TaskPriority priority) { priority_ = priority; return *this;
diff --git a/base/task_scheduler/task_traits.h b/base/task_scheduler/task_traits.h index 0fcde2dc..d2694225 100644 --- a/base/task_scheduler/task_traits.h +++ b/base/task_scheduler/task_traits.h
@@ -78,9 +78,9 @@ // Describes metadata for a single task or a group of tasks. class BASE_EXPORT TaskTraits { public: - // Constructs a default TaskTraits for tasks with - // (1) no I/O, - // (2) priority inherited from the calling context, and + // Constructs a default TaskTraits for tasks that + // (1) do not make blocking calls + // (2) can inherit their priority from the calling context, and // (3) may block shutdown or be skipped on shutdown. // Tasks that require stricter guarantees and/or know the specific // TaskPriority appropriate for them should highlight those by requesting @@ -90,13 +90,41 @@ TaskTraits& operator=(const TaskTraits& other) = default; ~TaskTraits(); - // Allows tasks with these traits to wait on synchronous file I/O. + // Tasks with this trait may block. This includes but is not limited to tasks + // that wait on synchronous file I/O operations: read or write a file from + // disk, interact with a pipe or a socket, rename or delete a file, enumerate + // files in a directory, etc. This trait isn't required for the mere use of + // locks. For tasks that block on synchronization primitives (thread or + // process handles, waitable events, condition variables), see + // WithSyncPrimitives(). + TaskTraits& MayBlock(); + + // Tasks with this trait are allowed to wait on waitable events and condition + // variables as well as to join threads and processes. This trait implies + // MayBlock(). + // + // This trait should generally not be used. + // + // Instead of waiting on a waitable event or a condition variable, put the + // work that should happen after the wait in a callback and post that callback + // from where the waitable event or condition variable would have been + // signaled. If something needs to be scheduled after many tasks have + // executed, use base::BarrierClosure. + // + // On Windows, join processes asynchronously using base::win::ObjectWatcher. + // + // Avoid creating threads. Instead, use + // base::Create(Sequenced|SingleTreaded)TaskRunnerWithTraits(). If a thread is + // really needed, make it non-joinable and add cleanup work at the end of the + // thread's main function (if using base::Thread, override Cleanup()). + TaskTraits& WithSyncPrimitives(); + + // DEPRECATED + // TODO(fdoray): Remove this as part of crbug.com/675660 TaskTraits& WithFileIO(); - // Allows tasks with these traits to wait on things other than file I/O. In - // particular, they may wait on a WaitableEvent or a ConditionVariable, join a - // thread or a process, or make a blocking system call that doesn't involve - // interactions with the file system. + // DEPRECATED + // TODO(fdoray): Remove this as part of crbug.com/675660 TaskTraits& WithWait(); // Applies |priority| to tasks with these traits. @@ -105,12 +133,15 @@ // Applies |shutdown_behavior| to tasks with these traits. TaskTraits& WithShutdownBehavior(TaskShutdownBehavior shutdown_behavior); - // Returns true if waiting on synchronous file I/O is allowed by these traits. - bool with_file_io() const { return with_file_io_; } + // Returns true if tasks with these traits may block. + bool may_block() const { return may_block_; } - // Returns true if waiting on things other than file I/O is allowed by these - // traits. - bool with_wait() const { return with_wait_; } + // Returns true if tasks with these traits may wait on sync primitives. + bool with_sync_primitives() const { return with_sync_primitives_; } + + // DEPRECATED + // TODO(fdoray): Remove this as part of crbug.com/675660 + bool with_file_io() const { return may_block(); } // Returns the priority of tasks with these traits. TaskPriority priority() const { return priority_; } @@ -119,8 +150,8 @@ TaskShutdownBehavior shutdown_behavior() const { return shutdown_behavior_; } private: - bool with_file_io_; - bool with_wait_; + bool may_block_; + bool with_sync_primitives_; TaskPriority priority_; TaskShutdownBehavior shutdown_behavior_; };
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc index af22098ef..16a7290 100644 --- a/base/threading/sequenced_worker_pool.cc +++ b/base/threading/sequenced_worker_pool.cc
@@ -818,8 +818,8 @@ const TaskShutdownBehavior task_shutdown_behavior = static_cast<TaskShutdownBehavior>(sequenced.shutdown_behavior); const TaskTraits traits = TaskTraits() - .WithFileIO() - .WithWait() + .MayBlock() + .WithSyncPrimitives() .WithPriority(task_priority_) .WithShutdownBehavior(task_shutdown_behavior); return GetTaskSchedulerTaskRunner(sequenced.sequence_token_id, traits) @@ -870,7 +870,8 @@ if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { if (!runs_tasks_on_verifier_) { runs_tasks_on_verifier_ = CreateTaskRunnerWithTraits( - TaskTraits().WithFileIO().WithWait().WithPriority(task_priority_)); + TaskTraits().MayBlock().WithSyncPrimitives().WithPriority( + task_priority_)); } return runs_tasks_on_verifier_->RunsTasksOnCurrentThread(); } else {
diff --git a/build/android/pylib/local/device/local_device_perf_test_run.py b/build/android/pylib/local/device/local_device_perf_test_run.py index afbd4e9..799dedc 100644 --- a/build/android/pylib/local/device/local_device_perf_test_run.py +++ b/build/android/pylib/local/device/local_device_perf_test_run.py
@@ -113,7 +113,9 @@ exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( cmd, timeout, cwd=cwd, shell=True) end_time = time.time() - json_output = self._test_instance.ReadChartjsonOutput(self._output_dir) + chart_json_output = self._test_instance.ReadChartjsonOutput( + self._output_dir) + json_output = self._test_instance.ReadJsonOutput(self._output_dir) if exit_code == 0: result_type = base_test_result.ResultType.PASS else: @@ -122,10 +124,12 @@ end_time = time.time() exit_code = -1 output = e.output + chart_json_output = '' json_output = '' result_type = base_test_result.ResultType.TIMEOUT return self._ProcessTestResult(test, cmd, start_time, end_time, exit_code, - output, json_output, result_type) + output, chart_json_output, json_output, + result_type) def _CreateCmd(self, test): cmd = [] @@ -134,6 +138,7 @@ cmd.append(self._tests[test]['cmd']) if self._output_dir: cmd.append('--output-dir=%s' % self._output_dir) + cmd.append('--output-format=json') return ' '.join(self._ExtendCmd(cmd)) def _ExtendCmd(self, cmd): # pylint: disable=no-self-use @@ -150,7 +155,7 @@ raise NotImplementedError def _ProcessTestResult(self, test, cmd, start_time, end_time, exit_code, - output, json_output, result_type): + output, chart_json_output, json_output, result_type): if exit_code is None: exit_code = -1 @@ -166,7 +171,8 @@ persisted_result = { 'name': test, 'output': [output], - 'chartjson': json_output, + 'chartjson': chart_json_output, + 'json': json_output, 'archive_bytes': archive_bytes, 'exit_code': exit_code, 'actual_exit_code': actual_exit_code,
diff --git a/build/android/pylib/perf/perf_test_instance.py b/build/android/pylib/perf/perf_test_instance.py index 3121d8d..84663368 100644 --- a/build/android/pylib/perf/perf_test_instance.py +++ b/build/android/pylib/perf/perf_test_instance.py
@@ -73,6 +73,7 @@ self._min_battery_level = args.min_battery_level self._no_timeout = args.no_timeout self._output_chartjson_data = args.output_chartjson_data + self._output_json_data = args.output_json_data self._output_json_list = args.output_json_list self._print_step = args.print_step self._single_step = ( @@ -107,7 +108,7 @@ data['has_archive'] = persisted_result['archive_bytes'] is not None step_values.append(data) - with file(self._output_json_list, 'w') as o: + with file(self.output_json_list, 'w') as o: o.write(json.dumps(step_values)) return base_test_result.ResultType.PASS except KeyError: @@ -137,13 +138,17 @@ i, persisted_outputs[i]) print output_formatted - if self._output_chartjson_data: - with file(self._output_chartjson_data, 'w') as f: + if self.output_json_data: + with file(self.output_json_data, 'w') as f: + f.write(persisted_result['json']) + + if self.output_chartjson_data: + with file(self.output_chartjson_data, 'w') as f: f.write(persisted_result['chartjson']) - if self._output_dir_archive_path: + if self.output_dir_archive_path: if persisted_result['archive_bytes'] is not None: - with file(self._output_dir_archive_path, 'wb') as f: + with file(self.output_dir_archive_path, 'wb') as f: f.write(persisted_result['archive_bytes']) else: logging.error('The output dir was not archived.') @@ -170,6 +175,21 @@ ' the test.') return '' + @staticmethod + def ReadJsonOutput(output_dir): + if not output_dir: + return '' + json_output_path = os.path.join(output_dir, 'results.json') + try: + with open(json_output_path) as f: + return f.read() + except IOError: + logging.exception('Exception when reading results.json.') + logging.error('This usually means that telemetry did not run, so it could' + ' not generate the file. Please check the device running' + ' the test.') + return '' + def WriteBuildBotJson(self, output_dir): """Write metadata about the buildbot environment to the output dir.""" if not output_dir or not self._write_buildbot_json: @@ -218,6 +238,10 @@ return self._output_dir_archive_path @property + def output_json_data(self): + return self._output_json_data + + @property def output_json_list(self): return self._output_json_list
diff --git a/build/android/test_runner.py b/build/android/test_runner.py index 612060af..d2b9fad 100755 --- a/build/android/test_runner.py +++ b/build/android/test_runner.py
@@ -500,7 +500,9 @@ group.add_argument( '--output-json-list', type=os.path.realpath, - help='Write a simple list of names from --steps into the given file.') + help='Writes a JSON list of information for each --steps into the given ' + 'file. Information includes runtime and device affinity for each ' + '--steps.') group.add_argument( '--collect-chartjson-data', action='store_true', @@ -508,7 +510,11 @@ group.add_argument( '--output-chartjson-data', type=os.path.realpath, - help='Write out chartjson into the given file.') + help='Writes telemetry chartjson formatted output into the given file.') + group.add_argument( + '--output-json-data', + type=os.path.realpath, + help='Writes telemetry JSON formatted output into the given file.') # TODO(rnephew): Remove this when everything moves to new option in platform # mode. group.add_argument(
diff --git a/cc/input/main_thread_scrolling_reason.h b/cc/input/main_thread_scrolling_reason.h index 8cc83d3e..191318b 100644 --- a/cc/input/main_thread_scrolling_reason.h +++ b/cc/input/main_thread_scrolling_reason.h
@@ -31,6 +31,7 @@ // animation running on the main thread or on the compositor thread. kHandlingScrollFromMainThread = 1 << 13, kCustomScrollbarScrolling = 1 << 15, + kHasOpacity = 1 << 16, // Transient scrolling reasons. These are computed for each scroll begin. kNonFastScrollableRegion = 1 << 5, @@ -42,7 +43,7 @@ kPageBasedScrolling = 1 << 12, // The number of flags in this struct (excluding itself). - kMainThreadScrollingReasonCount = 17, + kMainThreadScrollingReasonCount = 18, }; // Returns true if the given MainThreadScrollingReason can be set by the main @@ -52,7 +53,7 @@ kNotScrollingOnMain | kHasBackgroundAttachmentFixedObjects | kHasNonLayerViewportConstrainedObjects | kThreadedScrollingDisabled | kScrollbarScrolling | kPageOverlay | kHandlingScrollFromMainThread | - kCustomScrollbarScrolling; + kCustomScrollbarScrolling | kHasOpacity; return (reasons & reasons_set_by_main_thread) == reasons; } @@ -97,6 +98,8 @@ tracedValue->AppendString("Handling scroll from main thread"); if (reasons & MainThreadScrollingReason::kCustomScrollbarScrolling) tracedValue->AppendString("Custom scrollbar scrolling"); + if (reasons & MainThreadScrollingReason::kHasOpacity) + tracedValue->AppendString("Has opacity"); // Transient scrolling reasons. if (reasons & MainThreadScrollingReason::kNonFastScrollableRegion) @@ -115,6 +118,20 @@ tracedValue->AppendString("Page-based scrolling"); tracedValue->EndArray(); } + + // For a given reason, return its index in enum + static int getReasonIndex(uint32_t reason) { + // Multiple reasons provided + if (reason & (reason - 1)) + return -1; + + int index = 0; + while (reason > 0) { + reason = reason >> 1; + ++index; + } + return index; + } }; } // namespace cc
diff --git a/cc/layers/texture_layer_impl_unittest.cc b/cc/layers/texture_layer_impl_unittest.cc index f901cda..870962c 100644 --- a/cc/layers/texture_layer_impl_unittest.cc +++ b/cc/layers/texture_layer_impl_unittest.cc
@@ -150,6 +150,7 @@ TEST(TextureLayerImplTest, ResourceNotFreedOnGpuRasterToggle) { LayerTreeSettings settings; settings.gpu_rasterization_enabled = true; + bool released = false; LayerTestCommon::LayerImplTest impl(settings); impl.host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); @@ -171,7 +172,6 @@ impl.AddChildToRoot<TextureLayerImpl>(); texture_layer_impl->SetBounds(layer_size); texture_layer_impl->SetDrawsContent(true); - bool released = false; texture_layer_impl->SetTextureMailbox( texture_mailbox, SingleReleaseCallbackImpl::Create(base::Bind(
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java index 6027c5f9..fc69c7c 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java
@@ -48,9 +48,13 @@ @VisibleForTesting static final String EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url"; - // Supervisor package name @VisibleForTesting - static final Object SUPERVISOR_PKG = "com.google.android.instantapps.supervisor"; + static final String SUPERVISOR_PKG = "com.google.android.instantapps.supervisor"; + @VisibleForTesting + static final String[] SUPERVISOR_START_ACTIONS = { + "com.google.android.instantapps.START", + "com.google.android.instantapps.nmr1.INSTALL", + "com.google.android.instantapps.nmr1.VIEW" }; // An extra that may be specified on an intent:// URL that contains an encoded value for the // referrer field passed to the market:// URL in the case where the app is not present. @@ -455,8 +459,7 @@ } } - boolean isDirectInstantAppsIntent = isExternalProtocol - && SUPERVISOR_PKG.equals(intent.getPackage()); + boolean isDirectInstantAppsIntent = isExternalProtocol && isIntentToInstantApp(intent); boolean shouldProxyForInstantApps = isDirectInstantAppsIntent && mDelegate.isSerpReferrer(params.getTab()); if (shouldProxyForInstantApps) { @@ -536,6 +539,23 @@ } /** + * Checks whether {@param intent} is for an Instant App. Considers both package and actions that + * would resolve to Supervisor. + * @return Whether the given intent is going to open an Instant App. + */ + private boolean isIntentToInstantApp(Intent intent) { + if (SUPERVISOR_PKG.equals(intent.getPackage())) return true; + + String intentAction = intent.getAction(); + for (String action: SUPERVISOR_START_ACTIONS) { + if (action.equals(intentAction)) { + return true; + } + } + return false; + } + + /** * Clobber the current tab with fallback URL. * * @param browserFallbackUrl The fallback URL.
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java index 960451df..07d89145 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java
@@ -615,6 +615,19 @@ START_OTHER_ACTIVITY); assertFalse(mDelegate.startActivityIntent.hasExtra( InstantAppsHandler.IS_GOOGLE_SEARCH_REFERRER)); + + // Check that Supervisor is detected by action even without package + for (String action : ExternalNavigationHandler.SUPERVISOR_START_ACTIONS) { + String intentWithoutPackage = "intent://buzzfeed.com/tasty#Intent;scheme=http;" + + "action=" + action + ";" + + "S.com.google.android.instantapps.FALLBACK_PACKAGE=" + + "com.android.chrome;S.com.google.android.instantapps.INSTANT_APP_PACKAGE=" + + "com.yelp.android;S.android.intent.extra.REFERRER_NAME=" + + "https%3A%2F%2Fwww.google.com;end"; + mDelegate.setIsSerpReferrer(false); + checkUrl(intentWithoutPackage) + .expecting(OverrideUrlLoadingResult.NO_OVERRIDE, IGNORE); + } } @SmallTest
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/GeolocationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/GeolocationTest.java index 2ac8ac9..55e10fc 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/GeolocationTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/GeolocationTest.java
@@ -56,6 +56,7 @@ */ @Smoke @MediumTest + @CommandLineFlags.Add("disable-features=" + MODAL_FLAG) @Feature({"Location", "Main"}) public void testGeolocationPlumbingAllowedInfoBar() throws Exception { runTest("initiate_getCurrentPosition()", 1, false, false, false, false); @@ -104,6 +105,7 @@ * @throws Exception */ @MediumTest + @CommandLineFlags.Add("disable-features=" + MODAL_FLAG) @Feature({"Location"}) public void testGeolocationWatchInfoBar() throws Exception { runTest("initiate_watchPosition()", 2, false, false, false, false); @@ -126,7 +128,7 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add("enable-features=" + TOGGLE_FLAG) + @CommandLineFlags.Add({"enable-features=" + TOGGLE_FLAG, "disable-features=" + MODAL_FLAG}) @Feature({"Location"}) public void testGeolocationPersistenceAllowedInfoBar() throws Exception { runTest("initiate_getCurrentPosition()", 1, false, false, true, false); @@ -150,7 +152,7 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add("enable-features=" + TOGGLE_FLAG) + @CommandLineFlags.Add({"enable-features=" + TOGGLE_FLAG, "disable-features=" + MODAL_FLAG}) @Feature({"Location"}) public void testGeolocationPersistenceOffAllowedInfoBar() throws Exception { Tab tab = getActivity().getActivityTab(); @@ -204,7 +206,7 @@ * @throws Exception */ @LargeTest - @CommandLineFlags.Add("enable-features=" + TOGGLE_FLAG) + @CommandLineFlags.Add({"enable-features=" + TOGGLE_FLAG, "disable-features=" + MODAL_FLAG}) @Feature({"Location"}) public void testGeolocationWatchPersistenceOffAllowedInfoBar() throws Exception { runTest("initiate_watchPosition()", 2, false, false, true, true);
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/MediaTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/MediaTest.java index a5f7349..8474327 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/MediaTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/MediaTest.java
@@ -39,7 +39,7 @@ */ @MediumTest @Feature({"MediaPermissions", "Main"}) - @CommandLineFlags.Add(FAKE_DEVICE) + @CommandLineFlags.Add({FAKE_DEVICE, "disable-features=" + MODAL_FLAG}) public void testMicrophonePermissionsPlumbingInfoBar() throws Exception { testMediaPermissionsPlumbing( "Mic count:", "initiate_getMicrophone()", 1, false, false, false, false); @@ -63,7 +63,7 @@ */ @MediumTest @Feature({"MediaPermissions", "Main"}) - @CommandLineFlags.Add(FAKE_DEVICE) + @CommandLineFlags.Add({FAKE_DEVICE, "disable-features=" + MODAL_FLAG}) public void testCameraPermissionsPlumbingInfoBar() throws Exception { testMediaPermissionsPlumbing( "Camera count:", "initiate_getCamera()", 1, false, false, false, false); @@ -114,7 +114,10 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add({FAKE_DEVICE, "enable-features=" + TOGGLE_FLAG}) + @CommandLineFlags.Add({ + FAKE_DEVICE, + "enable-features=" + TOGGLE_FLAG, + "disable-features=" + MODAL_FLAG}) @Feature({"MediaPermissions"}) public void testMicrophonePersistenceOnInfoBar() throws Exception { testMediaPermissionsPlumbing( @@ -127,7 +130,10 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add({FAKE_DEVICE, "enable-features=" + TOGGLE_FLAG}) + @CommandLineFlags.Add({ + FAKE_DEVICE, + "enable-features=" + TOGGLE_FLAG, + "disable-features=" + MODAL_FLAG}) @Feature({"MediaPermissions"}) public void testMicrophonePersistenceOffInfoBar() throws Exception { testMediaPermissionsPlumbing( @@ -166,7 +172,10 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add({FAKE_DEVICE, "enable-features=" + TOGGLE_FLAG}) + @CommandLineFlags.Add({ + FAKE_DEVICE, + "enable-features=" + TOGGLE_FLAG, + "disable-features=" + MODAL_FLAG}) @Feature({"MediaPermissions"}) public void testCameraPersistenceOn() throws Exception { testMediaPermissionsPlumbing( @@ -179,7 +188,10 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add({FAKE_DEVICE, "enable-features=" + TOGGLE_FLAG}) + @CommandLineFlags.Add({ + FAKE_DEVICE, + "enable-features=" + TOGGLE_FLAG, + "disable-features=" + MODAL_FLAG}) @Feature({"MediaPermissions"}) public void testCameraPersistenceOff() throws Exception { testMediaPermissionsPlumbing( @@ -192,7 +204,10 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add({FAKE_DEVICE, "enable-features=" + TOGGLE_FLAG}) + @CommandLineFlags.Add({ + FAKE_DEVICE, + "enable-features=" + TOGGLE_FLAG, + "disable-features=" + MODAL_FLAG}) @Feature({"MediaPermissions"}) public void testCombinedPersistenceOnInfoBar() throws Exception { testMediaPermissionsPlumbing( @@ -205,7 +220,10 @@ * @throws Exception */ @MediumTest - @CommandLineFlags.Add({FAKE_DEVICE, "enable-features=" + TOGGLE_FLAG}) + @CommandLineFlags.Add({ + FAKE_DEVICE, + "enable-features=" + TOGGLE_FLAG, + "disable-features=" + MODAL_FLAG}) @Feature({"MediaPermissions"}) public void testCombinedPersistenceOffInfoBar() throws Exception { testMediaPermissionsPlumbing(
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java index 3da468ce..8b661f66 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java
@@ -18,6 +18,7 @@ import org.chromium.base.ThreadUtils; import org.chromium.base.library_loader.ProcessInitException; import org.chromium.base.test.util.CallbackHelper; +import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.RetryOnFailure; import org.chromium.chrome.browser.infobar.InfoBar; @@ -116,6 +117,7 @@ */ @MediumTest @Feature({"Browser", "PushMessaging"}) + @CommandLineFlags.Add("disable-features=ModalPermissionPrompts") public void testPushPermissionDenied() throws InterruptedException, TimeoutException { // Notifications permission should initially be prompt. assertEquals("\"default\"", runScriptBlocking("Notification.permission")); @@ -166,6 +168,7 @@ */ @MediumTest @Feature({"Browser", "PushMessaging"}) + @CommandLineFlags.Add("disable-features=ModalPermissionPrompts") public void testPushPermissionGranted() throws InterruptedException, TimeoutException { // Notifications permission should initially be prompt. assertEquals("\"default\"", runScriptBlocking("Notification.permission"));
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/findinpage/FindTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/findinpage/FindTest.java index 6b6ce25d5..94355d1 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/findinpage/FindTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/findinpage/FindTest.java
@@ -28,7 +28,9 @@ import org.chromium.base.test.util.FlakyTest; import org.chromium.base.test.util.RetryOnFailure; import org.chromium.chrome.R; +import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.test.ChromeTabbedActivityTestBase; +import org.chromium.chrome.test.util.FullscreenTestUtils; import org.chromium.chrome.test.util.MenuUtils; import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.CriteriaHelper; @@ -224,6 +226,46 @@ waitForFindResults("1/7"); } + /** + * Verify that Next/Previous buttons are disabled whenever there is no match. + */ + @MediumTest + @Feature({"FindInPage"}) + @RetryOnFailure + public void testFindNextPreviousOnNoMatch() throws InterruptedException { + loadTestAndVerifyFindInPage("pp", "0/0"); + + final TextView findQueryText = getFindQueryText(); + View next = getActivity().findViewById(R.id.find_next_button); + View prev = getActivity().findViewById(R.id.find_prev_button); + assertFalse(next.isEnabled()); + assertFalse(prev.isEnabled()); + + KeyUtils.singleKeyEventView(getInstrumentation(), findQueryText, KeyEvent.KEYCODE_DEL); + KeyUtils.singleKeyEventView(getInstrumentation(), findQueryText, KeyEvent.KEYCODE_DEL); + + loadTestAndVerifyFindInPage("pitts", "1/7"); + assertTrue(next.isEnabled()); + assertTrue(prev.isEnabled()); + } + + /** + * Verify that Find in page toolbar is dismissed on entering fullscreen. + */ + @MediumTest + @Feature({"FindInPage"}) + @RetryOnFailure + public void testFullscreen() throws InterruptedException { + loadTestAndVerifyFindInPage("pitts", "1/7"); + + Tab tab = getActivity().getActivityTab(); + FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, true, getActivity()); + waitForFindInPageVisibility(false); + + FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getActivity()); + waitForFindInPageVisibility(false); + } + @MediumTest @Feature({"FindInPage"}) @RetryOnFailure @@ -379,10 +421,7 @@ @Feature({"FindInPage"}) @RetryOnFailure public void testBackKeyDismissesFind() throws InterruptedException { - loadUrl(mTestServer.getURL(FILEPATH)); - findInPageFromMenu(); - final TextView findQueryText = getFindQueryText(); - KeyUtils.singleKeyEventView(getInstrumentation(), findQueryText, KeyEvent.KEYCODE_A); + loadTestAndVerifyFindInPage("pitts", "1/7"); waitForIME(true); // Hide IME by clicking next button from find tool bar. singleClickView(getActivity().findViewById(R.id.find_next_button));
diff --git a/chrome/app/chrome_exe_main_win.cc b/chrome/app/chrome_exe_main_win.cc index c305453..b95c04a 100644 --- a/chrome/app/chrome_exe_main_win.cc +++ b/chrome/app/chrome_exe_main_win.cc
@@ -198,6 +198,11 @@ } // namespace +#if defined(SYZYASAN) +// This is in chrome_elf. +extern "C" void BlockUntilHandlerStartedImpl(); +#endif // SYZYASAN + #if !defined(WIN_CONSOLE_APP) int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { #else @@ -232,6 +237,14 @@ // Signal Chrome Elf that Chrome has begun to start. SignalChromeElf(); +#if defined(SYZYASAN) + if (process_type.empty()) { + // This is a temporary workaround for a race during startup with the + // syzyasan_rtl.dll. See https://crbug.com/675710. + BlockUntilHandlerStartedImpl(); + } +#endif // SYZYASAN + // The exit manager is in charge of calling the dtors of singletons. base::AtExitManager exit_manager;
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index b436041..821bb4a 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -210,6 +210,8 @@ "app_mode/startup_app_launcher.h", "arc/arc_auth_context.cc", "arc/arc_auth_context.h", + "arc/arc_auth_notification.cc", + "arc/arc_auth_notification.h", "arc/arc_auth_service.cc", "arc/arc_auth_service.h", "arc/arc_optin_uma.cc",
diff --git a/chrome/browser/chromeos/arc/arc_auth_notification.cc b/chrome/browser/chromeos/arc/arc_auth_notification.cc new file mode 100644 index 0000000..02718a3 --- /dev/null +++ b/chrome/browser/chromeos/arc/arc_auth_notification.cc
@@ -0,0 +1,122 @@ +// Copyright 2016 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. + +#include "chrome/browser/chromeos/arc/arc_auth_notification.h" + +#include "ash/common/system/chromeos/devicetype_utils.h" +#include "base/macros.h" +#include "base/strings/utf_string_conversions.h" +#include "chrome/browser/chromeos/arc/arc_optin_uma.h" +#include "chrome/browser/chromeos/arc/arc_session_manager.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/ash/multi_user/multi_user_util.h" +#include "chrome/grit/generated_resources.h" +#include "chrome/grit/theme_resources.h" +#include "components/signin/core/account_id/account_id.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/message_center/message_center.h" +#include "ui/message_center/message_center_observer.h" +#include "ui/message_center/notification.h" +#include "ui/message_center/notification_delegate.h" +#include "url/gurl.h" + +namespace { + +// Ids of the notification shown on first run. +const char kNotifierId[] = "arc_auth"; +const char kDisplaySource[] = "arc_auth_source"; +const char kFirstRunNotificationId[] = "arc_auth/first_run"; + +class ArcAuthNotificationDelegate + : public message_center::NotificationDelegate, + public message_center::MessageCenterObserver { + public: + ArcAuthNotificationDelegate() {} + + // message_center::MessageCenterObserver + void OnNotificationUpdated(const std::string& notification_id) override { + if (notification_id != kFirstRunNotificationId) + return; + + StopObserving(); + message_center::Notification* notification = + message_center::MessageCenter::Get()->FindVisibleNotificationById( + notification_id); + if (!notification) { + NOTREACHED(); + return; + } + + if (!notification->IsRead()) + UpdateOptInActionUMA(arc::OptInActionType::NOTIFICATION_TIMED_OUT); + } + + // message_center::NotificationDelegate + void Display() override { StartObserving(); } + + void ButtonClick(int button_index) override { + StopObserving(); + if (button_index == 0) { + UpdateOptInActionUMA(arc::OptInActionType::NOTIFICATION_ACCEPTED); + arc::ArcSessionManager::Get()->EnableArc(); + } else { + UpdateOptInActionUMA(arc::OptInActionType::NOTIFICATION_DECLINED); + arc::ArcSessionManager::Get()->DisableArc(); + } + } + + void Close(bool by_user) override { StopObserving(); } + + private: + ~ArcAuthNotificationDelegate() override { StopObserving(); } + + void StartObserving() { + message_center::MessageCenter::Get()->AddObserver(this); + } + + void StopObserving() { + message_center::MessageCenter::Get()->RemoveObserver(this); + } + + DISALLOW_COPY_AND_ASSIGN(ArcAuthNotificationDelegate); +}; + +} // namespace + +namespace arc { + +// static +void ArcAuthNotification::Show(Profile* profile) { + message_center::NotifierId notifier_id( + message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); + notifier_id.profile_id = + multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail(); + + message_center::RichNotificationData data; + data.buttons.push_back(message_center::ButtonInfo( + l10n_util::GetStringUTF16(IDS_ARC_OPEN_PLAY_STORE_NOTIFICATION_BUTTON))); + data.buttons.push_back(message_center::ButtonInfo( + l10n_util::GetStringUTF16(IDS_ARC_CANCEL_NOTIFICATION_BUTTON))); + ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); + std::unique_ptr<message_center::Notification> notification( + new message_center::Notification( + message_center::NOTIFICATION_TYPE_SIMPLE, kFirstRunNotificationId, + l10n_util::GetStringUTF16(IDS_ARC_NOTIFICATION_TITLE), + l10n_util::GetStringFUTF16(IDS_ARC_NOTIFICATION_MESSAGE, + ash::GetChromeOSDeviceName()), + resource_bundle.GetImageNamed(IDR_ARC_PLAY_STORE_NOTIFICATION), + base::UTF8ToUTF16(kDisplaySource), GURL(), notifier_id, data, + new ArcAuthNotificationDelegate())); + message_center::MessageCenter::Get()->AddNotification( + std::move(notification)); +} + +// static +void ArcAuthNotification::Hide() { + message_center::MessageCenter::Get()->RemoveNotification( + kFirstRunNotificationId, false); +} + +} // namespace arc
diff --git a/chrome/browser/chromeos/arc/arc_auth_notification.h b/chrome/browser/chromeos/arc/arc_auth_notification.h new file mode 100644 index 0000000..76e47bb --- /dev/null +++ b/chrome/browser/chromeos/arc/arc_auth_notification.h
@@ -0,0 +1,21 @@ +// Copyright 2016 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. + +#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_NOTIFICATION_H_ +#define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_NOTIFICATION_H_ + +class Profile; + +namespace arc { + +// First run notification that can enable Arc. +class ArcAuthNotification { + public: + static void Show(Profile* profile); + static void Hide(); +}; + +} // namespace arc + +#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_NOTIFICATION_H_
diff --git a/chrome/browser/chromeos/arc/arc_session_manager.cc b/chrome/browser/chromeos/arc/arc_session_manager.cc index 256e119..d7486cc8 100644 --- a/chrome/browser/chromeos/arc/arc_session_manager.cc +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
@@ -15,6 +15,7 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "chrome/browser/chromeos/arc/arc_auth_context.h" +#include "chrome/browser/chromeos/arc/arc_auth_notification.h" #include "chrome/browser/chromeos/arc/arc_optin_uma.h" #include "chrome/browser/chromeos/arc/arc_support_host.h" #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_negotiator.h" @@ -476,9 +477,20 @@ if (IsArcEnabled()) OnOptInPreferenceChanged(); + + if (!g_disable_ui_for_testing && + !base::CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kEnableArcOOBEOptIn) && + profile_->IsNewProfile() && + !profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { + ArcAuthNotification::Show(profile_); + } } void ArcSessionManager::Shutdown() { + if (!g_disable_ui_for_testing) + ArcAuthNotification::Hide(); + ShutdownBridge(); if (support_host_) { support_host_->Close(); @@ -537,6 +549,13 @@ for (auto& observer : observer_list_) observer.OnArcOptInChanged(arc_enabled); + // Hide auth notification if it was opened before and arc.enabled pref was + // explicitly set to true or false. + if (!g_disable_ui_for_testing && + profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { + ArcAuthNotification::Hide(); + } + if (!arc_enabled) { // Reset any pending request to re-enable Arc. reenable_arc_ = false;
diff --git a/chrome/browser/data_use_measurement/chrome_data_use_recorder.h b/chrome/browser/data_use_measurement/chrome_data_use_recorder.h index 11775db..150b16a 100644 --- a/chrome/browser/data_use_measurement/chrome_data_use_recorder.h +++ b/chrome/browser/data_use_measurement/chrome_data_use_recorder.h
@@ -18,7 +18,7 @@ class ChromeDataUseRecorder : public DataUseRecorder { public: ChromeDataUseRecorder(); - ~ChromeDataUseRecorder(); + ~ChromeDataUseRecorder() override; RenderFrameHostID main_frame_id() const { return main_frame_id_; }
diff --git a/chrome/browser/media/router/media_source.cc b/chrome/browser/media/router/media_source.cc index d08ebbd..91f23d7 100644 --- a/chrome/browser/media/router/media_source.cc +++ b/chrome/browser/media/router/media_source.cc
@@ -6,9 +6,14 @@ #include <string> +#include "chrome/browser/media/router/media_source_helper.h" + namespace media_router { MediaSource::MediaSource(const MediaSource::Id& source_id) : id_(source_id) { + GURL url(source_id); + if (IsValidPresentationUrl(url)) + url_ = url; } MediaSource::MediaSource(const GURL& presentation_url)
diff --git a/chrome/browser/media/router/media_source_unittest.cc b/chrome/browser/media/router/media_source_unittest.cc index a4e92148..ea3f9ee 100644 --- a/chrome/browser/media/router/media_source_unittest.cc +++ b/chrome/browser/media/router/media_source_unittest.cc
@@ -21,4 +21,11 @@ EXPECT_EQ(test_url, source1.url()); } +TEST(MediaSourceTest, ConstructorWithURLString) { + GURL test_url = GURL("http://google.com"); + MediaSource source1(test_url.spec()); + EXPECT_EQ(test_url.spec(), source1.id()); + EXPECT_EQ(test_url, source1.url()); +} + } // namespace media_router
diff --git a/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc b/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc index 49665dd..003dd20 100644 --- a/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc
@@ -18,6 +18,10 @@ #include "net/test/embedded_test_server/embedded_test_server.h" #include "testing/gtest/include/gtest/gtest-param-test.h" +#if defined(OS_WIN) +#include "base/win/windows_version.h" +#endif + static const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html"; @@ -89,6 +93,17 @@ GetUserMediaAndGetStreamSize(tab, kVideoCallConstraintsVGA)); EXPECT_EQ("640x360", GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints360p)); + +// TODO(chfremer): Reenable these tests when https://crbug.com/676041 is +// resolved. +#if defined(OS_WIN) + auto win_version = base::win::GetVersion(); + if (win_version == base::win::VERSION_WIN8 || + win_version == base::win::VERSION_WIN8_1) { + return; + } +#endif + EXPECT_EQ("1280x720", GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints720p)); EXPECT_EQ("1920x1080",
diff --git a/chrome/browser/previews/previews_infobar_delegate.cc b/chrome/browser/previews/previews_infobar_delegate.cc index 80f8eab..3a34ccd 100644 --- a/chrome/browser/previews/previews_infobar_delegate.cc +++ b/chrome/browser/previews/previews_infobar_delegate.cc
@@ -109,7 +109,9 @@ bool PreviewsInfoBarDelegate::ShouldExpire( const NavigationDetails& details) const { - RecordPreviewsInfoBarAction(infobar_type_, INFOBAR_DISMISSED_BY_NAVIGATION); + RecordPreviewsInfoBarAction( + infobar_type_, details.is_reload ? INFOBAR_DISMISSED_BY_RELOAD + : INFOBAR_DISMISSED_BY_NAVIGATION); return InfoBarDelegate::ShouldExpire(details); }
diff --git a/chrome/browser/previews/previews_infobar_delegate.h b/chrome/browser/previews/previews_infobar_delegate.h index 84746d2..cc35b24 100644 --- a/chrome/browser/previews/previews_infobar_delegate.h +++ b/chrome/browser/previews/previews_infobar_delegate.h
@@ -36,6 +36,7 @@ INFOBAR_LOAD_ORIGINAL_CLICKED = 1, INFOBAR_DISMISSED_BY_USER = 2, INFOBAR_DISMISSED_BY_NAVIGATION = 3, + INFOBAR_DISMISSED_BY_RELOAD = 4, INFOBAR_INDEX_BOUNDARY };
diff --git a/chrome/browser/previews/previews_infobar_delegate_unittest.cc b/chrome/browser/previews/previews_infobar_delegate_unittest.cc index 023d105..f919393 100644 --- a/chrome/browser/previews/previews_infobar_delegate_unittest.cc +++ b/chrome/browser/previews/previews_infobar_delegate_unittest.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/previews/previews_infobar_delegate.h" #include <memory> +#include <string> #include "base/bind.h" #include "base/bind_helpers.h" @@ -25,8 +26,10 @@ #include "components/prefs/pref_registry_simple.h" #include "components/proxy_config/proxy_config_pref_names.h" #include "content/public/browser/web_contents.h" +#include "content/public/common/referrer.h" #include "content/public/test/web_contents_tester.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/page_transition_types.h" #include "ui/base/window_open_disposition.h" namespace { @@ -139,6 +142,38 @@ data_reduction_proxy::prefs::kLoFiLoadImagesPerSession)); } +TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestReloadDismissal) { + base::HistogramTester tester; + + // Navigate to test URL, so we can reload later. + content::WebContentsTester::For(web_contents()) + ->NavigateAndCommit(GURL(kTestUrl)); + + CreateInfoBar(PreviewsInfoBarDelegate::LOFI, true /* is_data_saver_user */); + + // Try showing a second infobar. Another should not be shown since the page + // has not navigated. + PreviewsInfoBarDelegate::Create( + web_contents(), PreviewsInfoBarDelegate::LOFI, + true /* is_data_saver_user */, + PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); + EXPECT_EQ(1U, infobar_service()->infobar_count()); + + // Navigate to test URL as a reload to dismiss the infobar. + controller().LoadURL(GURL(kTestUrl), content::Referrer(), + ui::PAGE_TRANSITION_RELOAD, std::string()); + content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); + + EXPECT_EQ(0U, infobar_service()->infobar_count()); + EXPECT_FALSE(user_opt_out_.value()); + + tester.ExpectBucketCount(kUMAPreviewsInfoBarActionLoFi, + PreviewsInfoBarDelegate::INFOBAR_DISMISSED_BY_RELOAD, + 1); + EXPECT_EQ(0, drp_test_context_->pref_service()->GetInteger( + data_reduction_proxy::prefs::kLoFiLoadImagesPerSession)); +} + TEST_F(PreviewsInfoBarDelegateUnitTest, InfobarTestUserDismissal) { base::HistogramTester tester;
diff --git a/chrome/browser/resources/chromeos/keyboard/keyboard_utils.js b/chrome/browser/resources/chromeos/keyboard/keyboard_utils.js index 8b7960f7..3b289606 100644 --- a/chrome/browser/resources/chromeos/keyboard/keyboard_utils.js +++ b/chrome/browser/resources/chromeos/keyboard/keyboard_utils.js
@@ -46,13 +46,13 @@ /** * Swallows keypress and keyup events of arrow keys. - * @param {Event} event Raised event. + * @param {!Event} event Raised event. * @private */ keyboard.onKeyIgnore_ = function(event) { - event = /** @type {KeyboardEvent} */(event); + event = /** @type {!KeyboardEvent} */(event); - if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) + if (hasKeyModifiers(event)) return; if (event.key == 'ArrowLeft' || @@ -66,13 +66,13 @@ /** * Handles arrow key events, depending on if self is a content script. - * @param {Event} event Raised event. + * @param {!Event} event Raised event. * @private */ keyboard.onKeyDown_ = function(event) { - event = /** @type {KeyboardEvent} */(event); + event = /** @type {!KeyboardEvent} */(event); - if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) + if (hasKeyModifiers(event)) return; // This file also gets embedded inside of the CfM/hotrod enrollment webview.
diff --git a/chrome/browser/resources/inspect/inspect.js b/chrome/browser/resources/inspect/inspect.js index e5643f1c..5d11f63 100644 --- a/chrome/browser/resources/inspect/inspect.js +++ b/chrome/browser/resources/inspect/inspect.js
@@ -824,7 +824,7 @@ var line = lineFactory(key, value); line.lastElementChild.addEventListener('keydown', function(e) { if (e.key == 'Tab' && - !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && + !hasKeyModifiers(e) && line.classList.contains('fresh') && !line.classList.contains('empty')) { // Tabbing forward on the fresh line, try create a new empty one.
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js index 9af2257..0be3e13f 100644 --- a/chrome/browser/resources/md_downloads/crisper.js +++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -25,9 +25,9 @@ // <if expr="is_ios"> if(!("key"in KeyboardEvent.prototype)){Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){if(this.keyCode>=48&&this.keyCode<=57)return String.fromCharCode(this.keyCode);if(this.keyCode>=65&&this.keyCode<=90){var result=String.fromCharCode(this.keyCode).toLowerCase();if(this.shiftKey)result=result.toUpperCase();return result}switch(this.keyCode){case 8:return"Backspace";case 9:return"Tab";case 13:return"Enter";case 16:return"Shift";case 17:return"Control";case 18:return"Alt";case 27:return"Escape";case 32:return" ";case 33:return"PageUp";case 34:return"PageDown";case 35:return"End";case 36:return"Home";case 37:return"ArrowLeft";case 38:return"ArrowUp";case 39:return"ArrowRight";case 40:return"ArrowDown";case 45:return"Insert";case 46:return"Delete";case 91:return"Meta";case 112:return"F1";case 113:return"F2";case 114:return"F3";case 115:return"F4";case 116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case 120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";case 187:return"=";case 189:return"-";case 219:return"[";case 221:return"]"}return"Unidentified"}})}else{window.console.log("KeyboardEvent.Key polyfill not required")} // </if> /* is_ios */ -function importModules(moduleNames){return new Promise(function(resolve){define(moduleNames,function(){resolve(Array.from(arguments))})})}Polymer.IronResizableBehavior={properties:{_parentResizable:{type:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:false}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"},created:function(){this._interestedResizables=[];this._boundNotifyResize=this.notifyResize.bind(this)},attached:function(){this.fire("iron-request-resize-notifications",null,{node:this,bubbles:true,cancelable:true});if(!this._parentResizable){window.addEventListener("resize",this._boundNotifyResize);this.notifyResize()}},detached:function(){if(this._parentResizable){this._parentResizable.stopResizeNotificationsFor(this)}else{window.removeEventListener("resize",this._boundNotifyResize)}this._parentResizable=null},notifyResize:function(){if(!this.isAttached){return}this._interestedResizables.forEach(function(resizable){if(this.resizerShouldNotify(resizable)){this._notifyDescendant(resizable)}},this);this._fireResize()},assignParentResizable:function(parentResizable){this._parentResizable=parentResizable},stopResizeNotificationsFor:function(target){var index=this._interestedResizables.indexOf(target);if(index>-1){this._interestedResizables.splice(index,1);this.unlisten(target,"iron-resize","_onDescendantIronResize")}},resizerShouldNotify:function(element){return true},_onDescendantIronResize:function(event){if(this._notifyingDescendant){event.stopPropagation();return}if(!Polymer.Settings.useShadow){this._fireResize()}},_fireResize:function(){this.fire("iron-resize",null,{node:this,bubbles:false})},_onIronRequestResizeNotifications:function(event){var target=event.path?event.path[0]:event.target;if(target===this){return}if(this._interestedResizables.indexOf(target)===-1){this._interestedResizables.push(target);this.listen(target,"iron-resize","_onDescendantIronResize")}target.assignParentResizable(this);this._notifyDescendant(target);event.stopPropagation()},_parentResizableChanged:function(parentResizable){if(parentResizable){window.removeEventListener("resize",this._boundNotifyResize)}},_notifyDescendant:function(descendant){if(!this.isAttached){return}this._notifyingDescendant=true;descendant.notifyResize();this._notifyingDescendant=false}};(function(){"use strict";var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"};var KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"};var KEY_CHAR=/[a-z0-9*]/;var IDENT_CHAR=/U\+/;var ARROW_KEY=/^arrow/;var SPACE_KEY=/^space(bar)?/;var ESC_KEY=/^escape$/;function transformKey(key,noSpecialChars){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey===" "||SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.test(lKey)){validKey="esc"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.test(lKey)){validKey=lKey}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("arrow","")}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return validKey}function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(keyIdent in KEY_IDENTIFIER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIdent=parseInt(keyIdent.replace("U+","0x"),16);validKey=String.fromCharCode(keyIdent).toLowerCase()}else{validKey=keyIdent.toLowerCase()}}return validKey}function transformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=String(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKey=String(keyCode-96)}else{validKey=KEY_CODE[keyCode]}}return validKey}function normalizedKeyForEvent(keyEvent,noSpecialChars){if(keyEvent.key){return transformKey(keyEvent.key,noSpecialChars)}if(keyEvent.detail&&keyEvent.detail.key){return transformKey(keyEvent.detail.key,noSpecialChars)}return transformKeyIdentifier(keyEvent.keyIdentifier)||transformKeyCode(keyEvent.keyCode)||""}function keyComboMatchesEvent(keyCombo,event){var keyEvent=normalizedKeyForEvent(event,keyCombo.hasModifiers);return keyEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.shiftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey&&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyComboString(keyComboString){if(keyComboString.length===1){return{combo:keyComboString,key:keyComboString,event:"keydown"}}return keyComboString.split("+").reduce(function(parsedKeyCombo,keyComboPart){var eventParts=keyComboPart.split(":");var keyName=eventParts[0];var event=eventParts[1];if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_KEYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyName;parsedKeyCombo.event=event||"keydown"}return parsedKeyCombo},{combo:keyComboString.split(":").shift()})}function parseEventString(eventString){return eventString.trim().split(" ").map(function(keyComboString){return parseKeyComboString(keyComboString)})}Polymer.IronA11yKeysBehavior={properties:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolean,value:false},_boundKeyHandlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:function(eventString,handlerName){this._imperativeKeyBindings[eventString]=handlerName;this._prepKeyBindings();this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imperativeKeyBindings={};this._prepKeyBindings();this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(event,eventString){var keyCombos=parseEventString(eventString);for(var i=0;i<keyCombos.length;++i){if(keyComboMatchesEvent(keyCombos[i],event)){return true}}return false},_collectKeyBindings:function(){var keyBindings=this.behaviors.map(function(behavior){return behavior.keyBindings});if(keyBindings.indexOf(this.keyBindings)===-1){keyBindings.push(this.keyBindings)}return keyBindings},_prepKeyBindings:function(){this._keyBindings={};this._collectKeyBindings().forEach(function(keyBindings){for(var eventString in keyBindings){this._addKeyBinding(eventString,keyBindings[eventString])}},this);for(var eventString in this._imperativeKeyBindings){this._addKeyBinding(eventString,this._imperativeKeyBindings[eventString])}for(var eventName in this._keyBindings){this._keyBindings[eventName].sort(function(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb2[0].hasModifiers;return b1===b2?0:b1?-1:1})}},_addKeyBinding:function(eventString,handlerName){parseEventString(eventString).forEach(function(keyCombo){this._keyBindings[keyCombo.event]=this._keyBindings[keyCombo.event]||[];this._keyBindings[keyCombo.event].push([keyCombo,handlerName])},this)},_resetKeyEventListeners:function(){this._unlistenKeyEventListeners();if(this.isAttached){this._listenKeyEventListeners()}},_listenKeyEventListeners:function(){if(!this.keyEventTarget){return}Object.keys(this._keyBindings).forEach(function(eventName){var keyBindings=this._keyBindings[eventName];var boundKeyHandler=this._onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHandlers.push([this.keyEventTarget,eventName,boundKeyHandler]);this.keyEventTarget.addEventListener(eventName,boundKeyHandler)},this)},_unlistenKeyEventListeners:function(){var keyHandlerTuple;var keyEventTarget;var eventName;var boundKeyHandler;while(this._boundKeyHandlers.length){keyHandlerTuple=this._boundKeyHandlers.pop();keyEventTarget=keyHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2];keyEventTarget.removeEventListener(eventName,boundKeyHandler)}},_onKeyBindingEvent:function(keyBindings,event){if(this.stopKeyboardEventPropagation){event.stopPropagation()}if(event.defaultPrevented){return}for(var i=0;i<keyBindings.length;i++){var keyCombo=keyBindings[i][0];var handlerName=keyBindings[i][1];if(keyComboMatchesEvent(keyCombo,event)){this._triggerKeyHandler(keyCombo,handlerName,event);if(event.defaultPrevented){return}}}},_triggerKeyHandler:function(keyCombo,handlerName,keyboardEvent){var detail=Object.create(keyCombo);detail.keyboardEvent=keyboardEvent;var event=new CustomEvent(keyCombo.event,{detail:detail,cancelable:true});this[handlerName].call(this,event);if(event.defaultPrevented){keyboardEvent.preventDefault()}}}})();Polymer.IronScrollTargetBehavior={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:true,_scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if(this._oldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget);this._oldScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){this.scrollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollTarget=this.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument).querySelector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._boundScrollHandler=this._boundScrollHandler||this._scrollHandler.bind(this);this._oldScrollTarget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,scrollTarget)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTop(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTarget===this._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.scrollTarget===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,top){if(this.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollTop=top}},get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0},get _scrollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isValidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScrollListener:function(yes,scrollTarget){if(!this._boundScrollHandler){return}var eventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTarget.addEventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeEventListener("scroll",this._boundScrollHandler)}},toggleScrollListener:function(yes){this._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarget)}};(function(){var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;var DEFAULT_PHYSICAL_COUNT=3;var HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEIGHT=1;var SECRET_TABINDEX=-100;Polymer({is:"iron-list",properties:{items:{type:Array},maxPhysicalCount:{type:Number,value:500},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:false,reflectToAttribute:true},selectionEnabled:{type:Boolean,value:false},selectedItem:{type:Object,notify:true},selectedItems:{type:Object,notify:true},multiSelection:{type:Boolean,value:false}},observers:["_itemsChanged(items.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOverflow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polymer.IronResizableBehavior,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBehavior],keyBindings:{up:"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_collection:null,_maxPages:2,_focusedItem:null,_focusedIndex:-1,_offscreenFocusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,get _physicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(){var size=this.grid?this._physicalRows*this._rowHeight:this._physicalSize;return size-this._viewportHeight},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtualStart(){return Math.max(0,this._virtualCount-this._physicalCount)},_virtualStartVal:0,set _virtualStart(val){this._virtualStartVal=Math.min(this._maxVirtualStart,Math.max(this._minVirtualStart,val))},get _virtualStart(){return this._virtualStartVal||0},_physicalStartVal:0,set _physicalStart(val){this._physicalStartVal=val%this._physicalCount;if(this._physicalStartVal<0){this._physicalStartVal=this._physicalCount+this._physicalStartVal}this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _physicalStart(){return this._physicalStartVal||0},_physicalCountVal:0,set _physicalCount(val){this._physicalCountVal=val;this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _physicalCount(){return this._physicalCountVal},_physicalEnd:0,get _optPhysicalSize(){if(this.grid){return this._estRowsInView*this._rowHeight*this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){if(this._firstVisibleIndexVal===null){var physicalOffset=Math.floor(this._physicalTop+this._scrollerPaddingTop);this._firstVisibleIndexVal=this._iterateItems(function(pidx,vidx){physicalOffset+=this._getPhysicalSizeIncrement(pidx);if(physicalOffset>this._scrollPosition){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(this.grid&&this._virtualCount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}return this._firstVisibleIndexVal},get lastVisibleIndex(){if(this._lastVisibleIndexVal===null){if(this.grid){var lastIndex=this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow-1;this._lastVisibleIndexVal=Math.min(this._virtualCount,lastIndex)}else{var physicalOffset=this._physicalTop;this._iterateItems(function(pidx,vidx){if(physicalOffset<this._scrollBottom){this._lastVisibleIndexVal=vidx}else{return true}physicalOffset+=this._getPhysicalSizeIncrement(pidx)})}}return this._lastVisibleIndexVal},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(this._physicalCount/this._itemsPerRow)},ready:function(){this.addEventListener("focus",this._didFocus.bind(this),true)},attached:function(){if(this._physicalCount===0){this._debounceTemplate(this._render)}this.listen(this,"iron-resize","_resizeHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler")},_setOverflow:function(scrollTarget){this.style.webkitOverflowScrolling=scrollTarget===this?"touch":"";this.style.overflow=scrollTarget===this?"auto":""},updateViewportBoundaries:function(){this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(window.getComputedStyle(this)["padding-top"],10);this._viewportWidth=this.$.items.offsetWidth;this._viewportHeight=this._scrollTargetHeight;this.grid&&this._updateGridMetrics()},_scrollHandler:function(){var scrollTop=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));var delta=scrollTop-this._scrollPosition;var isScrollingDown=delta>=0;this._scrollPosition=scrollTop;this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;if(Math.abs(delta)>this._physicalSize){var idxAdjustment=Math.round(delta/this._physicalAverage)*this._itemsPerRow;this._physicalTop=this._physicalTop+delta;this._virtualStart=this._virtualStart+idxAdjustment;this._physicalStart=this._physicalStart+idxAdjustment;this._update()}else{var reusables=this._getReusables(isScrollingDown);if(isScrollingDown){this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.indexes.length}else{this._virtualStart=this._virtualStart-reusables.indexes.length;this._physicalStart=this._physicalStart-reusables.indexes.length}if(reusables.indexes.length===0){this._increasePoolIfNeeded()}else{this._update(reusables.indexes,isScrollingDown?null:reusables.indexes)}}},_getReusables:function(fromTop){var ith,lastIth,offsetContent,physicalItemHeight;var idxs=[];var protectedOffsetContent=this._hiddenContentSize*this._ratio;var virtualStart=this._virtualStart;var virtualEnd=this._virtualEnd;var physicalCount=this._physicalCount;var physicalTop=this._physicalTop+this._scrollerPaddingTop;var scrollTop=this._scrollTop;var scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIth=this._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalEnd;lastIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}while(true){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=offsetContent-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=protectedOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virtualCount){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(ith);physicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(virtualStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalItemHeight<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItemHeight;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physicalTop-this._scrollerPaddingTop}},_update:function(itemSet,movingUp){if(itemSet&&itemSet.length===0){return}this._manageFocus();this._assignModels(itemSet);this._updateMetrics(itemSet);if(movingUp){while(movingUp.length){var idx=movingUp.pop();this._physicalTop-=this._getPhysicalSizeIncrement(idx)}}this._positionItems();this._updateScrollerSize();this._increasePoolIfNeeded()},_createPool:function(size){var physicalItems=new Array(size);this._ensureTemplatized();for(var i=0;i<size;i++){var inst=this.stamp(null);physicalItems[i]=inst.root.querySelector("*");Polymer.dom(this).appendChild(inst.root)}return physicalItems},_increasePoolIfNeeded:function(){if(this._viewportHeight===0){return false}var self=this;var isClientFull=this._physicalBottom>=this._scrollBottom&&this._physicalTop<=this._scrollPosition;if(this._physicalSize>=this._optPhysicalSize&&isClientFull){return false}var maxPoolSize=Math.round(this._physicalCount*.5);if(!isClientFull){this._debounceTemplate(this._increasePool.bind(this,maxPoolSize));return true}this._yield(function(){self._increasePool(Math.min(maxPoolSize,Math.max(1,Math.round(50/self._templateCost))))});return true},_yield:function(cb){var g=window;var handle=g.requestIdleCallback?g.requestIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.addDebouncer({complete:function(){g.cancelIdleCallback?g.cancelIdleCallback(handle):g.clearTimeout(handle);cb()}})},_increasePool:function(missingItems){var nextPhysicalCount=Math.min(this._physicalCount+missingItems,this._virtualCount-this._virtualStart,Math.max(this.maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPhysicalCount=this._physicalCount;var delta=nextPhysicalCount-prevPhysicalCount;var ts=window.performance.now();if(delta<=0){return}[].push.apply(this._physicalItems,this._createPool(delta));[].push.apply(this._physicalSizes,new Array(delta));this._physicalCount=prevPhysicalCount+delta;if(this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedIndex)&&this._getPhysicalIndex(this._focusedIndex)<this._physicalEnd){this._physicalStart=this._physicalStart+delta}this._update();this._templateCost=(window.performance.now()-ts)/delta},_render:function(){if(this.isAttached&&this._isVisible){if(this._physicalCount===0){this.updateViewportBoundaries();this._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reusables=this._getReusables(true);this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.indexes.length;this._update(reusables.indexes);this._update()}}},_ensureTemplatized:function(){if(!this.ctor){var props={};props.__key__=true;props[this.as]=true;props[this.indexAs]=true;props[this.selectedAs]=true;props.tabIndex=true;this._instanceProps=props;this._userTemplate=Polymer.dom(this).querySelector("template");if(this._userTemplate){this.templatize(this._userTemplate)}else{console.warn("iron-list requires a template to be provided in light-dom")}}},_getStampedChildren:function(){return this._physicalItems},_forwardInstancePath:function(inst,path,value){if(path.indexOf(this.as+".")===0){this.notifyPath("items."+inst.__key__+"."+path.slice(this.as.length+1),value)}},_forwardParentProp:function(prop,value){if(this._physicalItems){this._physicalItems.forEach(function(item){item._templateInstance[prop]=value},this)}},_forwardParentPath:function(path,value){if(this._physicalItems){this._physicalItems.forEach(function(item){item._templateInstance.notifyPath(path,value,true)},this)}},_forwardItemPath:function(path,value){if(!this._physicalIndexForKey){return}var dot=path.indexOf(".");var key=path.substring(0,dot<0?path.length:dot);var idx=this._physicalIndexForKey[key];var offscreenItem=this._offscreenFocusedItem;var el=offscreenItem&&offscreenItem._templateInstance.__key__===key?offscreenItem:this._physicalItems[idx];if(!el||el._templateInstance.__key__!==key){return}if(dot>=0){path=this.as+"."+path.substring(dot+1);el._templateInstance.notifyPath(path,value,true)}else{var currentItem=el._templateInstance[this.as];if(Array.isArray(this.selectedItems)){for(var i=0;i<this.selectedItems.length;i++){if(this.selectedItems[i]===currentItem){this.set("selectedItems."+i,value);break}}}else if(this.selectedItem===currentItem){this.set("selectedItem",value)}el._templateInstance[this.as]=value}},_itemsChanged:function(change){if(change.path==="items"){this._virtualStart=0;this._physicalTop=0;this._virtualCount=this.items?this.items.length:0;this._collection=this.items?Polymer.Collection.get(this.items):null;this._physicalIndexForKey={};this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;this._physicalCount=this._physicalCount||0;this._physicalItems=this._physicalItems||[];this._physicalSizes=this._physicalSizes||[];this._physicalStart=0;this._resetScrollPosition(0);this._removeFocusedItem();this._debounceTemplate(this._render)}else if(change.path==="items.splices"){this._adjustVirtualIndex(change.value.indexSplices);this._virtualCount=this.items?this.items.length:0;this._debounceTemplate(this._render)}else{this._forwardItemPath(change.path.split(".").slice(1).join("."),change.value)}},_adjustVirtualIndex:function(splices){splices.forEach(function(splice){splice.removed.forEach(this._removeItem,this);if(splice.index<this._virtualStart){var delta=Math.max(splice.addedCount-splice.removed.length,splice.index-this._virtualStart);this._virtualStart=this._virtualStart+delta;if(this._focusedIndex>=0){this._focusedIndex=this._focusedIndex+delta}}},this)},_removeItem:function(item){this.$.selector.deselect(item);if(this._focusedItem&&this._focusedItem._templateInstance[this.as]===item){this._removeFocusedItem()}},_iterateItems:function(fn,itemSet){var pidx,vidx,rtn,i;if(arguments.length===2&&itemSet){for(i=0;i<itemSet.length;i++){pidx=itemSet[i];vidx=this._computeVidx(pidx);if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}else{pidx=this._physicalStart;vidx=this._virtualStart;for(;pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}for(pidx=0;pidx<this._physicalStart;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}},_computeVidx:function(pidx){if(pidx>=this._physicalStart){return this._virtualStart+(pidx-this._physicalStart)}return this._virtualStart+(this._physicalCount-this._physicalStart)+pidx},_assignModels:function(itemSet){this._iterateItems(function(pidx,vidx){var el=this._physicalItems[pidx];var inst=el._templateInstance;var item=this.items&&this.items[vidx];if(item!=null){inst[this.as]=item;inst.__key__=this._collection.getKey(item);inst[this.selectedAs]=this.$.selector.isSelected(item);inst[this.indexAs]=vidx;inst.tabIndex=this._focusedIndex===vidx?0:-1;this._physicalIndexForKey[inst.__key__]=pidx;el.removeAttribute("hidden")}else{inst.__key__=null;el.setAttribute("hidden","")}},itemSet)},_updateMetrics:function(itemSet){Polymer.dom.flush();var newPhysicalSize=0;var oldPhysicalSize=0;var prevAvgCount=this._physicalAverageCount;var prevPhysicalAvg=this._physicalAverage;this._iterateItems(function(pidx,vidx){oldPhysicalSize+=this._physicalSizes[pidx]||0;this._physicalSizes[pidx]=this._physicalItems[pidx].offsetHeight;newPhysicalSize+=this._physicalSizes[pidx];this._physicalAverageCount+=this._physicalSizes[pidx]?1:0},itemSet);if(this.grid){this._updateGridMetrics();this._physicalSize=Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight}else{this._physicalSize=this._physicalSize+newPhysicalSize-oldPhysicalSize}if(this._physicalAverageCount!==prevAvgCount){this._physicalAverage=Math.round((prevPhysicalAvg*prevAvgCount+newPhysicalSize)/this._physicalAverageCount)}},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().width:200;this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight:200;this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition();var y=this._physicalTop;if(this.grid){var totalItemWidth=this._itemsPerRow*this._itemWidth;var rowOffset=(this._viewportWidth-totalItemWidth)/2;this._iterateItems(function(pidx,vidx){var modulus=vidx%this._itemsPerRow;var x=Math.floor(modulus*this._itemWidth+rowOffset);this.translate3d(x+"px",y+"px",0,this._physicalItems[pidx]);if(this._shouldRenderNextRow(vidx)){y+=this._rowHeight}})}else{this._iterateItems(function(pidx,vidx){this.translate3d(0,y+"px",0,this._physicalItems[pidx]);y+=this._physicalSizes[pidx]})}},_getPhysicalSizeIncrement:function(pidx){if(!this.grid){return this._physicalSizes[pidx]}if(this._computeVidx(pidx)%this._itemsPerRow!==this._itemsPerRow-1){return 0}return this._rowHeight},_shouldRenderNextRow:function(vidx){return vidx%this._itemsPerRow===this._itemsPerRow-1},_adjustScrollPosition:function(){var deltaHeight=this._virtualStart===0?this._physicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(deltaHeight){this._physicalTop=this._physicalTop-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physicalTop!==0){this._resetScrollPosition(this._scrollTop-deltaHeight)}}},_resetScrollPosition:function(pos){if(this.scrollTarget){this._scrollTop=pos;this._scrollPosition=this._scrollTop}},_updateScrollerSize:function(forceUpdate){if(this.grid){this._estScrollHeight=this._virtualRowCount*this._rowHeight}else{this._estScrollHeight=this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAverage}forceUpdate=forceUpdate||this._scrollHeight===0;forceUpdate=forceUpdate||this._scrollPosition>=this._estScrollHeight-this._physicalSize;forceUpdate=forceUpdate||this.grid&&this.$.items.style.height<this._estScrollHeight;if(forceUpdate||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._optPhysicalSize){this.$.items.style.height=this._estScrollHeight+"px";this._scrollHeight=this._estScrollHeight}},scrollToItem:function(item){return this.scrollToIndex(this.items.indexOf(item))},scrollToIndex:function(idx){if(typeof idx!=="number"||idx<0||idx>this.items.length-1){return}Polymer.dom.flush();if(this._physicalCount===0){return}idx=Math.min(Math.max(idx,0),this._virtualCount-1);if(!this._isIndexRendered(idx)||idx>=this._maxVirtualStart){this._virtualStart=this.grid?idx-this._itemsPerRow*2:idx-1}this._manageFocus();this._assignModels();this._updateMetrics();this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage;var currentTopItem=this._physicalStart;var currentVirtualItem=this._virtualStart;var targetOffsetTop=0;var hiddenContentSize=this._hiddenContentSize;while(currentVirtualItem<idx&&targetOffsetTop<=hiddenContentSize){targetOffsetTop=targetOffsetTop+this._getPhysicalSizeIncrement(currentTopItem);currentTopItem=(currentTopItem+1)%this._physicalCount;currentVirtualItem++}this._updateScrollerSize(true);this._positionItems();this._resetScrollPosition(this._physicalTop+this._scrollerPaddingTop+targetOffsetTop);this._increasePoolIfNeeded();this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null},_resetAverage:function(){this._physicalAverage=0;this._physicalAverageCount=0},_resizeHandler:function(){var delta=Math.abs(this._viewportHeight-this._scrollTargetHeight);if(IOS&&delta>0&&delta<100){return}Polymer.dom.addDebouncer(this.debounce("_debounceTemplate",function(){this.updateViewportBoundaries();this._render();if(this._isVisible){this.toggleScrollListener(true);if(this._physicalCount>0){this._resetAverage();this.scrollToIndex(this.firstVisibleIndex)}}else{this.toggleScrollListener(false)}}.bind(this),1))},_getModelFromItem:function(item){var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[key];if(pidx!=null){return this._physicalItems[pidx]._templateInstance}return null},_getNormalizedItem:function(item){if(this._collection.getKey(item)===undefined){if(typeof item==="number"){item=this.items[item];if(!item){throw new RangeError("<item> not found")}return item}throw new TypeError("<item> should be a valid item")}return item},selectItem:function(item){item=this._getNormalizedItem(item);var model=this._getModelFromItem(item);if(!this.multiSelection&&this.selectedItem){this.deselectItem(this.selectedItem)}if(model){model[this.selectedAs]=true}this.$.selector.select(item);this.updateSizeForItem(item)},deselectItem:function(item){item=this._getNormalizedItem(item);var model=this._getModelFromItem(item);if(model){model[this.selectedAs]=false}this.$.selector.deselect(item);this.updateSizeForItem(item)},toggleSelectionForItem:function(item){item=this._getNormalizedItem(item);if(this.$.selector.isSelected(item)){this.deselectItem(item)}else{this.selectItem(item)}},clearSelection:function(){function unselect(item){var model=this._getModelFromItem(item);if(model){model[this.selectedAs]=false}}if(Array.isArray(this.selectedItems)){this.selectedItems.forEach(unselect,this)}else if(this.selectedItem){unselect.call(this,this.selectedItem)}this.$.selector.clearSelection()},_selectionEnabledChanged:function(selectionEnabled){var handler=selectionEnabled?this.listen:this.unlisten;handler.call(this,this,"tap","_selectionHandler")},_selectionHandler:function(e){var model=this.modelForElement(e.target);if(!model){return}var modelTabIndex,activeElTabIndex;var target=Polymer.dom(e).path[0];var activeEl=Polymer.dom(this.domHost?this.domHost.root:document).activeElement;var physicalItem=this._physicalItems[this._getPhysicalIndex(model[this.indexAs])]; +function importModules(moduleNames){return new Promise(function(resolve){define(moduleNames,function(){resolve(Array.from(arguments))})})}function hasKeyModifiers(e){return!!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}Polymer.IronResizableBehavior={properties:{_parentResizable:{type:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:false}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"},created:function(){this._interestedResizables=[];this._boundNotifyResize=this.notifyResize.bind(this)},attached:function(){this.fire("iron-request-resize-notifications",null,{node:this,bubbles:true,cancelable:true});if(!this._parentResizable){window.addEventListener("resize",this._boundNotifyResize);this.notifyResize()}},detached:function(){if(this._parentResizable){this._parentResizable.stopResizeNotificationsFor(this)}else{window.removeEventListener("resize",this._boundNotifyResize)}this._parentResizable=null},notifyResize:function(){if(!this.isAttached){return}this._interestedResizables.forEach(function(resizable){if(this.resizerShouldNotify(resizable)){this._notifyDescendant(resizable)}},this);this._fireResize()},assignParentResizable:function(parentResizable){this._parentResizable=parentResizable},stopResizeNotificationsFor:function(target){var index=this._interestedResizables.indexOf(target);if(index>-1){this._interestedResizables.splice(index,1);this.unlisten(target,"iron-resize","_onDescendantIronResize")}},resizerShouldNotify:function(element){return true},_onDescendantIronResize:function(event){if(this._notifyingDescendant){event.stopPropagation();return}if(!Polymer.Settings.useShadow){this._fireResize()}},_fireResize:function(){this.fire("iron-resize",null,{node:this,bubbles:false})},_onIronRequestResizeNotifications:function(event){var target=event.path?event.path[0]:event.target;if(target===this){return}if(this._interestedResizables.indexOf(target)===-1){this._interestedResizables.push(target);this.listen(target,"iron-resize","_onDescendantIronResize")}target.assignParentResizable(this);this._notifyDescendant(target);event.stopPropagation()},_parentResizableChanged:function(parentResizable){if(parentResizable){window.removeEventListener("resize",this._boundNotifyResize)}},_notifyDescendant:function(descendant){if(!this.isAttached){return}this._notifyingDescendant=true;descendant.notifyResize();this._notifyingDescendant=false}};(function(){"use strict";var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"};var KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"};var KEY_CHAR=/[a-z0-9*]/;var IDENT_CHAR=/U\+/;var ARROW_KEY=/^arrow/;var SPACE_KEY=/^space(bar)?/;var ESC_KEY=/^escape$/;function transformKey(key,noSpecialChars){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey===" "||SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.test(lKey)){validKey="esc"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.test(lKey)){validKey=lKey}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("arrow","")}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return validKey}function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(keyIdent in KEY_IDENTIFIER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIdent=parseInt(keyIdent.replace("U+","0x"),16);validKey=String.fromCharCode(keyIdent).toLowerCase()}else{validKey=keyIdent.toLowerCase()}}return validKey}function transformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=String(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKey=String(keyCode-96)}else{validKey=KEY_CODE[keyCode]}}return validKey}function normalizedKeyForEvent(keyEvent,noSpecialChars){if(keyEvent.key){return transformKey(keyEvent.key,noSpecialChars)}if(keyEvent.detail&&keyEvent.detail.key){return transformKey(keyEvent.detail.key,noSpecialChars)}return transformKeyIdentifier(keyEvent.keyIdentifier)||transformKeyCode(keyEvent.keyCode)||""}function keyComboMatchesEvent(keyCombo,event){var keyEvent=normalizedKeyForEvent(event,keyCombo.hasModifiers);return keyEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.shiftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey&&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyComboString(keyComboString){if(keyComboString.length===1){return{combo:keyComboString,key:keyComboString,event:"keydown"}}return keyComboString.split("+").reduce(function(parsedKeyCombo,keyComboPart){var eventParts=keyComboPart.split(":");var keyName=eventParts[0];var event=eventParts[1];if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_KEYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyName;parsedKeyCombo.event=event||"keydown"}return parsedKeyCombo},{combo:keyComboString.split(":").shift()})}function parseEventString(eventString){return eventString.trim().split(" ").map(function(keyComboString){return parseKeyComboString(keyComboString)})}Polymer.IronA11yKeysBehavior={properties:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolean,value:false},_boundKeyHandlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:function(eventString,handlerName){this._imperativeKeyBindings[eventString]=handlerName;this._prepKeyBindings();this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imperativeKeyBindings={};this._prepKeyBindings();this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(event,eventString){var keyCombos=parseEventString(eventString);for(var i=0;i<keyCombos.length;++i){if(keyComboMatchesEvent(keyCombos[i],event)){return true}}return false},_collectKeyBindings:function(){var keyBindings=this.behaviors.map(function(behavior){return behavior.keyBindings});if(keyBindings.indexOf(this.keyBindings)===-1){keyBindings.push(this.keyBindings)}return keyBindings},_prepKeyBindings:function(){this._keyBindings={};this._collectKeyBindings().forEach(function(keyBindings){for(var eventString in keyBindings){this._addKeyBinding(eventString,keyBindings[eventString])}},this);for(var eventString in this._imperativeKeyBindings){this._addKeyBinding(eventString,this._imperativeKeyBindings[eventString])}for(var eventName in this._keyBindings){this._keyBindings[eventName].sort(function(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb2[0].hasModifiers;return b1===b2?0:b1?-1:1})}},_addKeyBinding:function(eventString,handlerName){parseEventString(eventString).forEach(function(keyCombo){this._keyBindings[keyCombo.event]=this._keyBindings[keyCombo.event]||[];this._keyBindings[keyCombo.event].push([keyCombo,handlerName])},this)},_resetKeyEventListeners:function(){this._unlistenKeyEventListeners();if(this.isAttached){this._listenKeyEventListeners()}},_listenKeyEventListeners:function(){if(!this.keyEventTarget){return}Object.keys(this._keyBindings).forEach(function(eventName){var keyBindings=this._keyBindings[eventName];var boundKeyHandler=this._onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHandlers.push([this.keyEventTarget,eventName,boundKeyHandler]);this.keyEventTarget.addEventListener(eventName,boundKeyHandler)},this)},_unlistenKeyEventListeners:function(){var keyHandlerTuple;var keyEventTarget;var eventName;var boundKeyHandler;while(this._boundKeyHandlers.length){keyHandlerTuple=this._boundKeyHandlers.pop();keyEventTarget=keyHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2];keyEventTarget.removeEventListener(eventName,boundKeyHandler)}},_onKeyBindingEvent:function(keyBindings,event){if(this.stopKeyboardEventPropagation){event.stopPropagation()}if(event.defaultPrevented){return}for(var i=0;i<keyBindings.length;i++){var keyCombo=keyBindings[i][0];var handlerName=keyBindings[i][1];if(keyComboMatchesEvent(keyCombo,event)){this._triggerKeyHandler(keyCombo,handlerName,event);if(event.defaultPrevented){return}}}},_triggerKeyHandler:function(keyCombo,handlerName,keyboardEvent){var detail=Object.create(keyCombo);detail.keyboardEvent=keyboardEvent;var event=new CustomEvent(keyCombo.event,{detail:detail,cancelable:true});this[handlerName].call(this,event);if(event.defaultPrevented){keyboardEvent.preventDefault()}}}})();Polymer.IronScrollTargetBehavior={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:true,_scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if(this._oldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget);this._oldScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){this.scrollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollTarget=this.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument).querySelector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._boundScrollHandler=this._boundScrollHandler||this._scrollHandler.bind(this);this._oldScrollTarget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,scrollTarget)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTop(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTarget===this._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.scrollTarget===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,top){if(this.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollTop=top}},get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0},get _scrollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isValidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScrollListener:function(yes,scrollTarget){if(!this._boundScrollHandler){return}var eventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTarget.addEventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeEventListener("scroll",this._boundScrollHandler)}},toggleScrollListener:function(yes){this._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarget)}};(function(){var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;var DEFAULT_PHYSICAL_COUNT=3;var HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEIGHT=1;var SECRET_TABINDEX=-100;Polymer({is:"iron-list",properties:{items:{type:Array},maxPhysicalCount:{type:Number,value:500},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:false,reflectToAttribute:true},selectionEnabled:{type:Boolean,value:false},selectedItem:{type:Object,notify:true},selectedItems:{type:Object,notify:true},multiSelection:{type:Boolean,value:false}},observers:["_itemsChanged(items.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOverflow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polymer.IronResizableBehavior,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBehavior],keyBindings:{up:"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_collection:null,_maxPages:2,_focusedItem:null,_focusedIndex:-1,_offscreenFocusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,get _physicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(){var size=this.grid?this._physicalRows*this._rowHeight:this._physicalSize;return size-this._viewportHeight},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtualStart(){return Math.max(0,this._virtualCount-this._physicalCount)},_virtualStartVal:0,set _virtualStart(val){this._virtualStartVal=Math.min(this._maxVirtualStart,Math.max(this._minVirtualStart,val))},get _virtualStart(){return this._virtualStartVal||0},_physicalStartVal:0,set _physicalStart(val){this._physicalStartVal=val%this._physicalCount;if(this._physicalStartVal<0){this._physicalStartVal=this._physicalCount+this._physicalStartVal}this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _physicalStart(){return this._physicalStartVal||0},_physicalCountVal:0,set _physicalCount(val){this._physicalCountVal=val;this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _physicalCount(){return this._physicalCountVal},_physicalEnd:0,get _optPhysicalSize(){if(this.grid){return this._estRowsInView*this._rowHeight*this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){if(this._firstVisibleIndexVal===null){var physicalOffset=Math.floor(this._physicalTop+this._scrollerPaddingTop);this._firstVisibleIndexVal=this._iterateItems(function(pidx,vidx){physicalOffset+=this._getPhysicalSizeIncrement(pidx);if(physicalOffset>this._scrollPosition){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(this.grid&&this._virtualCount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}return this._firstVisibleIndexVal},get lastVisibleIndex(){if(this._lastVisibleIndexVal===null){if(this.grid){var lastIndex=this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow-1;this._lastVisibleIndexVal=Math.min(this._virtualCount,lastIndex)}else{var physicalOffset=this._physicalTop;this._iterateItems(function(pidx,vidx){if(physicalOffset<this._scrollBottom){this._lastVisibleIndexVal=vidx}else{return true}physicalOffset+=this._getPhysicalSizeIncrement(pidx)})}}return this._lastVisibleIndexVal},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(this._physicalCount/this._itemsPerRow)},ready:function(){this.addEventListener("focus",this._didFocus.bind(this),true)},attached:function(){if(this._physicalCount===0){this._debounceTemplate(this._render)}this.listen(this,"iron-resize","_resizeHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler")},_setOverflow:function(scrollTarget){this.style.webkitOverflowScrolling=scrollTarget===this?"touch":"";this.style.overflow=scrollTarget===this?"auto":""},updateViewportBoundaries:function(){this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(window.getComputedStyle(this)["padding-top"],10);this._viewportWidth=this.$.items.offsetWidth;this._viewportHeight=this._scrollTargetHeight;this.grid&&this._updateGridMetrics()},_scrollHandler:function(){var scrollTop=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));var delta=scrollTop-this._scrollPosition;var isScrollingDown=delta>=0;this._scrollPosition=scrollTop;this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;if(Math.abs(delta)>this._physicalSize){var idxAdjustment=Math.round(delta/this._physicalAverage)*this._itemsPerRow;this._physicalTop=this._physicalTop+delta;this._virtualStart=this._virtualStart+idxAdjustment;this._physicalStart=this._physicalStart+idxAdjustment;this._update()}else{var reusables=this._getReusables(isScrollingDown);if(isScrollingDown){this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.indexes.length}else{this._virtualStart=this._virtualStart-reusables.indexes.length;this._physicalStart=this._physicalStart-reusables.indexes.length}if(reusables.indexes.length===0){this._increasePoolIfNeeded()}else{this._update(reusables.indexes,isScrollingDown?null:reusables.indexes)}}},_getReusables:function(fromTop){var ith,lastIth,offsetContent,physicalItemHeight;var idxs=[];var protectedOffsetContent=this._hiddenContentSize*this._ratio;var virtualStart=this._virtualStart;var virtualEnd=this._virtualEnd;var physicalCount=this._physicalCount;var physicalTop=this._physicalTop+this._scrollerPaddingTop;var scrollTop=this._scrollTop;var scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIth=this._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalEnd;lastIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}while(true){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=offsetContent-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=protectedOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virtualCount){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(ith);physicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(virtualStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalItemHeight<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItemHeight;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physicalTop-this._scrollerPaddingTop}},_update:function(itemSet,movingUp){if(itemSet&&itemSet.length===0){return}this._manageFocus();this._assignModels(itemSet);this._updateMetrics(itemSet);if(movingUp){while(movingUp.length){var idx=movingUp.pop();this._physicalTop-=this._getPhysicalSizeIncrement(idx)}}this._positionItems();this._updateScrollerSize();this._increasePoolIfNeeded()},_createPool:function(size){var physicalItems=new Array(size);this._ensureTemplatized();for(var i=0;i<size;i++){var inst=this.stamp(null);physicalItems[i]=inst.root.querySelector("*");Polymer.dom(this).appendChild(inst.root)}return physicalItems},_increasePoolIfNeeded:function(){if(this._viewportHeight===0){return false}var self=this;var isClientFull=this._physicalBottom>=this._scrollBottom&&this._physicalTop<=this._scrollPosition;if(this._physicalSize>=this._optPhysicalSize&&isClientFull){return false}var maxPoolSize=Math.round(this._physicalCount*.5);if(!isClientFull){this._debounceTemplate(this._increasePool.bind(this,maxPoolSize));return true}this._yield(function(){self._increasePool(Math.min(maxPoolSize,Math.max(1,Math.round(50/self._templateCost))))});return true},_yield:function(cb){var g=window;var handle=g.requestIdleCallback?g.requestIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.addDebouncer({complete:function(){g.cancelIdleCallback?g.cancelIdleCallback(handle):g.clearTimeout(handle);cb()}})},_increasePool:function(missingItems){var nextPhysicalCount=Math.min(this._physicalCount+missingItems,this._virtualCount-this._virtualStart,Math.max(this.maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPhysicalCount=this._physicalCount;var delta=nextPhysicalCount-prevPhysicalCount;var ts=window.performance.now();if(delta<=0){return}[].push.apply(this._physicalItems,this._createPool(delta));[].push.apply(this._physicalSizes,new Array(delta));this._physicalCount=prevPhysicalCount+delta;if(this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedIndex)&&this._getPhysicalIndex(this._focusedIndex)<this._physicalEnd){this._physicalStart=this._physicalStart+delta}this._update();this._templateCost=(window.performance.now()-ts)/delta},_render:function(){if(this.isAttached&&this._isVisible){if(this._physicalCount===0){this.updateViewportBoundaries();this._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reusables=this._getReusables(true);this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.indexes.length;this._update(reusables.indexes);this._update()}}},_ensureTemplatized:function(){if(!this.ctor){var props={};props.__key__=true;props[this.as]=true;props[this.indexAs]=true;props[this.selectedAs]=true;props.tabIndex=true;this._instanceProps=props;this._userTemplate=Polymer.dom(this).querySelector("template");if(this._userTemplate){this.templatize(this._userTemplate)}else{console.warn("iron-list requires a template to be provided in light-dom")}}},_getStampedChildren:function(){return this._physicalItems},_forwardInstancePath:function(inst,path,value){if(path.indexOf(this.as+".")===0){this.notifyPath("items."+inst.__key__+"."+path.slice(this.as.length+1),value)}},_forwardParentProp:function(prop,value){if(this._physicalItems){this._physicalItems.forEach(function(item){item._templateInstance[prop]=value},this)}},_forwardParentPath:function(path,value){if(this._physicalItems){this._physicalItems.forEach(function(item){item._templateInstance.notifyPath(path,value,true)},this)}},_forwardItemPath:function(path,value){if(!this._physicalIndexForKey){return}var dot=path.indexOf(".");var key=path.substring(0,dot<0?path.length:dot);var idx=this._physicalIndexForKey[key];var offscreenItem=this._offscreenFocusedItem;var el=offscreenItem&&offscreenItem._templateInstance.__key__===key?offscreenItem:this._physicalItems[idx];if(!el||el._templateInstance.__key__!==key){return}if(dot>=0){path=this.as+"."+path.substring(dot+1);el._templateInstance.notifyPath(path,value,true)}else{var currentItem=el._templateInstance[this.as];if(Array.isArray(this.selectedItems)){for(var i=0;i<this.selectedItems.length;i++){if(this.selectedItems[i]===currentItem){this.set("selectedItems."+i,value);break}}}else if(this.selectedItem===currentItem){this.set("selectedItem",value)}el._templateInstance[this.as]=value}},_itemsChanged:function(change){if(change.path==="items"){this._virtualStart=0;this._physicalTop=0;this._virtualCount=this.items?this.items.length:0;this._collection=this.items?Polymer.Collection.get(this.items):null;this._physicalIndexForKey={};this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;this._physicalCount=this._physicalCount||0;this._physicalItems=this._physicalItems||[];this._physicalSizes=this._physicalSizes||[];this._physicalStart=0;this._resetScrollPosition(0);this._removeFocusedItem();this._debounceTemplate(this._render)}else if(change.path==="items.splices"){this._adjustVirtualIndex(change.value.indexSplices);this._virtualCount=this.items?this.items.length:0;this._debounceTemplate(this._render)}else{this._forwardItemPath(change.path.split(".").slice(1).join("."),change.value)}},_adjustVirtualIndex:function(splices){splices.forEach(function(splice){splice.removed.forEach(this._removeItem,this);if(splice.index<this._virtualStart){var delta=Math.max(splice.addedCount-splice.removed.length,splice.index-this._virtualStart);this._virtualStart=this._virtualStart+delta;if(this._focusedIndex>=0){this._focusedIndex=this._focusedIndex+delta}}},this)},_removeItem:function(item){this.$.selector.deselect(item);if(this._focusedItem&&this._focusedItem._templateInstance[this.as]===item){this._removeFocusedItem()}},_iterateItems:function(fn,itemSet){var pidx,vidx,rtn,i;if(arguments.length===2&&itemSet){for(i=0;i<itemSet.length;i++){pidx=itemSet[i];vidx=this._computeVidx(pidx);if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}else{pidx=this._physicalStart;vidx=this._virtualStart;for(;pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}for(pidx=0;pidx<this._physicalStart;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}},_computeVidx:function(pidx){if(pidx>=this._physicalStart){return this._virtualStart+(pidx-this._physicalStart)}return this._virtualStart+(this._physicalCount-this._physicalStart)+pidx},_assignModels:function(itemSet){this._iterateItems(function(pidx,vidx){var el=this._physicalItems[pidx];var inst=el._templateInstance;var item=this.items&&this.items[vidx];if(item!=null){inst[this.as]=item;inst.__key__=this._collection.getKey(item);inst[this.selectedAs]=this.$.selector.isSelected(item);inst[this.indexAs]=vidx;inst.tabIndex=this._focusedIndex===vidx?0:-1;this._physicalIndexForKey[inst.__key__]=pidx;el.removeAttribute("hidden")}else{inst.__key__=null;el.setAttribute("hidden","")}},itemSet)},_updateMetrics:function(itemSet){Polymer.dom.flush();var newPhysicalSize=0;var oldPhysicalSize=0;var prevAvgCount=this._physicalAverageCount;var prevPhysicalAvg=this._physicalAverage;this._iterateItems(function(pidx,vidx){oldPhysicalSize+=this._physicalSizes[pidx]||0;this._physicalSizes[pidx]=this._physicalItems[pidx].offsetHeight;newPhysicalSize+=this._physicalSizes[pidx];this._physicalAverageCount+=this._physicalSizes[pidx]?1:0},itemSet);if(this.grid){this._updateGridMetrics();this._physicalSize=Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight}else{this._physicalSize=this._physicalSize+newPhysicalSize-oldPhysicalSize}if(this._physicalAverageCount!==prevAvgCount){this._physicalAverage=Math.round((prevPhysicalAvg*prevAvgCount+newPhysicalSize)/this._physicalAverageCount)}},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().width:200;this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight:200;this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition();var y=this._physicalTop;if(this.grid){var totalItemWidth=this._itemsPerRow*this._itemWidth;var rowOffset=(this._viewportWidth-totalItemWidth)/2;this._iterateItems(function(pidx,vidx){var modulus=vidx%this._itemsPerRow;var x=Math.floor(modulus*this._itemWidth+rowOffset);this.translate3d(x+"px",y+"px",0,this._physicalItems[pidx]);if(this._shouldRenderNextRow(vidx)){y+=this._rowHeight}})}else{this._iterateItems(function(pidx,vidx){this.translate3d(0,y+"px",0,this._physicalItems[pidx]);y+=this._physicalSizes[pidx]})}},_getPhysicalSizeIncrement:function(pidx){if(!this.grid){return this._physicalSizes[pidx]}if(this._computeVidx(pidx)%this._itemsPerRow!==this._itemsPerRow-1){return 0}return this._rowHeight},_shouldRenderNextRow:function(vidx){return vidx%this._itemsPerRow===this._itemsPerRow-1},_adjustScrollPosition:function(){var deltaHeight=this._virtualStart===0?this._physicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(deltaHeight){this._physicalTop=this._physicalTop-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physicalTop!==0){this._resetScrollPosition(this._scrollTop-deltaHeight)}}},_resetScrollPosition:function(pos){if(this.scrollTarget){this._scrollTop=pos;this._scrollPosition=this._scrollTop}},_updateScrollerSize:function(forceUpdate){if(this.grid){this._estScrollHeight=this._virtualRowCount*this._rowHeight}else{this._estScrollHeight=this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAverage}forceUpdate=forceUpdate||this._scrollHeight===0;forceUpdate=forceUpdate||this._scrollPosition>=this._estScrollHeight-this._physicalSize;forceUpdate=forceUpdate||this.grid&&this.$.items.style.height<this._estScrollHeight;if(forceUpdate||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._optPhysicalSize){this.$.items.style.height=this._estScrollHeight+"px";this._scrollHeight=this._estScrollHeight}},scrollToItem:function(item){return this.scrollToIndex(this.items.indexOf(item))},scrollToIndex:function(idx){if(typeof idx!=="number"||idx<0||idx>this.items.length-1){return}Polymer.dom.flush();if(this._physicalCount===0){return}idx=Math.min(Math.max(idx,0),this._virtualCount-1);if(!this._isIndexRendered(idx)||idx>=this._maxVirtualStart){this._virtualStart=this.grid?idx-this._itemsPerRow*2:idx-1}this._manageFocus();this._assignModels();this._updateMetrics();this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage;var currentTopItem=this._physicalStart;var currentVirtualItem=this._virtualStart;var targetOffsetTop=0;var hiddenContentSize=this._hiddenContentSize;while(currentVirtualItem<idx&&targetOffsetTop<=hiddenContentSize){targetOffsetTop=targetOffsetTop+this._getPhysicalSizeIncrement(currentTopItem);currentTopItem=(currentTopItem+1)%this._physicalCount;currentVirtualItem++}this._updateScrollerSize(true);this._positionItems();this._resetScrollPosition(this._physicalTop+this._scrollerPaddingTop+targetOffsetTop);this._increasePoolIfNeeded();this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null},_resetAverage:function(){this._physicalAverage=0;this._physicalAverageCount=0},_resizeHandler:function(){var delta=Math.abs(this._viewportHeight-this._scrollTargetHeight);if(IOS&&delta>0&&delta<100){return}Polymer.dom.addDebouncer(this.debounce("_debounceTemplate",function(){this.updateViewportBoundaries();this._render();if(this._isVisible){this.toggleScrollListener(true);if(this._physicalCount>0){this._resetAverage();this.scrollToIndex(this.firstVisibleIndex)}}else{this.toggleScrollListener(false)}}.bind(this),1))},_getModelFromItem:function(item){var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[key];if(pidx!=null){return this._physicalItems[pidx]._templateInstance}return null},_getNormalizedItem:function(item){if(this._collection.getKey(item)===undefined){if(typeof item==="number"){item=this.items[item];if(!item){throw new RangeError("<item> not found")}return item}throw new TypeError("<item> should be a valid item")}return item},selectItem:function(item){item=this._getNormalizedItem(item);var model=this._getModelFromItem(item);if(!this.multiSelection&&this.selectedItem){this.deselectItem(this.selectedItem)}if(model){model[this.selectedAs]=true}this.$.selector.select(item);this.updateSizeForItem(item)},deselectItem:function(item){item=this._getNormalizedItem(item);var model=this._getModelFromItem(item);if(model){model[this.selectedAs]=false}this.$.selector.deselect(item);this.updateSizeForItem(item)},toggleSelectionForItem:function(item){item=this._getNormalizedItem(item);if(this.$.selector.isSelected(item)){this.deselectItem(item)}else{this.selectItem(item)}},clearSelection:function(){function unselect(item){var model=this._getModelFromItem(item);if(model){model[this.selectedAs]=false}}if(Array.isArray(this.selectedItems)){this.selectedItems.forEach(unselect,this)}else if(this.selectedItem){unselect.call(this,this.selectedItem)}this.$.selector.clearSelection()},_selectionEnabledChanged:function(selectionEnabled){var handler=selectionEnabled?this.listen:this.unlisten;handler.call(this,this,"tap","_selectionHandler")},_selectionHandler:function(e){var model=this.modelForElement(e.target);if(!model){return}var modelTabIndex,activeElTabIndex;var target=Polymer.dom(e).path[0];var activeEl=Polymer.dom(this.domHost?this.domHost.root:document).activeElement; -if(target.localName==="input"||target.localName==="button"||target.localName==="select"){return}modelTabIndex=model.tabIndex;model.tabIndex=SECRET_TABINDEX;activeElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabIndex=modelTabIndex;if(activeEl&&physicalItem!==activeEl&&physicalItem.contains(activeEl)&&activeElTabIndex!==SECRET_TABINDEX){return}this.toggleSelectionForItem(model[this.as])},_multiSelectionChanged:function(multiSelection){this.clearSelection();this.$.selector.multi=multiSelection},updateSizeForItem:function(item){item=this._getNormalizedItem(item);var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[key];if(pidx!=null){this._updateMetrics([pidx]);this._positionItems()}},_manageFocus:function(){var fidx=this._focusedIndex;if(fidx>=0&&fidx<this._virtualCount){if(this._isIndexRendered(fidx)){this._restoreFocusedItem()}else{this._createFocusBackfillItem()}}else if(this._virtualCount>0&&this._physicalCount>0){this._focusedIndex=this._virtualStart;this._focusedItem=this._physicalItems[this._physicalStart]}},_isIndexRendered:function(idx){return idx>=this._virtualStart&&idx<=this._virtualEnd},_isIndexVisible:function(idx){return idx>=this.firstVisibleIndex&&idx<=this.lastVisibleIndex},_getPhysicalIndex:function(idx){return this._physicalIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))]},_focusPhysicalItem:function(idx){if(idx<0||idx>=this._virtualCount){return}this._restoreFocusedItem();if(!this._isIndexRendered(idx)){this.scrollToIndex(idx)}var physicalItem=this._physicalItems[this._getPhysicalIndex(idx)];var model=physicalItem._templateInstance;var focusable;model.tabIndex=SECRET_TABINDEX;if(physicalItem.tabIndex===SECRET_TABINDEX){focusable=physicalItem}if(!focusable){focusable=Polymer.dom(physicalItem).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')}model.tabIndex=0;this._focusedIndex=idx;focusable&&focusable.focus()},_removeFocusedItem:function(){if(this._offscreenFocusedItem){Polymer.dom(this).removeChild(this._offscreenFocusedItem)}this._offscreenFocusedItem=null;this._focusBackfillItem=null;this._focusedItem=null;this._focusedIndex=-1},_createFocusBackfillItem:function(){var fidx=this._focusedIndex;var pidx=this._getPhysicalIndex(fidx);if(this._offscreenFocusedItem||pidx==null||fidx<0){return}if(!this._focusBackfillItem){var stampedTemplate=this.stamp(null);this._focusBackfillItem=stampedTemplate.root.querySelector("*");Polymer.dom(this).appendChild(stampedTemplate.root)}this._offscreenFocusedItem=this._physicalItems[pidx];this._offscreenFocusedItem._templateInstance.tabIndex=0;this._physicalItems[pidx]=this._focusBackfillItem;this.translate3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)},_restoreFocusedItem:function(){var pidx,fidx=this._focusedIndex;if(!this._offscreenFocusedItem||this._focusedIndex<0){return}this._assignModels();pidx=this._getPhysicalIndex(fidx);if(pidx!=null){this._focusBackfillItem=this._physicalItems[pidx];this._focusBackfillItem._templateInstance.tabIndex=-1;this._physicalItems[pidx]=this._offscreenFocusedItem;this._offscreenFocusedItem=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillItem)}},_didFocus:function(e){var targetModel=this.modelForElement(e.target);var focusedModel=this._focusedItem?this._focusedItem._templateInstance:null;var hasOffscreenFocusedItem=this._offscreenFocusedItem!==null;var fidx=this._focusedIndex;if(!targetModel||!focusedModel){return}if(focusedModel===targetModel){if(!this._isIndexVisible(fidx)){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem();focusedModel.tabIndex=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs];this._focusedIndex=fidx;this._focusedItem=this._physicalItems[this._getPhysicalIndex(fidx)];if(hasOffscreenFocusedItem&&!this._offscreenFocusedItem){this._update()}}},_didMoveUp:function(){this._focusPhysicalItem(this._focusedIndex-1)},_didMoveDown:function(e){e.detail.keyboardEvent.preventDefault();this._focusPhysicalItem(this._focusedIndex+1)},_didEnter:function(e){this._focusPhysicalItem(this._focusedIndex);this._selectionHandler(e.detail.keyboardEvent)}})})(); +var physicalItem=this._physicalItems[this._getPhysicalIndex(model[this.indexAs])];if(target.localName==="input"||target.localName==="button"||target.localName==="select"){return}modelTabIndex=model.tabIndex;model.tabIndex=SECRET_TABINDEX;activeElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabIndex=modelTabIndex;if(activeEl&&physicalItem!==activeEl&&physicalItem.contains(activeEl)&&activeElTabIndex!==SECRET_TABINDEX){return}this.toggleSelectionForItem(model[this.as])},_multiSelectionChanged:function(multiSelection){this.clearSelection();this.$.selector.multi=multiSelection},updateSizeForItem:function(item){item=this._getNormalizedItem(item);var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[key];if(pidx!=null){this._updateMetrics([pidx]);this._positionItems()}},_manageFocus:function(){var fidx=this._focusedIndex;if(fidx>=0&&fidx<this._virtualCount){if(this._isIndexRendered(fidx)){this._restoreFocusedItem()}else{this._createFocusBackfillItem()}}else if(this._virtualCount>0&&this._physicalCount>0){this._focusedIndex=this._virtualStart;this._focusedItem=this._physicalItems[this._physicalStart]}},_isIndexRendered:function(idx){return idx>=this._virtualStart&&idx<=this._virtualEnd},_isIndexVisible:function(idx){return idx>=this.firstVisibleIndex&&idx<=this.lastVisibleIndex},_getPhysicalIndex:function(idx){return this._physicalIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))]},_focusPhysicalItem:function(idx){if(idx<0||idx>=this._virtualCount){return}this._restoreFocusedItem();if(!this._isIndexRendered(idx)){this.scrollToIndex(idx)}var physicalItem=this._physicalItems[this._getPhysicalIndex(idx)];var model=physicalItem._templateInstance;var focusable;model.tabIndex=SECRET_TABINDEX;if(physicalItem.tabIndex===SECRET_TABINDEX){focusable=physicalItem}if(!focusable){focusable=Polymer.dom(physicalItem).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')}model.tabIndex=0;this._focusedIndex=idx;focusable&&focusable.focus()},_removeFocusedItem:function(){if(this._offscreenFocusedItem){Polymer.dom(this).removeChild(this._offscreenFocusedItem)}this._offscreenFocusedItem=null;this._focusBackfillItem=null;this._focusedItem=null;this._focusedIndex=-1},_createFocusBackfillItem:function(){var fidx=this._focusedIndex;var pidx=this._getPhysicalIndex(fidx);if(this._offscreenFocusedItem||pidx==null||fidx<0){return}if(!this._focusBackfillItem){var stampedTemplate=this.stamp(null);this._focusBackfillItem=stampedTemplate.root.querySelector("*");Polymer.dom(this).appendChild(stampedTemplate.root)}this._offscreenFocusedItem=this._physicalItems[pidx];this._offscreenFocusedItem._templateInstance.tabIndex=0;this._physicalItems[pidx]=this._focusBackfillItem;this.translate3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)},_restoreFocusedItem:function(){var pidx,fidx=this._focusedIndex;if(!this._offscreenFocusedItem||this._focusedIndex<0){return}this._assignModels();pidx=this._getPhysicalIndex(fidx);if(pidx!=null){this._focusBackfillItem=this._physicalItems[pidx];this._focusBackfillItem._templateInstance.tabIndex=-1;this._physicalItems[pidx]=this._offscreenFocusedItem;this._offscreenFocusedItem=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillItem)}},_didFocus:function(e){var targetModel=this.modelForElement(e.target);var focusedModel=this._focusedItem?this._focusedItem._templateInstance:null;var hasOffscreenFocusedItem=this._offscreenFocusedItem!==null;var fidx=this._focusedIndex;if(!targetModel||!focusedModel){return}if(focusedModel===targetModel){if(!this._isIndexVisible(fidx)){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem();focusedModel.tabIndex=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs];this._focusedIndex=fidx;this._focusedItem=this._physicalItems[this._getPhysicalIndex(fidx)];if(hasOffscreenFocusedItem&&!this._offscreenFocusedItem){this._update()}}},_didMoveUp:function(){this._focusPhysicalItem(this._focusedIndex-1)},_didMoveDown:function(e){e.detail.keyboardEvent.preventDefault();this._focusPhysicalItem(this._focusedIndex+1)},_didEnter:function(e){this._focusPhysicalItem(this._focusedIndex);this._selectionHandler(e.detail.keyboardEvent)}})})(); // Copyright 2015 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. @@ -64,8 +64,8 @@ // Copyright 2015 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. -cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",properties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_:{type:Boolean,value:false,reflectToAttribute:true},inSearchMode_:{type:Boolean,value:false},items_:{type:Array,value:function(){return[]}},spinnerActive_:{type:Boolean,notify:true}},hostAttributes:{loading:true},listeners:{"downloads-list.scroll":"onListScroll_","toolbar.search-changed":"onSearchChanged_"},observers:["itemsChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownloadsChanged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$.toolbar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_)this.$["downloads-list"].fire("iron-resize")},insertItems_:function(index,list){this.splice.apply(this,["items_",index,0].concat(list));this.updateHideDates_(index,index+list.length);this.removeAttribute("loading");this.spinnerActive_=false},itemsChanged_:function(){this.hasDownloads_=this.items_.length>0},noDownloadsText_:function(){return loadTimeData.getString(this.inSearchMode_?"noSearchResults":"noDownloads")},onCanExecute_:function(e){e=e;switch(e.command.id){case"undo-command":e.canExecute=this.$.toolbar.canUndo();break;case"clear-all-command":e.canExecute=this.$.toolbar.canClearAll();break;case"find-command":e.canExecute=true;break}},onCommand_:function(e){if(e.command.id=="clear-all-command")downloads.ActionService.getInstance().clearAll();else if(e.command.id=="undo-command")downloads.ActionService.getInstance().undo();else if(e.command.id=="find-command")this.$.toolbar.onFindCommand()},onListScroll_:function(){var list=this.$["downloads-list"];if(list.scrollHeight-list.scrollTop-list.offsetHeight<=100){downloads.ActionService.getInstance().loadMore()}this.hasShadow_=list.scrollTop>0},onLoad_:function(){cr.ui.decorate("command",cr.ui.Command);document.addEventListener("canExecute",this.onCanExecute_.bind(this));document.addEventListener("command",this.onCommand_.bind(this));downloads.ActionService.getInstance().loadMore()},onSearchChanged_:function(){this.inSearchMode_=downloads.ActionService.getInstance().isSearching()},removeItem_:function(index){this.splice("items_",index,1);this.updateHideDates_(index,index);this.onListScroll_()},updateHideDates_:function(start,end){for(var i=start;i<=end;++i){var current=this.items_[i];if(!current)continue;var prev=this.items_[i-1];var hideDate=!!prev&&prev.date_string==current.date_string;this.set("items_."+i+".hideDate",hideDate)}},updateItem_:function(index,data){this.set("items_."+index,data);this.updateHideDates_(index,index);var list=this.$["downloads-list"];list.updateSizeForItem(index)}});Manager.clearAll=function(){Manager.get().clearAll_()};Manager.get=function(){return queryRequiredElement("downloads-manager")};Manager.insertItems=function(index,list){Manager.get().insertItems_(index,list)};Manager.onLoad=function(){Manager.get().onLoad_()};Manager.removeItem=function(index){Manager.get().removeItem_(index)};Manager.updateItem=function(index,data){Manager.get().updateItem_(index,data)};return{Manager:Manager}}); +cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",properties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_:{type:Boolean,value:false,reflectToAttribute:true},inSearchMode_:{type:Boolean,value:false},items_:{type:Array,value:function(){return[]}},spinnerActive_:{type:Boolean,notify:true}},hostAttributes:{loading:true},listeners:{"downloads-list.scroll":"onListScroll_","toolbar.search-changed":"onSearchChanged_"},observers:["itemsChanged_(items_.*)"],loaded_:new PromiseResolver,clearAll_:function(){this.set("items_",[])},hasDownloadsChanged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$.toolbar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_)this.$["downloads-list"].fire("iron-resize")},insertItems_:function(index,list){this.splice.apply(this,["items_",index,0].concat(list));this.updateHideDates_(index,index+list.length);if(this.hasAttribute("loading")){this.removeAttribute("loading");this.loaded_.resolve()}this.spinnerActive_=false},itemsChanged_:function(){this.hasDownloads_=this.items_.length>0},noDownloadsText_:function(){return loadTimeData.getString(this.inSearchMode_?"noSearchResults":"noDownloads")},onCanExecute_:function(e){e=e;switch(e.command.id){case"undo-command":e.canExecute=this.$.toolbar.canUndo();break;case"clear-all-command":e.canExecute=this.$.toolbar.canClearAll();break;case"find-command":e.canExecute=true;break}},onCommand_:function(e){if(e.command.id=="clear-all-command")downloads.ActionService.getInstance().clearAll();else if(e.command.id=="undo-command")downloads.ActionService.getInstance().undo();else if(e.command.id=="find-command")this.$.toolbar.onFindCommand()},onListScroll_:function(){var list=this.$["downloads-list"];if(list.scrollHeight-list.scrollTop-list.offsetHeight<=100){downloads.ActionService.getInstance().loadMore()}this.hasShadow_=list.scrollTop>0},onLoad_:function(){cr.ui.decorate("command",cr.ui.Command);document.addEventListener("canExecute",this.onCanExecute_.bind(this));document.addEventListener("command",this.onCommand_.bind(this));downloads.ActionService.getInstance().loadMore();return this.loaded_.promise},onSearchChanged_:function(){this.inSearchMode_=downloads.ActionService.getInstance().isSearching()},removeItem_:function(index){this.splice("items_",index,1);this.updateHideDates_(index,index);this.onListScroll_()},updateHideDates_:function(start,end){for(var i=start;i<=end;++i){var current=this.items_[i];if(!current)continue;var prev=this.items_[i-1];var hideDate=!!prev&&prev.date_string==current.date_string;this.set("items_."+i+".hideDate",hideDate)}},updateItem_:function(index,data){this.set("items_."+index,data);this.updateHideDates_(index,index);var list=this.$["downloads-list"];list.updateSizeForItem(index)}});Manager.clearAll=function(){Manager.get().clearAll_()};Manager.get=function(){return queryRequiredElement("downloads-manager")};Manager.insertItems=function(index,list){Manager.get().insertItems_(index,list)};Manager.onLoad=function(){return Manager.get().onLoad_()};Manager.removeItem=function(index){Manager.get().removeItem_(index)};Manager.updateItem=function(index,data){Manager.get().updateItem_(index,data)};return{Manager:Manager}}); // Copyright 2015 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. -window.addEventListener("load",function(){downloads.Manager.onLoad();document.fonts.load("bold 12px Roboto")}); \ No newline at end of file +window.addEventListener("load",function(){downloads.Manager.onLoad().then(function(){requestIdleCallback(function(){chrome.send("metricsHandler:recordTime",["Download.ResultsRenderedTime",window.performance.now()]);document.fonts.load("bold 12px Roboto")})})}); \ No newline at end of file
diff --git a/chrome/browser/resources/md_downloads/downloads.js b/chrome/browser/resources/md_downloads/downloads.js index bfed6d1..9f934af 100644 --- a/chrome/browser/resources/md_downloads/downloads.js +++ b/chrome/browser/resources/md_downloads/downloads.js
@@ -3,6 +3,13 @@ // found in the LICENSE file. window.addEventListener('load', function() { - downloads.Manager.onLoad(); - document.fonts.load('bold 12px Roboto'); + downloads.Manager.onLoad().then(function() { + requestIdleCallback(function() { + chrome.send('metricsHandler:recordTime', [ + 'Download.ResultsRenderedTime', + window.performance.now() + ]); + document.fonts.load('bold 12px Roboto'); + }); + }); });
diff --git a/chrome/browser/resources/md_downloads/manager.js b/chrome/browser/resources/md_downloads/manager.js index 62b6b34..743aacd 100644 --- a/chrome/browser/resources/md_downloads/manager.js +++ b/chrome/browser/resources/md_downloads/manager.js
@@ -52,6 +52,9 @@ 'itemsChanged_(items_.*)', ], + /** @private {!PromiseResolver} */ + loaded_: new PromiseResolver, + /** @private */ clearAll_: function() { this.set('items_', []); @@ -74,7 +77,12 @@ insertItems_: function(index, list) { this.splice.apply(this, ['items_', index, 0].concat(list)); this.updateHideDates_(index, index + list.length); - this.removeAttribute('loading'); + + if (this.hasAttribute('loading')) { + this.removeAttribute('loading'); + this.loaded_.resolve(); + } + this.spinnerActive_ = false; }, @@ -134,13 +142,17 @@ this.hasShadow_ = list.scrollTop > 0; }, - /** @private */ + /** + * @return {!Promise} + * @private + */ onLoad_: function() { cr.ui.decorate('command', cr.ui.Command); document.addEventListener('canExecute', this.onCanExecute_.bind(this)); document.addEventListener('command', this.onCommand_.bind(this)); downloads.ActionService.getInstance().loadMore(); + return this.loaded_.promise; }, /** @private */ @@ -201,8 +213,9 @@ Manager.get().insertItems_(index, list); }; + /** @return {!Promise} */ Manager.onLoad = function() { - Manager.get().onLoad_(); + return Manager.get().onLoad_(); }; Manager.removeItem = function(index) {
diff --git a/chrome/browser/resources/md_history/app.crisper.js b/chrome/browser/resources/md_history/app.crisper.js index 97e35a1..a4ee83e 100644 --- a/chrome/browser/resources/md_history/app.crisper.js +++ b/chrome/browser/resources/md_history/app.crisper.js
@@ -45,7 +45,7 @@ // Copyright 2014 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. -cr.define("cr.ui",function(){function FocusRow(root,boundary,opt_delegate){this.root=root;this.boundary_=boundary||document.documentElement;this.delegate=opt_delegate;this.eventTracker=new EventTracker}FocusRow.Delegate=function(){};FocusRow.Delegate.prototype={onKeydown:assertNotReached,onFocus:assertNotReached};FocusRow.ACTIVE_CLASS="focus-row-active";FocusRow.isFocusable=function(element){if(!element||element.disabled)return false;function isVisible(element){assertInstanceof(element,Element);var style=window.getComputedStyle(element);if(style.visibility=="hidden"||style.display=="none")return false;var parent=element.parentNode;if(!parent)return false;if(parent==element.ownerDocument||parent instanceof DocumentFragment)return true;return isVisible(parent)}return isVisible(element)};FocusRow.prototype={addItem:function(type,query){assert(type);var element=this.root.querySelector(query);if(!element)return false;element.setAttribute("focus-type",type);element.tabIndex=this.isActive()?0:-1;this.eventTracker.add(element,"blur",this.onBlur_.bind(this));this.eventTracker.add(element,"focus",this.onFocus_.bind(this));this.eventTracker.add(element,"keydown",this.onKeydown_.bind(this));this.eventTracker.add(element,"mousedown",this.onMousedown_.bind(this));return true},destroy:function(){this.eventTracker.removeAll()},getCustomEquivalent:function(sampleElement){return assert(this.getFirstFocusable())},getElements:function(){var elements=this.root.querySelectorAll("[focus-type]");return Array.prototype.slice.call(elements)},getEquivalentElement:function(sampleElement){if(this.getFocusableElements().indexOf(sampleElement)>=0)return sampleElement;var sampleFocusType=this.getTypeForElement(sampleElement);if(sampleFocusType){var sameType=this.getFirstFocusable(sampleFocusType);if(sameType)return sameType}return this.getCustomEquivalent(sampleElement)},getFirstFocusable:function(opt_type){var filter=opt_type?'="'+opt_type+'"':"";var elements=this.root.querySelectorAll("[focus-type"+filter+"]");for(var i=0;i<elements.length;++i){if(cr.ui.FocusRow.isFocusable(elements[i]))return elements[i]}return null},getFocusableElements:function(){return this.getElements().filter(cr.ui.FocusRow.isFocusable)},getTypeForElement:function(element){return element.getAttribute("focus-type")||""},isActive:function(){return this.root.classList.contains(FocusRow.ACTIVE_CLASS)},makeActive:function(active){if(active==this.isActive())return;this.getElements().forEach(function(element){element.tabIndex=active?0:-1});this.root.classList.toggle(FocusRow.ACTIVE_CLASS,active)},onBlur_:function(e){if(!this.boundary_.contains(e.relatedTarget))return;var currentTarget=e.currentTarget;if(this.getFocusableElements().indexOf(currentTarget)>=0)this.makeActive(false)},onFocus_:function(e){if(this.delegate)this.delegate.onFocus(this,e)},onMousedown_:function(e){if(e.button)return;if(!e.currentTarget.disabled)e.currentTarget.tabIndex=0},onKeydown_:function(e){var elements=this.getFocusableElements();var currentElement=e.currentTarget;var elementIndex=elements.indexOf(currentElement);assert(elementIndex>=0);if(this.delegate&&this.delegate.onKeydown(this,e))return;if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;var index=-1;if(e.key=="ArrowLeft")index=elementIndex+(isRTL()?1:-1);else if(e.key=="ArrowRight")index=elementIndex+(isRTL()?-1:1);else if(e.key=="Home")index=0;else if(e.key=="End")index=elements.length-1;var elementToFocus=elements[index];if(elementToFocus){this.getEquivalentElement(elementToFocus).focus();e.preventDefault()}}};return{FocusRow:FocusRow}}); +cr.define("cr.ui",function(){function FocusRow(root,boundary,opt_delegate){this.root=root;this.boundary_=boundary||document.documentElement;this.delegate=opt_delegate;this.eventTracker=new EventTracker}FocusRow.Delegate=function(){};FocusRow.Delegate.prototype={onKeydown:assertNotReached,onFocus:assertNotReached};FocusRow.ACTIVE_CLASS="focus-row-active";FocusRow.isFocusable=function(element){if(!element||element.disabled)return false;function isVisible(element){assertInstanceof(element,Element);var style=window.getComputedStyle(element);if(style.visibility=="hidden"||style.display=="none")return false;var parent=element.parentNode;if(!parent)return false;if(parent==element.ownerDocument||parent instanceof DocumentFragment)return true;return isVisible(parent)}return isVisible(element)};FocusRow.prototype={addItem:function(type,query){assert(type);var element=this.root.querySelector(query);if(!element)return false;element.setAttribute("focus-type",type);element.tabIndex=this.isActive()?0:-1;this.eventTracker.add(element,"blur",this.onBlur_.bind(this));this.eventTracker.add(element,"focus",this.onFocus_.bind(this));this.eventTracker.add(element,"keydown",this.onKeydown_.bind(this));this.eventTracker.add(element,"mousedown",this.onMousedown_.bind(this));return true},destroy:function(){this.eventTracker.removeAll()},getCustomEquivalent:function(sampleElement){return assert(this.getFirstFocusable())},getElements:function(){var elements=this.root.querySelectorAll("[focus-type]");return Array.prototype.slice.call(elements)},getEquivalentElement:function(sampleElement){if(this.getFocusableElements().indexOf(sampleElement)>=0)return sampleElement;var sampleFocusType=this.getTypeForElement(sampleElement);if(sampleFocusType){var sameType=this.getFirstFocusable(sampleFocusType);if(sameType)return sameType}return this.getCustomEquivalent(sampleElement)},getFirstFocusable:function(opt_type){var filter=opt_type?'="'+opt_type+'"':"";var elements=this.root.querySelectorAll("[focus-type"+filter+"]");for(var i=0;i<elements.length;++i){if(cr.ui.FocusRow.isFocusable(elements[i]))return elements[i]}return null},getFocusableElements:function(){return this.getElements().filter(cr.ui.FocusRow.isFocusable)},getTypeForElement:function(element){return element.getAttribute("focus-type")||""},isActive:function(){return this.root.classList.contains(FocusRow.ACTIVE_CLASS)},makeActive:function(active){if(active==this.isActive())return;this.getElements().forEach(function(element){element.tabIndex=active?0:-1});this.root.classList.toggle(FocusRow.ACTIVE_CLASS,active)},onBlur_:function(e){if(!this.boundary_.contains(e.relatedTarget))return;var currentTarget=e.currentTarget;if(this.getFocusableElements().indexOf(currentTarget)>=0)this.makeActive(false)},onFocus_:function(e){if(this.delegate)this.delegate.onFocus(this,e)},onMousedown_:function(e){if(e.button)return;if(!e.currentTarget.disabled)e.currentTarget.tabIndex=0},onKeydown_:function(e){var elements=this.getFocusableElements();var currentElement=e.currentTarget;var elementIndex=elements.indexOf(currentElement);assert(elementIndex>=0);if(this.delegate&&this.delegate.onKeydown(this,e))return;if(hasKeyModifiers(e))return;var index=-1;if(e.key=="ArrowLeft")index=elementIndex+(isRTL()?1:-1);else if(e.key=="ArrowRight")index=elementIndex+(isRTL()?-1:1);else if(e.key=="Home")index=0;else if(e.key=="End")index=elements.length-1;var elementToFocus=elements[index];if(elementToFocus){this.getEquivalentElement(elementToFocus).focus();e.preventDefault()}}};return{FocusRow:FocusRow}}); // Copyright 2016 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.
diff --git a/chrome/browser/resources/ntp4/dot_list.js b/chrome/browser/resources/ntp4/dot_list.js index 017a786..779dcda 100644 --- a/chrome/browser/resources/ntp4/dot_list.js +++ b/chrome/browser/resources/ntp4/dot_list.js
@@ -41,10 +41,10 @@ /** * Handler for key events on the dot list. These keys will change the focus * element. - * @param {Event} e The KeyboardEvent. + * @param {!Event} e The KeyboardEvent. */ onKeyDown_: function(e) { - if (e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) + if (hasKeyModifiers(e)) return; var direction = 0;
diff --git a/chrome/browser/resources/options/cookies_list.js b/chrome/browser/resources/options/cookies_list.js index 21f4d00b..5cd0f97 100644 --- a/chrome/browser/resources/options/cookies_list.js +++ b/chrome/browser/resources/options/cookies_list.js
@@ -754,7 +754,7 @@ */ handleKeyLeftRight_: function(e) { var id = e.key; - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) + if (hasKeyModifiers(e)) return; if ((id == 'ArrowLeft' || id == 'ArrowRight') && this.expandedItem) { var cs = this.ownerDocument.defaultView.getComputedStyle(this);
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js index 118c50b..da5793d 100644 --- a/chrome/browser/resources/pdf/pdf.js +++ b/chrome/browser/resources/pdf/pdf.js
@@ -320,7 +320,7 @@ pageDownHandler(); return; case 37: // Left arrow key. - if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) { + if (!hasKeyModifiers(e)) { // Go to the previous page if there are no horizontal scrollbars and // no form field is focused. if (!(this.viewport_.documentHasScrollbars().horizontal || @@ -341,7 +341,7 @@ } return; case 39: // Right arrow key. - if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) { + if (!hasKeyModifiers(e)) { // Go to the next page if there are no horizontal scrollbars and no // form field is focused. if (!(this.viewport_.documentHasScrollbars().horizontal ||
diff --git a/chrome/browser/resources/print_preview/common/overlay.js b/chrome/browser/resources/print_preview/common/overlay.js index 4585dd64..e5f58fa 100644 --- a/chrome/browser/resources/print_preview/common/overlay.js +++ b/chrome/browser/resources/print_preview/common/overlay.js
@@ -40,7 +40,7 @@ this.getElement().addEventListener('keydown', function f(e) { // Escape pressed -> cancel the dialog. - if (!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { + if (!hasKeyModifiers(e)) { if (e.keyCode == 27) { e.stopPropagation(); e.preventDefault();
diff --git a/chrome/browser/resources/print_preview/previewarea/preview_area.js b/chrome/browser/resources/print_preview/previewarea/preview_area.js index a572b42f..3c25bc0 100644 --- a/chrome/browser/resources/print_preview/previewarea/preview_area.js +++ b/chrome/browser/resources/print_preview/previewarea/preview_area.js
@@ -260,7 +260,7 @@ // If the user is holding a modifier key, ignore. if (!this.plugin_ || !arrayContains([33, 34, 37, 38, 39, 40], e.keyCode) || - e.metaKey || e.altKey || e.shiftKey || e.ctrlKey) { + hasKeyModifiers(e)) { return; }
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index 0c5f7c9c..afe40161 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -903,8 +903,7 @@ */ onKeyDown_: function(e) { // Escape key closes the dialog. - if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && - !e.metaKey) { + if (e.keyCode == 27 && !hasKeyModifiers(e)) { // On non-mac with toolkit-views, ESC key is handled by C++-side instead // of JS-side. if (cr.isMac) {
diff --git a/chrome/browser/resources/print_preview/search/destination_list_item.js b/chrome/browser/resources/print_preview/search/destination_list_item.js index 48b5b817..8b529d45 100644 --- a/chrome/browser/resources/print_preview/search/destination_list_item.js +++ b/chrome/browser/resources/print_preview/search/destination_list_item.js
@@ -227,7 +227,7 @@ * @private */ onKeyDown_: function(e) { - if (!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { + if (!hasKeyModifiers(e)) { if (e.keyCode == 13) { var activeElementTag = document.activeElement ? document.activeElement.tagName.toUpperCase() : ''; @@ -281,7 +281,7 @@ * @private */ onExtensionIconKeyDown_: function(e) { - if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) + if (hasKeyModifiers(e)) return; if (e.keyCode != 13 /* Enter */) return;
diff --git a/chrome/browser/resources/settings/device_page/keyboard.html b/chrome/browser/resources/settings/device_page/keyboard.html index 6b111be..cb7b630 100644 --- a/chrome/browser/resources/settings/device_page/keyboard.html +++ b/chrome/browser/resources/settings/device_page/keyboard.html
@@ -3,6 +3,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="/controls/settings_checkbox.html"> <link rel="import" href="/controls/settings_dropdown_menu.html"> <link rel="import" href="/i18n_setup.html"> @@ -109,10 +110,12 @@ </iron-collapse> <div id="keyboardOverlay" class="settings-box" on-tap="onShowKeyboardShortcutsOverlayTap_" actionable> - $i18n{showKeyboardShortcutsOverlay} + <div class="start">$i18n{showKeyboardShortcutsOverlay}</div> + <button class="icon-external" is="paper-icon-button-light"></button> </div> <div class="settings-box" on-tap="onShowLanguageInputTap_" actionable> - $i18n{keyboardShowLanguageAndInput} + <div class="start">$i18n{keyboardShowLanguageAndInput}</div> + <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> </template> <script src="keyboard.js"></script>
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html b/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html index 847c03f..c11eec9 100644 --- a/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html +++ b/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html
@@ -31,6 +31,25 @@ -webkit-margin-start: 16px; color: var(--paper-grey-600); } + + #addressList .start { + display: flex; + overflow: hidden; + } + + #addressSummary { + display: flex; + flex: 1; + overflow: hidden; + } + + .ellipses { + flex: 1; + max-width: fit-content; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } </style> <div class="settings-box first"> <h2>$i18n{addresses}</h2> @@ -40,7 +59,14 @@ <template is="dom-repeat" items="[[addresses]]"> <div class="list-item two-line"> <div class="start"> - <span id="addressSummary">[[address_(item)]]</span> + <span id="addressSummary"> + <span class="ellipses"> + [[item.metadata.summaryLabel]] + </span> + <span class="ellipses"> + [[item.metadata.summarySublabel]] + </span> + </span> <span class="payments-label" hidden$="[[item.metadata.isLocal]]"> $i18n{googlePayments} </span>
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js b/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js index 5d3a865..dfd4bc7c 100644 --- a/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js +++ b/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js
@@ -47,15 +47,6 @@ }, /** - * Formats an AddressEntry so it's displayed as an address. - * @param {!chrome.autofillPrivate.AddressEntry} item - * @return {string} - */ - address_: function(item) { - return item.metadata.summaryLabel + item.metadata.summarySublabel; - }, - - /** * Formats the expiration date so it's displayed as MM/YYYY. * @param {!chrome.autofillPrivate.CreditCardEntry} item * @return {string}
diff --git a/chrome/browser/resources/settings/people_page/manage_profile.html b/chrome/browser/resources/settings/people_page/manage_profile.html index e78622a..f0f4e78 100644 --- a/chrome/browser/resources/settings/people_page/manage_profile.html +++ b/chrome/browser/resources/settings/people_page/manage_profile.html
@@ -33,7 +33,7 @@ </template> <cr-profile-avatar-selector id="selector" avatars="[[availableIcons]]" selected-avatar-url="{{profileIconUrl}}" - on-iron-activate="onIconActivate_"> + on-iron-activate="onIconActivate_" ignore-modified-key-events> </cr-profile-avatar-selector> </template> <script src="manage_profile.js"></script>
diff --git a/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp b/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp index 095db126d..5985d7c 100644 --- a/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp +++ b/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp
@@ -9,6 +9,7 @@ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', '../compiled_resources2.gyp:route', '../site_settings/compiled_resources2.gyp:constants', '../site_settings/compiled_resources2.gyp:site_settings_behavior',
diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.html b/chrome/browser/resources/settings/site_settings_page/site_settings_page.html index 75f145c7..8efa74b 100644 --- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.html +++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.html
@@ -1,4 +1,5 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="/icons.html"> <link rel="import" href="/route.html"> @@ -26,7 +27,7 @@ <iron-icon icon="settings:cookie"></iron-icon> <div class="middle"> <div>$i18n{siteSettingsCookies}</div> - <div id="cookies" class="secondary"></div> + <div class="secondary">[[default_.cookies]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -36,7 +37,7 @@ <iron-icon icon="settings:location-on"></iron-icon> <div class="middle"> <div>$i18n{siteSettingsLocation}</div> - <div id="geolocation" class="secondary"></div> + <div class="secondary">[[default_.location]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -47,7 +48,7 @@ <iron-icon icon="settings:videocam"></iron-icon> <div class="middle"> <div>$i18n{siteSettingsCamera}</div> - <div id="camera" class="secondary"></div> + <div class="secondary">[[default_.mediaStreamCamera]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -57,7 +58,7 @@ <iron-icon icon="settings:mic"></iron-icon> <div class="middle"> $i18n{siteSettingsMic} - <div id="mic" class="secondary"></div> + <div class="secondary">[[default_.mediaStreamMic]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -68,7 +69,7 @@ <iron-icon icon="settings:notifications"></iron-icon> <div class="middle"> $i18n{siteSettingsNotifications} - <div id="notifications" class="secondary"></div> + <div class="secondary">[[default_.notifications]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -79,7 +80,7 @@ <iron-icon icon="settings:input"></iron-icon> <div class="middle"> $i18n{siteSettingsJavascript} - <div id="javascript" class="secondary"></div> + <div class="secondary">[[default_.javascript]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -89,7 +90,7 @@ <iron-icon icon="cr:extension"></iron-icon> <div class="middle"> $i18n{siteSettingsFlash} - <div id="plugins" class="secondary"></div> + <div class="secondary">[[default_.plugins]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -99,7 +100,7 @@ <iron-icon icon="settings:photo"></iron-icon> <div class="middle"> $i18n{siteSettingsImages} - <div id="images" class="secondary"></div> + <div class="secondary">[[default_.images]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -109,7 +110,7 @@ <iron-icon icon="cr:open-in-new"></iron-icon> <div class="middle"> $i18n{siteSettingsPopups} - <div id="popups" class="secondary"></div> + <div class="secondary">[[default_.popups]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -120,7 +121,7 @@ <iron-icon icon="settings:sync"></iron-icon> <div class="middle"> $i18n{siteSettingsBackgroundSync} - <div id="backgroundSync" class="secondary"></div> + <div class="secondary">[[default_.backgroundSync]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -130,7 +131,7 @@ <iron-icon icon="settings:code"></iron-icon> <div class="middle"> $i18n{siteSettingsKeygen} - <div id="keygen" class="secondary"></div> + <div class="secondary">[[default_.keygen]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -141,7 +142,7 @@ <iron-icon icon="cr:file-download"></iron-icon> <div class="middle"> $i18n{siteSettingsAutomaticDownloads} - <div id="automaticDownloads" class="secondary"></div> + <div class="secondary">[[default_.multipleAutomaticDownloads]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -152,7 +153,7 @@ <iron-icon icon="cr:extension"></iron-icon> <div class="middle"> $i18n{siteSettingsUnsandboxedPlugins} - <div id="unsandboxedPlugins" class="secondary"></div> + <div class="secondary">[[default_.ppapiBroker]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div> @@ -163,7 +164,7 @@ <iron-icon icon="settings:protocol-handler"></iron-icon> <div class="middle"> $i18n{siteSettingsHandlers} - <div id="handlers" class="secondary"></div> + <div class="secondary">[[default_.registerProtocolHandler]]</div> </div> <button class="subpage-arrow" is="paper-icon-button-light"></button> </div>
diff --git a/chrome/browser/resources/settings/site_settings_page/site_settings_page.js b/chrome/browser/resources/settings/site_settings_page/site_settings_page.js index c2f031d5..7ba95a5 100644 --- a/chrome/browser/resources/settings/site_settings_page/site_settings_page.js +++ b/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
@@ -10,9 +10,22 @@ Polymer({ is: 'settings-site-settings-page', - behaviors: [SiteSettingsBehavior], + behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], properties: { + /** + * An object to bind default value labels to (so they are not in the |this| + * scope). The keys of this object are the values of the + * settings.ContentSettingsTypes enum. + * @private + */ + default_: { + type: Object, + value: function() { + return {}; + }, + }, + /** @private */ enableSiteSettings_: { type: Boolean, @@ -26,35 +39,36 @@ this.ContentSettingsTypes = settings.ContentSettingsTypes; this.ALL_SITES = settings.ALL_SITES; - // Look up the default value for each category and show it. - this.setDefaultValue_(this.ContentSettingsTypes.AUTOMATIC_DOWNLOADS, - '#automaticDownloads'); - this.setDefaultValue_(this.ContentSettingsTypes.BACKGROUND_SYNC, - '#backgroundSync'); - this.setDefaultValue_(this.ContentSettingsTypes.CAMERA, '#camera'); - this.setDefaultValue_(this.ContentSettingsTypes.COOKIES, '#cookies'); - this.setDefaultValue_(this.ContentSettingsTypes.GEOLOCATION, - '#geolocation'); - this.setDefaultValue_(this.ContentSettingsTypes.IMAGES, '#images'); - this.setDefaultValue_(this.ContentSettingsTypes.JAVASCRIPT, - '#javascript'); - this.setDefaultValue_(this.ContentSettingsTypes.KEYGEN, '#keygen'); - this.setDefaultValue_(this.ContentSettingsTypes.MIC, '#mic'); - this.setDefaultValue_(this.ContentSettingsTypes.NOTIFICATIONS, - '#notifications'); - this.setDefaultValue_(this.ContentSettingsTypes.PLUGINS, '#plugins'); - this.setDefaultValue_(this.ContentSettingsTypes.POPUPS, '#popups'); - this.setDefaultValue_(this.ContentSettingsTypes.PROTOCOL_HANDLERS, - '#handlers'); - this.setDefaultValue_(this.ContentSettingsTypes.UNSANDBOXED_PLUGINS, - '#unsandboxedPlugins'); + var keys = Object.keys(settings.ContentSettingsTypes); + for (var i = 0; i < keys.length; ++i) { + var key = settings.ContentSettingsTypes[keys[i]]; + // Default labels are not applicable to USB and ZOOM. + if (key == settings.ContentSettingsTypes.USB_DEVICES || + key == settings.ContentSettingsTypes.ZOOM_LEVELS) + continue; + this.updateDefaultValueLabel_(key); + } + + this.addWebUIListener( + 'contentSettingCategoryChanged', + this.updateDefaultValueLabel_.bind(this)); }, - setDefaultValue_: function(category, id) { + /** + * @param {string} category The category to update. + * @private + */ + updateDefaultValueLabel_: function(category) { this.browserProxy.getDefaultValueForContentType( - category).then(function(setting) { - var description = this.computeCategoryDesc(category, setting, false); - this.$$(id).innerText = description; + category).then(function(defaultValue) { + var labelVar = + 'default_.' + Polymer.CaseMap.dashToCamelCase(category); + this.set( + labelVar, + this.computeCategoryDesc( + category, + defaultValue.setting, + /*showRecommendation=*/false)); }.bind(this)); },
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui.css b/chrome/browser/resources/vr_shell/vr_shell_ui.css index d48fa334..77c6cb5 100644 --- a/chrome/browser/resources/vr_shell/vr_shell_ui.css +++ b/chrome/browser/resources/vr_shell/vr_shell_ui.css
@@ -152,6 +152,8 @@ } #omni .connection-security { + display: none; + flex: none; height: 50px; margin-right: 10px; width: 50px;
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui.html b/chrome/browser/resources/vr_shell/vr_shell_ui.html index 2d5364dc..3ba2f45b 100644 --- a/chrome/browser/resources/vr_shell/vr_shell_ui.html +++ b/chrome/browser/resources/vr_shell/vr_shell_ui.html
@@ -34,9 +34,11 @@ <div id="omni-container" class="ui-element"> <div id="omni" class="idle"> <div id="omni-content"> - <img id="omni-insecure-icon" class="connection-security" + <img id="omni-warning-icon" class="connection-security" + src="../../../../ui/webui/resources/images/warning.svg"> + <img id="omni-info-icon" class="connection-security" src="../../../../ui/webui/resources/images/i_circle.svg"> - <img id="omni-secure-icon" class="connection-security" + <img id="omni-lock-icon" class="connection-security" src="../../../../ui/webui/resources/images/lock.svg"> <div id="url"> <span id="domain"></span><span id="path"></span>
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui.js b/chrome/browser/resources/vr_shell/vr_shell_ui.js index c3595e2..3c8b7c82 100644 --- a/chrome/browser/resources/vr_shell/vr_shell_ui.js +++ b/chrome/browser/resources/vr_shell/vr_shell_ui.js
@@ -288,6 +288,23 @@ this.onAnimationDone.bind(this)); } + getSecurityIconElementId(level) { + // See security_state.h and getSecurityIconResource() for this mapping. + switch (level) { + case 0: // NONE + case 1: // HTTP_SHOW_WARNING + case 4: // SECURITY_WARNING + return '#omni-info-icon'; + case 2: // SECURE: + case 3: // EV_SECURE: + return '#omni-lock-icon'; + case 5: // SECURE_WITH_POLICY_INSTALLED_CERT (ChromeOS only) + case 6: // DANGEROUS + default: + return '#omni-warning-icon'; + } + } + setEnabled(enabled) { this.enabled = enabled; this.resetVisibilityTimer(); @@ -347,11 +364,12 @@ this.setNativeVisibility(false); return; } - let secure = this.level == 2 || this.level == 3; - document.querySelector('#omni-secure-icon').style.display = - (secure ? 'block' : 'none'); - document.querySelector('#omni-insecure-icon').style.display = - (secure ? 'none' : 'block'); + + document.querySelector('#omni-warning-icon').style.display = 'none'; + document.querySelector('#omni-info-icon').style.display = 'none'; + document.querySelector('#omni-lock-icon').style.display = 'none'; + let icon = this.getSecurityIconElementId(this.level); + document.querySelector(icon).style.display = 'block'; let state = 'idle'; this.visibleAfterTransition = true;
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index af4465a9..201c61fa 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -109,9 +109,9 @@ proceeded_(false) { // Computes display options based on user profile and blocked resource. bool is_main_frame_load_blocked = IsMainPageLoadBlocked(unsafe_resources); - bool can_show_threat_details_option = CanShowThreatDetailsOption(); + bool can_show_extended_reporting_option = CanShowExtendedReportingOption(); SafeBrowsingErrorUI::SBErrorDisplayOptions display_options( - is_main_frame_load_blocked, can_show_threat_details_option, + is_main_frame_load_blocked, can_show_extended_reporting_option, IsExtendedReportingEnabled(*profile()->GetPrefs()), IsScout(*profile()->GetPrefs()), IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); @@ -135,7 +135,7 @@ // reports. if (unsafe_resources.size() == 1 && ShouldReportThreatDetails(unsafe_resources[0].threat_type) && - threat_details_.get() == NULL && can_show_threat_details_option) { + threat_details_.get() == NULL && can_show_extended_reporting_option) { threat_details_ = ThreatDetails::NewThreatDetails(ui_manager_, web_contents, unsafe_resources[0]); } @@ -150,9 +150,8 @@ threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; } -bool SafeBrowsingBlockingPage::CanShowThreatDetailsOption() { +bool SafeBrowsingBlockingPage::CanShowExtendedReportingOption() { return (!web_contents()->GetBrowserContext()->IsOffTheRecord() && - main_frame_url_.SchemeIs(url::kHttpScheme) && IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); }
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h index 04b906de..a302b93 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
@@ -106,18 +106,10 @@ ExtendedReportingNotShownOnSecurePage); FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, MalwareReportsTransitionDisabled); - FRIEND_TEST_ALL_PREFIXES( - SafeBrowsingBlockingPageTest, - ExtendedReportingNotShownOnSecurePageWithSecureSubresource); - FRIEND_TEST_ALL_PREFIXES( - SafeBrowsingBlockingPageTest, - ExtendedReportingNotShownOnSecurePageWithInsecureSubresource); - FRIEND_TEST_ALL_PREFIXES( - SafeBrowsingBlockingPageTest, - ExtendedReportingOnInsecurePageWithSecureSubresource); - FRIEND_TEST_ALL_PREFIXES( - SafeBrowsingBlockingPageTest, - ExtendedReportingNotShownOnSecurePageWithPendingInsecureLoad); + FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, + ExtendedReportingNotShownInIncognito); + FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, + ExtendedReportingNotShownNotAllowExtendedReporting); void UpdateReportingPref(); // Used for the transition from old to new pref. @@ -138,9 +130,10 @@ // milliseconds), in order to get data from the blocked resource itself. int64_t threat_details_proceed_delay_ms_; - // Checks if we should even show the threat details option. For example, we - // don't show it in incognito mode. - bool CanShowThreatDetailsOption(); + // Checks if we should even show the extended reporting option. We don't show + // it in incognito mode or if kSafeBrowsingExtendedReportingOptInAllowed + // preference is disabled. + bool CanShowExtendedReportingOption(); // Called when the insterstitial is going away. If there is a // pending threat details object, we look at the user's
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc index 38c2d74a..5100146 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
@@ -898,16 +898,6 @@ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); } -// Verifies that the reporting checkbox is hidden on non-HTTP pages. -// TODO(mattm): Should also verify that no report is sent, but there isn't a -// good way to do that in the current design. -IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ReportingDisabled) { - SetExtendedReportingPref(browser()->profile()->GetPrefs(), true); - - TestReportingDisabledAndDontProceed( - net::URLRequestMockHTTPJob::GetMockHttpsUrl(kEmptyPage)); -} - // Verifies that the reporting checkbox is hidden when opt-in is // disabled by policy. IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index 43699d1..0376620 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -11,7 +11,9 @@ #include "chrome/browser/safe_browsing/test_safe_browsing_service.h" #include "chrome/browser/safe_browsing/threat_details.h" #include "chrome/browser/safe_browsing/ui_manager.h" +#include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" +#include "chrome/test/base/testing_profile.h" #include "components/prefs/pref_service.h" #include "components/safe_browsing_db/safe_browsing_prefs.h" #include "content/public/browser/interstitial_page.h" @@ -19,6 +21,8 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "content/public/test/web_contents_tester.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" using content::InterstitialPage; using content::NavigationEntry; @@ -27,11 +31,9 @@ static const char* kGoogleURL = "http://www.google.com/"; static const char* kGoodURL = "http://www.goodguys.com/"; -static const char* kGoodHTTPSURL = "https://www.goodguys.com/"; static const char* kBadURL = "http://www.badguys.com/"; static const char* kBadURL2 = "http://www.badguys2.com/"; static const char* kBadURL3 = "http://www.badguys3.com/"; -static const char* kBadHTTPSURL = "https://www.badguys.com/"; namespace safe_browsing { @@ -71,6 +73,14 @@ } }; +class MockTestingProfile : public TestingProfile { + public: + MockTestingProfile() {} + virtual ~MockTestingProfile() {} + + MOCK_CONST_METHOD0(IsOffTheRecord, bool()); +}; + } // namespace class SafeBrowsingBlockingPageTest : public ChromeRenderViewHostTestHarness { @@ -104,6 +114,19 @@ ChromeRenderViewHostTestHarness::TearDown(); } + content::BrowserContext* CreateBrowserContext() override { + // Set custom profile object so that we can mock calls to IsOffTheRecord. + // This needs to happen before we call the parent SetUp() function. We use + // a nice mock because other parts of the code are calling IsOffTheRecord. + mock_profile_ = new testing::NiceMock<MockTestingProfile>(); + return mock_profile_; + } + + void SetProfileOffTheRecord() { + EXPECT_CALL(*mock_profile_, IsOffTheRecord()) + .WillRepeatedly(testing::Return(true)); + } + void OnBlockingPageComplete(bool proceed) { if (proceed) user_response_ = OK; @@ -203,6 +226,9 @@ scoped_refptr<TestSafeBrowsingUIManager> ui_manager_; + // Owned by TestSafeBrowsingBlockingPage. + MockTestingProfile* mock_profile_; + private: void InitResource(security_interstitials::UnsafeResource* resource, bool is_subresource, @@ -611,7 +637,7 @@ ShowInterstitial(false, kBadURL); SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); ASSERT_TRUE(sb_interstitial); - EXPECT_TRUE(sb_interstitial->CanShowThreatDetailsOption()); + EXPECT_TRUE(sb_interstitial->CanShowExtendedReportingOption()); base::RunLoop().RunUntilIdle(); @@ -645,7 +671,7 @@ ShowInterstitial(false, kBadURL); SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); ASSERT_TRUE(sb_interstitial); - EXPECT_TRUE(sb_interstitial->CanShowThreatDetailsOption()); + EXPECT_TRUE(sb_interstitial->CanShowExtendedReportingOption()); base::RunLoop().RunUntilIdle(); @@ -662,23 +688,26 @@ EXPECT_FALSE(IsExtendedReportingEnabled(*profile->GetPrefs())); } -// Test that extended reporting option is not shown on blocking an HTTPS main -// page, and no report is sent. -TEST_F(SafeBrowsingBlockingPageTest, ExtendedReportingNotShownOnSecurePage) { +// Test that extended reporting option is not shown in incognito window. +TEST_F(SafeBrowsingBlockingPageTest, + ExtendedReportingNotShownInIncognito) { + // Make profile in incognito mode. + SetProfileOffTheRecord(); // Enable malware details. Profile* profile = Profile::FromBrowserContext( web_contents()->GetBrowserContext()); + ASSERT_TRUE(profile->IsOffTheRecord()); SetExtendedReportingPref(profile->GetPrefs(), true); // Start a load. - controller().LoadURL(GURL(kBadHTTPSURL), content::Referrer(), + controller().LoadURL(GURL(kBadURL), content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); // Simulate the load causing a safe browsing interstitial to be shown. - ShowInterstitial(false, kBadHTTPSURL); + ShowInterstitial(false, kBadURL); SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); ASSERT_TRUE(sb_interstitial); - EXPECT_FALSE(sb_interstitial->CanShowThreatDetailsOption()); + EXPECT_FALSE(sb_interstitial->CanShowExtendedReportingOption()); base::RunLoop().RunUntilIdle(); @@ -694,25 +723,25 @@ ui_manager_->GetThreatDetails()->clear(); } -// Test that extended reporting option is not shown on blocking an HTTPS -// subresource on an HTTPS page, and no report is sent. +// Test that extended reporting option is not shown if +// kSafeBrowsingExtendedReportingOptInAllowed is disabled. TEST_F(SafeBrowsingBlockingPageTest, - ExtendedReportingNotShownOnSecurePageWithSecureSubresource) { + ExtendedReportingNotShownNotAllowExtendedReporting) { // Enable malware details. Profile* profile = Profile::FromBrowserContext( web_contents()->GetBrowserContext()); - SetExtendedReportingPref(profile->GetPrefs(), true); + profile->GetPrefs()->SetBoolean( + prefs::kSafeBrowsingExtendedReportingOptInAllowed, false); - // Commit a load. - content::WebContentsTester::For(web_contents()) - ->NavigateAndCommit(GURL(kGoodHTTPSURL)); + // Start a load. + controller().LoadURL(GURL(kBadURL), content::Referrer(), + ui::PAGE_TRANSITION_TYPED, std::string()); - // Simulate a subresource load causing a safe browsing interstitial to be - // shown. - ShowInterstitial(true, kBadHTTPSURL); + // Simulate the load causing a safe browsing interstitial to be shown. + ShowInterstitial(false, kBadURL); SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); ASSERT_TRUE(sb_interstitial); - EXPECT_FALSE(sb_interstitial->CanShowThreatDetailsOption()); + EXPECT_FALSE(sb_interstitial->CanShowExtendedReportingOption()); base::RunLoop().RunUntilIdle(); @@ -728,117 +757,4 @@ ui_manager_->GetThreatDetails()->clear(); } -// Test that extended reporting option is not shown on blocking an HTTP -// subresource on an HTTPS page, and no report is sent. -TEST_F(SafeBrowsingBlockingPageTest, - ExtendedReportingNotShownOnSecurePageWithInsecureSubresource) { - // Enable malware details. - Profile* profile = Profile::FromBrowserContext( - web_contents()->GetBrowserContext()); - SetExtendedReportingPref(profile->GetPrefs(), true); - - // Commit a load. - content::WebContentsTester::For(web_contents()) - ->NavigateAndCommit(GURL(kGoodHTTPSURL)); - - // Simulate a subresource load causing a safe browsing interstitial to be - // shown. - ShowInterstitial(true, kBadURL); - SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); - ASSERT_TRUE(sb_interstitial); - EXPECT_FALSE(sb_interstitial->CanShowThreatDetailsOption()); - - base::RunLoop().RunUntilIdle(); - - // Simulate the user clicking "don't proceed". - DontProceedThroughInterstitial(sb_interstitial); - - // The interstitial should be gone. - EXPECT_EQ(CANCEL, user_response()); - EXPECT_FALSE(GetSafeBrowsingBlockingPage()); - - // No report should have been sent. - EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); - ui_manager_->GetThreatDetails()->clear(); -} - -// Test that extended reporting option is shown on blocking an HTTPS -// subresource on an HTTP page. -TEST_F(SafeBrowsingBlockingPageTest, - ExtendedReportingOnInsecurePageWithSecureSubresource) { - // Enable malware details. - Profile* profile = Profile::FromBrowserContext( - web_contents()->GetBrowserContext()); - SetExtendedReportingPref(profile->GetPrefs(), true); - - // Commit a load. - content::WebContentsTester::For(web_contents()) - ->NavigateAndCommit(GURL(kGoodURL)); - - // Simulate a subresource load causing a safe browsing interstitial to be - // shown. - ShowInterstitial(true, kBadHTTPSURL); - SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); - ASSERT_TRUE(sb_interstitial); - EXPECT_TRUE(sb_interstitial->CanShowThreatDetailsOption()); - - base::RunLoop().RunUntilIdle(); - - // Simulate the user clicking "don't proceed". - DontProceedThroughInterstitial(sb_interstitial); - - // The interstitial should be gone. - EXPECT_EQ(CANCEL, user_response()); - EXPECT_FALSE(GetSafeBrowsingBlockingPage()); - - // A report should have been sent. - EXPECT_EQ(1u, ui_manager_->GetThreatDetails()->size()); - ui_manager_->GetThreatDetails()->clear(); -} - -// Test that extended reporting option is not shown on blocking an HTTPS -// subresource on an HTTPS page while there is a pending load for an HTTP page, -// and no report is sent. -TEST_F(SafeBrowsingBlockingPageTest, - ExtendedReportingNotShownOnSecurePageWithPendingInsecureLoad) { - // Enable malware details. - Profile* profile = Profile::FromBrowserContext( - web_contents()->GetBrowserContext()); - SetExtendedReportingPref(profile->GetPrefs(), true); - - // Commit a load. - content::WebContentsTester::For(web_contents()) - ->NavigateAndCommit(GURL(kGoodHTTPSURL)); - - GURL pending_url("http://slow.example.com"); - - // Start a pending load. - content::WebContentsTester::For(web_contents())->StartNavigation(pending_url); - - // Simulate a subresource load on the committed page causing a safe browsing - // interstitial to be shown. - ShowInterstitial(true, kBadHTTPSURL); - SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); - ASSERT_TRUE(sb_interstitial); - // Threat details option should not be shown. (The blocking page is for the - // committed HTTPS page, not the pending HTTP page.) - EXPECT_FALSE(sb_interstitial->CanShowThreatDetailsOption()); - - base::RunLoop().RunUntilIdle(); - - // Simulate the user clicking "don't proceed". - DontProceedThroughInterstitial(sb_interstitial); - - // The interstitial should be gone. - EXPECT_EQ(CANCEL, user_response()); - EXPECT_FALSE(GetSafeBrowsingBlockingPage()); - - // No report should have been sent. - EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); - ui_manager_->GetThreatDetails()->clear(); -} - -// TODO(mattm): Add test for extended reporting not shown or sent in incognito -// window. - } // namespace safe_browsing
diff --git a/chrome/browser/safe_browsing/srt_fetcher_win.cc b/chrome/browser/safe_browsing/srt_fetcher_win.cc index 50cbfe6..5f176dd 100644 --- a/chrome/browser/safe_browsing/srt_fetcher_win.cc +++ b/chrome/browser/safe_browsing/srt_fetcher_win.cc
@@ -272,12 +272,11 @@ } else { parse_error = true; } - - // Clean up the old value. - reporter_key.DeleteValue(kFoundUwsValueName); - - RecordBooleanHistogram(kFoundUwsReadErrorMetricName, parse_error); } + + // Clean up the old value. + reporter_key.DeleteValue(kFoundUwsValueName); + RecordBooleanHistogram(kFoundUwsReadErrorMetricName, parse_error); } // Reports to UMA the memory usage of the software reporter tool as reported
diff --git a/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc b/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc index 594e63d..99404cb 100644 --- a/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc +++ b/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
@@ -14,6 +14,7 @@ #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h" +#include "chrome/browser/ui/webui/metrics_handler.h" #include "chrome/browser/ui/webui/theme_source.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/features.h" @@ -144,6 +145,7 @@ handler_ = new MdDownloadsDOMHandler(dlm, web_ui); web_ui->AddMessageHandler(handler_); + web_ui->AddMessageHandler(new MetricsHandler); // Set up the chrome://downloads/ source. content::WebUIDataSource* source = CreateDownloadsUIHTMLSource(profile);
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc index 26bff84..6363c746 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc
@@ -5,7 +5,6 @@ #include "chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h" #include "base/bind.h" -#include "base/sys_info.h" #include "base/values.h" #include "content/public/browser/web_ui.h"
diff --git a/chrome/test/base/tracing.cc b/chrome/test/base/tracing.cc index f210652..ab89cc81 100644 --- a/chrome/test/base/tracing.cc +++ b/chrome/test/base/tracing.cc
@@ -53,10 +53,12 @@ InProcessTraceController() {} virtual ~InProcessTraceController() {} - bool BeginTracing(const base::trace_event::TraceConfig& trace_config) { + bool BeginTracing( + const base::trace_event::TraceConfig& trace_config, + tracing::StartTracingDoneCallback start_tracing_done_callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); return content::TracingController::GetInstance()->StartTracing( - trace_config, content::TracingController::StartTracingDoneCallback()); + trace_config, start_tracing_done_callback); } bool EndTracing(std::string* json_trace_output) { @@ -99,12 +101,21 @@ bool BeginTracing(const std::string& category_patterns) { return InProcessTraceController::GetInstance()->BeginTracing( - base::trace_event::TraceConfig(category_patterns, "")); + base::trace_event::TraceConfig(category_patterns, ""), + tracing::StartTracingDoneCallback()); } bool BeginTracingWithTraceConfig( const base::trace_event::TraceConfig& trace_config) { - return InProcessTraceController::GetInstance()->BeginTracing(trace_config); + return InProcessTraceController::GetInstance()->BeginTracing( + trace_config, tracing::StartTracingDoneCallback()); +} + +bool BeginTracingWithTraceConfig( + const base::trace_event::TraceConfig& trace_config, + tracing::StartTracingDoneCallback start_tracing_done_callback) { + return InProcessTraceController::GetInstance()->BeginTracing( + trace_config, start_tracing_done_callback); } bool EndTracing(std::string* json_trace_output) {
diff --git a/chrome/test/base/tracing.h b/chrome/test/base/tracing.h index 9c87927..115597b 100644 --- a/chrome/test/base/tracing.h +++ b/chrome/test/base/tracing.h
@@ -32,11 +32,18 @@ // Begin tracing specified category_patterns on the browser. // |trace_config| specifies the configuration for tracing. This includes the // list of categories enabled, tracing modes and memory dumps configuration. +// Once all child processes have acked to the StartTracing request, +// |start_tracing_done_callback| will be called back. // // See base/trace_event/trace_config.h for documentation of configurations. bool BeginTracingWithTraceConfig( const base::trace_event::TraceConfig& trace_config) WARN_UNUSED_RESULT; +typedef base::Callback<void()> StartTracingDoneCallback; +bool BeginTracingWithTraceConfig( + const base::trace_event::TraceConfig& trace_config, + StartTracingDoneCallback start_tracing_done_callback) WARN_UNUSED_RESULT; + // Called from UI thread. // End trace and collect the trace output as a json string. bool EndTracing(std::string* json_trace_output) WARN_UNUSED_RESULT;
diff --git a/chrome/test/base/tracing_browsertest.cc b/chrome/test/base/tracing_browsertest.cc index 6c0f86f..c5df112 100644 --- a/chrome/test/base/tracing_browsertest.cc +++ b/chrome/test/base/tracing_browsertest.cc
@@ -29,6 +29,21 @@ using tracing::BeginTracingWithTraceConfig; using tracing::EndTracing; +void RequestGlobalDumpCallback(base::Closure quit_closure, + uint64_t, + bool success) { + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); + ASSERT_TRUE(success); +} + +void OnStartTracingDoneCallback( + base::trace_event::MemoryDumpLevelOfDetail explicit_dump_type, + base::Closure quit_closure) { + base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump( + MemoryDumpType::EXPLICITLY_TRIGGERED, explicit_dump_type, + Bind(&RequestGlobalDumpCallback, quit_closure)); +} + class TracingBrowserTest : public InProcessBrowserTest { protected: // Execute some no-op javascript on the current tab - this triggers a trace @@ -42,17 +57,20 @@ } void PerformDumpMemoryTestActions( - const base::trace_event::TraceConfig& trace_config) { + const base::trace_event::TraceConfig& trace_config, + base::trace_event::MemoryDumpLevelOfDetail explicit_dump_type) { GURL url1("about:blank"); ui_test_utils::NavigateToURLWithDisposition( browser(), url1, WindowOpenDisposition::NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); - // Begin tracing and watch for multiple periodic dump trace events. - std::string event_name = base::trace_event::MemoryDumpTypeToString( - MemoryDumpType::PERIODIC_INTERVAL); - ASSERT_TRUE(BeginTracingWithTraceConfig(trace_config)); + // Begin tracing and trigger dump once start is broadcasted to all + // processes. + base::RunLoop run_loop; + ASSERT_TRUE(BeginTracingWithTraceConfig( + trace_config, Bind(&OnStartTracingDoneCallback, explicit_dump_type, + run_loop.QuitClosure()))); // Create and destroy renderers while tracing is enabled. GURL url2("chrome://credits"); @@ -70,6 +88,7 @@ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); + run_loop.Run(); std::string json_events; ASSERT_TRUE(EndTracing(&json_events)); @@ -80,18 +99,20 @@ } }; -// Flaky: http://crbug.com/658054 -IN_PROC_BROWSER_TEST_F(TracingBrowserTest, DISABLED_TestMemoryInfra) { - PerformDumpMemoryTestActions(base::trace_event::TraceConfig( - base::trace_event::TraceConfigMemoryTestUtil:: - GetTraceConfig_PeriodicTriggers(250, 2000))); +IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestMemoryInfra) { + PerformDumpMemoryTestActions( + base::trace_event::TraceConfig( + base::trace_event::TraceConfigMemoryTestUtil:: + GetTraceConfig_EmptyTriggers()), + base::trace_event::MemoryDumpLevelOfDetail::DETAILED); } -// Flaky: http://crbug.com/658054 -IN_PROC_BROWSER_TEST_F(TracingBrowserTest, DISABLED_TestBackgroundMemoryInfra) { - PerformDumpMemoryTestActions(base::trace_event::TraceConfig( - base::trace_event::TraceConfigMemoryTestUtil:: - GetTraceConfig_BackgroundTrigger(200))); +IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestBackgroundMemoryInfra) { + PerformDumpMemoryTestActions( + base::trace_event::TraceConfig( + base::trace_event::TraceConfigMemoryTestUtil:: + GetTraceConfig_BackgroundTrigger(200)), + base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); } } // namespace
diff --git a/chrome/test/data/webrtc/webrtc-simulcast.html b/chrome/test/data/webrtc/webrtc-simulcast.html index b61e4b3..2ffa13ae 100644 --- a/chrome/test/data/webrtc/webrtc-simulcast.html +++ b/chrome/test/data/webrtc/webrtc-simulcast.html
@@ -135,12 +135,12 @@ function initialize() { trace('Setting up for a new call.'); - var servers = null; + var configs = {iceServers:[], rtcpMuxPolicy:'negotiate'}; var constraints = {'mandatory': {'DtlsSrtpKeyAgreement': false}}; - pcClient = new webkitRTCPeerConnection(servers, constraints); + pcClient = new webkitRTCPeerConnection(configs, constraints); trace('Created local peer connection object pcClient'); pcClient.onicecandidate = onClientIceCandidate; - pcServer = new webkitRTCPeerConnection(servers, constraints); + pcServer = new webkitRTCPeerConnection(configs, constraints); trace('Created remote peer connection object pcServer'); pcServer.onicecandidate = onServerIceCandidate; pcServer.onaddstream = onServerGotStream;
diff --git a/chrome/test/data/webui/cr_elements/cr_profile_avatar_selector_tests.js b/chrome/test/data/webui/cr_elements/cr_profile_avatar_selector_tests.js index d422997..f7666137 100644 --- a/chrome/test/data/webui/cr_elements/cr_profile_avatar_selector_tests.js +++ b/chrome/test/data/webui/cr_elements/cr_profile_avatar_selector_tests.js
@@ -88,6 +88,34 @@ // Simulate tapping the second avatar. MockInteractions.tap(avatarSelector.$['avatar-grid'].items[1]); }); + + test('Ignores modified key events', function() { + var selector = avatarSelector.$['avatar-grid']; + var items = selector.items; + + selector._setFocusedItem(items[0]); + assertTrue(items[0].focused); + + MockInteractions.keyDownOn(items[0], 39, [], 'ArrowRight'); + assertTrue(items[1].focused); + + MockInteractions.keyDownOn(items[0], 37, [], 'ArrowLeft'); + assertTrue(items[0].focused); + + avatarSelector.ignoreModifiedKeyEvents = true; + + MockInteractions.keyDownOn(items[0], 39, 'alt', 'ArrowRight'); + assertTrue(items[0].focused); + + MockInteractions.keyDownOn(items[0], 39, 'ctrl', 'ArrowRight'); + assertTrue(items[0].focused); + + MockInteractions.keyDownOn(items[0], 39, 'meta', 'ArrowRight'); + assertTrue(items[0].focused); + + MockInteractions.keyDownOn(items[0], 39, 'shift', 'ArrowRight'); + assertTrue(items[0].focused); + }); }); }
diff --git a/chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js b/chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js index 08b926a0..18c5d33 100644 --- a/chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js +++ b/chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js
@@ -70,7 +70,7 @@ ret.languageCode = 'EN-US'; ret.metadata = {isLocal: true}; ret.metadata.summaryLabel = ret.fullNames[0]; - ret.metadata.summarySublabel = ' ' + ret.addressLines; + ret.metadata.summarySublabel = ', ' + ret.addressLines; return ret; };
diff --git a/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js b/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js index c156739..ce09a25f 100644 --- a/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js +++ b/chrome/test/data/webui/settings/settings_autofill_section_browsertest.js
@@ -419,8 +419,15 @@ var addressSummary = address.metadata.summaryLabel + address.metadata.summarySublabel; - assertEquals(addressSummary, - row.querySelector('#addressSummary').textContent); + var actualSummary = ''; + + // Eliminate white space between nodes! + var addressPieces = row.querySelector('#addressSummary').children; + for (var i = 0; i < addressPieces.length; ++i) { + actualSummary += addressPieces[i].textContent.trim(); + } + + assertEquals(addressSummary, actualSummary); }); test('verifyAddAddressDialog', function() {
diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc index 5c08c0f..96d1463 100644 --- a/components/cronet/android/cronet_url_request_context_adapter.cc +++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -8,8 +8,10 @@ #include <stddef.h> #include <stdint.h> +#include <limits> #include <map> #include <utility> +#include <vector> #include "base/android/jni_android.h" #include "base/android/jni_array.h" @@ -52,7 +54,7 @@ #include "net/cookies/cookie_monster.h" #include "net/http/http_auth_handler_factory.h" #include "net/http/http_server_properties_manager.h" -#include "net/log/bounded_file_net_log_observer.h" +#include "net/log/file_net_log_observer.h" #include "net/log/write_to_file_net_log_observer.h" #include "net/nqe/external_estimate_provider.h" #include "net/proxy/proxy_config_service_android.h" @@ -930,15 +932,15 @@ DCHECK(base::PathIsWritable(file_path)); bounded_file_observer_.reset( - new net::BoundedFileNetLogObserver(GetFileThread()->task_runner())); - if (include_socket_bytes) { - bounded_file_observer_->set_capture_mode( - net::NetLogCaptureMode::IncludeSocketBytes()); - } + new net::FileNetLogObserver(GetFileThread()->task_runner())); - bounded_file_observer_->StartObserving(g_net_log.Get().net_log(), file_path, - /*constants=*/nullptr, context_.get(), - size, kNumNetLogEventFiles); + net::NetLogCaptureMode capture_mode = + include_socket_bytes ? net::NetLogCaptureMode::IncludeSocketBytes() + : net::NetLogCaptureMode::Default(); + + bounded_file_observer_->StartObservingBounded( + g_net_log.Get().net_log(), capture_mode, file_path, + /*constants=*/nullptr, context_.get(), size, kNumNetLogEventFiles); } void CronetURLRequestContextAdapter::StopBoundedFileNetLogOnNetworkThread() {
diff --git a/components/cronet/android/cronet_url_request_context_adapter.h b/components/cronet/android/cronet_url_request_context_adapter.h index a58ecd3626..714ef99 100644 --- a/components/cronet/android/cronet_url_request_context_adapter.h +++ b/components/cronet/android/cronet_url_request_context_adapter.h
@@ -36,7 +36,7 @@ class SdchOwner; class URLRequestContext; class WriteToFileNetLogObserver; -class BoundedFileNetLogObserver; +class FileNetLogObserver; } // namespace net namespace cronet { @@ -216,7 +216,7 @@ std::unique_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; base::Lock write_to_file_observer_lock_; - std::unique_ptr<net::BoundedFileNetLogObserver> bounded_file_observer_; + std::unique_ptr<net::FileNetLogObserver> bounded_file_observer_; // |pref_service_| should outlive the HttpServerPropertiesManager owned by // |context_|.
diff --git a/components/cryptauth/eid_generator.cc b/components/cryptauth/eid_generator.cc index 069bc18..057190c 100644 --- a/components/cryptauth/eid_generator.cc +++ b/components/cryptauth/eid_generator.cc
@@ -30,6 +30,11 @@ base::TimeDelta::FromHours(2).InMilliseconds(); const int32_t EidGenerator::kNumBytesInEidValue = 2; +// static +EidGenerator* EidGenerator::GetInstance() { + return base::Singleton<EidGenerator>::get(); +} + std::string EidGenerator::EidComputationHelperImpl::GenerateEidDataForDevice( const std::string& eid_seed, const int64_t start_of_period_timestamp_ms, @@ -68,6 +73,43 @@ return AdjacentDataType::FUTURE; } +std::string EidGenerator::EidData::DataInHex() const { + std::string str = "[" + current_data.DataInHex(); + + if (adjacent_data) { + return str + ", " + adjacent_data->DataInHex() + "]"; + } + + return str + "]"; +} + +EidGenerator::DataWithTimestamp::DataWithTimestamp( + const std::string& data, + const int64_t start_timestamp_ms, + const int64_t end_timestamp_ms) + : data(data), + start_timestamp_ms(start_timestamp_ms), + end_timestamp_ms(end_timestamp_ms) { + DCHECK(start_timestamp_ms < end_timestamp_ms); + DCHECK(data.size()); +} + +bool EidGenerator::DataWithTimestamp::ContainsTime( + const int64_t timestamp_ms) const { + return start_timestamp_ms <= timestamp_ms && timestamp_ms < end_timestamp_ms; +} + +std::string EidGenerator::DataWithTimestamp::DataInHex() const { + std::stringstream ss; + ss << "0x" << std::hex; + + for (size_t i = 0; i < data.size(); i++) { + ss << static_cast<int>(data.data()[i]); + } + + return ss.str(); +} + EidGenerator::EidGenerator() : EidGenerator(base::WrapUnique(new EidComputationHelperImpl()), base::WrapUnique(new base::DefaultClock())) {} @@ -78,14 +120,6 @@ : clock_(std::move(clock)), eid_computation_helper_(std::move(computation_helper)) {} -EidGenerator::DataWithTimestamp::DataWithTimestamp( - const std::string& data, - const int64_t start_timestamp_ms, - const int64_t end_timestamp_ms) - : data(data), - start_timestamp_ms(start_timestamp_ms), - end_timestamp_ms(end_timestamp_ms) {} - EidGenerator::~EidGenerator() {} std::unique_ptr<EidGenerator::EidData>
diff --git a/components/cryptauth/eid_generator.h b/components/cryptauth/eid_generator.h index f2cd640a..89230e94 100644 --- a/components/cryptauth/eid_generator.h +++ b/components/cryptauth/eid_generator.h
@@ -10,6 +10,8 @@ #include <vector> #include "base/gtest_prod_util.h" +#include "base/macros.h" +#include "base/memory/singleton.h" #include "base/time/clock.h" namespace cryptauth { @@ -38,6 +40,7 @@ const int64_t end_timestamp_ms); bool ContainsTime(const int64_t timestamp_ms) const; + std::string DataInHex() const; const std::string data; const int64_t start_timestamp_ms; @@ -56,13 +59,14 @@ ~EidData(); AdjacentDataType GetAdjacentDataType() const; + std::string DataInHex() const; const DataWithTimestamp current_data; const std::unique_ptr<DataWithTimestamp> adjacent_data; }; - EidGenerator(); - ~EidGenerator(); + static EidGenerator* GetInstance(); + virtual ~EidGenerator(); // Generates EID data for the given EID seeds to be used as a background scan // filter. In the normal case, two DataWithTimestamp values are returned, one @@ -92,7 +96,12 @@ const std::vector<RemoteDevice>& device_list, const std::vector<BeaconSeed>& scanning_device_beacon_seeds) const; + protected: + EidGenerator(); + private: + friend struct base::DefaultSingletonTraits<EidGenerator>; + struct EidPeriodTimestamps { int64_t current_period_start_timestamp_ms; int64_t current_period_end_timestamp_ms; @@ -168,6 +177,8 @@ std::unique_ptr<EidComputationHelper> eid_computation_helper_; + DISALLOW_COPY_AND_ASSIGN(EidGenerator); + friend class CryptAuthEidGeneratorTest; FRIEND_TEST_ALL_PREFIXES( CryptAuthEidGeneratorTest, @@ -209,7 +220,7 @@ TestEidComputationHelperImpl_ChangingExtraEntropyChangesOutput); FRIEND_TEST_ALL_PREFIXES( CryptAuthEidGeneratorTest, - testEidComputationHelper_ChangingTimestampWithLongExtraEntropy); + TestEidComputationHelper_ChangingTimestampWithLongExtraEntropy); FRIEND_TEST_ALL_PREFIXES(CryptAuthEidGeneratorTest, TestEidComputationHelper_EnsureTestVectorsPass); };
diff --git a/components/cryptauth/eid_generator_unittest.cc b/components/cryptauth/eid_generator_unittest.cc index 18a73e3..cd1d20c 100644 --- a/components/cryptauth/eid_generator_unittest.cc +++ b/components/cryptauth/eid_generator_unittest.cc
@@ -653,7 +653,7 @@ } TEST_F(CryptAuthEidGeneratorTest, - testEidComputationHelper_ChangingTimestampWithLongExtraEntropy) { + TestEidComputationHelper_ChangingTimestampWithLongExtraEntropy) { EidGenerator::EidComputationHelperImpl helper; std::string long_extra_entropy = "reallyReallyReallyReallyReallyReallyReallyLongExtraEntropy"; @@ -714,4 +714,15 @@ EXPECT_EQ("\xee\xcc", test_eid_with_entropy2); } +TEST_F(CryptAuthEidGeneratorTest, + TestDataWithTimestamp_ContainsTime) { + EidGenerator::DataWithTimestamp data_with_timestamp( + "data", /* start */ 1000L, /* end */ 2000L); + EXPECT_FALSE(data_with_timestamp.ContainsTime(999L)); + EXPECT_TRUE(data_with_timestamp.ContainsTime(1000L)); + EXPECT_TRUE(data_with_timestamp.ContainsTime(1500L)); + EXPECT_TRUE(data_with_timestamp.ContainsTime(1999L)); + EXPECT_FALSE(data_with_timestamp.ContainsTime(2000L)); +} + } // namespace cryptauth
diff --git a/components/data_use_measurement/core/data_use_recorder.h b/components/data_use_measurement/core/data_use_recorder.h index 5611012..8a26da6 100644 --- a/components/data_use_measurement/core/data_use_recorder.h +++ b/components/data_use_measurement/core/data_use_recorder.h
@@ -26,7 +26,7 @@ class DataUseRecorder { public: DataUseRecorder(); - ~DataUseRecorder(); + virtual ~DataUseRecorder(); // Returns the actual data used by the entity being tracked. DataUse& data_use() { return data_use_; }
diff --git a/components/payments/payment_app.mojom b/components/payments/payment_app.mojom index 6959aa7..a12d53b 100644 --- a/components/payments/payment_app.mojom +++ b/components/payments/payment_app.mojom
@@ -25,8 +25,9 @@ }; interface PaymentAppManager { - SetManifest(string service_worker_scope, PaymentAppManifest payment_app_manifest) + Init(string service_worker_scope); + SetManifest(PaymentAppManifest payment_app_manifest) => (PaymentAppManifestError error); - GetManifest(string service_worker_scope) + GetManifest() => (PaymentAppManifest payment_app_manifest, PaymentAppManifestError error); };
diff --git a/components/security_interstitials/core/safe_browsing_error_ui.cc b/components/security_interstitials/core/safe_browsing_error_ui.cc index 7c9a1e60..44bd274e 100644 --- a/components/security_interstitials/core/safe_browsing_error_ui.cc +++ b/components/security_interstitials/core/safe_browsing_error_ui.cc
@@ -284,9 +284,10 @@ void SafeBrowsingErrorUI::PopulateExtendedReportingOption( base::DictionaryValue* load_time_data) { - load_time_data->SetBoolean(security_interstitials::kDisplayCheckBox, - display_options_.can_show_threat_details_option); - if (!display_options_.can_show_threat_details_option) + load_time_data->SetBoolean( + security_interstitials::kDisplayCheckBox, + display_options_.can_show_extended_reporting_option); + if (!display_options_.can_show_extended_reporting_option) return; const std::string privacy_link = base::StringPrintf(
diff --git a/components/security_interstitials/core/safe_browsing_error_ui.h b/components/security_interstitials/core/safe_browsing_error_ui.h index fbad261d..322edb0 100644 --- a/components/security_interstitials/core/safe_browsing_error_ui.h +++ b/components/security_interstitials/core/safe_browsing_error_ui.h
@@ -26,12 +26,13 @@ struct SBErrorDisplayOptions { SBErrorDisplayOptions(bool is_main_frame_load_blocked, - bool can_show_threat_details_option, + bool can_show_extended_reporting_option, bool is_extended_reporting_enabled, bool is_scout_reporting_enabled, bool is_proceed_anyway_disabled) : is_main_frame_load_blocked(is_main_frame_load_blocked), - can_show_threat_details_option(can_show_threat_details_option), + can_show_extended_reporting_option( + can_show_extended_reporting_option), is_extended_reporting_enabled(is_extended_reporting_enabled), is_scout_reporting_enabled(is_scout_reporting_enabled), is_proceed_anyway_disabled(is_proceed_anyway_disabled) {} @@ -40,7 +41,7 @@ bool is_main_frame_load_blocked; // Indicates if we can show extended reporting checkbox, - bool can_show_threat_details_option; + bool can_show_extended_reporting_option; // Indicates if user opted in for SB extended reporting. bool is_extended_reporting_enabled;
diff --git a/components/test_runner/mock_webrtc_peer_connection_handler.cc b/components/test_runner/mock_webrtc_peer_connection_handler.cc index 4c4a9a7..5a773d2 100644 --- a/components/test_runner/mock_webrtc_peer_connection_handler.cc +++ b/components/test_runner/mock_webrtc_peer_connection_handler.cc
@@ -459,9 +459,6 @@ return true; } -void MockWebRTCPeerConnectionHandler::logSelectedRtcpMuxPolicy( - blink::RtcpMuxPolicy selectedRtcpMuxPolicy) {} - bool MockWebRTCPeerConnectionHandler::addICECandidate( const WebRTCICECandidate& ice_candidate) { client_->didGenerateICECandidate(ice_candidate);
diff --git a/components/test_runner/mock_webrtc_peer_connection_handler.h b/components/test_runner/mock_webrtc_peer_connection_handler.h index 93a412f5..0a6c2f4 100644 --- a/components/test_runner/mock_webrtc_peer_connection_handler.h +++ b/components/test_runner/mock_webrtc_peer_connection_handler.h
@@ -52,7 +52,6 @@ blink::WebRTCSessionDescription remoteDescription() override; bool setConfiguration( const blink::WebRTCConfiguration& configuration) override; - void logSelectedRtcpMuxPolicy(blink::RtcpMuxPolicy) override; bool addICECandidate(const blink::WebRTCICECandidate& ice_candidate) override; bool addICECandidate(const blink::WebRTCVoidRequest& request, const blink::WebRTCICECandidate& ice_candidate) override;
diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index bb77021..e30970b9 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc
@@ -157,11 +157,6 @@ } void ResourceLoader::StartRequest() { - if (delegate_->HandleExternalProtocol(this, request_->url())) { - CancelAndIgnore(); - return; - } - // Give the handler a chance to delay the URLRequest from being started. bool defer_start = false; if (!handler_->OnWillStart(request_->url(), &defer_start)) { @@ -273,12 +268,6 @@ } } - if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) { - // The request is complete so we can remove it. - CancelAndIgnore(); - return; - } - scoped_refptr<ResourceResponse> response = new ResourceResponse(); PopulateResourceResponse(info, request_.get(), response.get()); delegate_->DidReceiveRedirect(this, redirect_info.new_url, response.get()); @@ -286,6 +275,12 @@ Cancel(); } else if (*defer) { deferred_stage_ = DEFERRED_REDIRECT; // Follow redirect when resumed. + DCHECK(deferred_redirect_url_.is_empty()); + deferred_redirect_url_ = redirect_info.new_url; + } else if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) { + // The request is complete so we can remove it. + CancelAndIgnore(); + return; } } @@ -450,7 +445,7 @@ StartRequestInternal(); break; case DEFERRED_REDIRECT: - request_->FollowDeferredRedirect(); + FollowDeferredRedirectInternal(); break; case DEFERRED_READ: base::ThreadTaskRunnerHandle::Get()->PostTask( @@ -478,10 +473,17 @@ void ResourceLoader::StartRequestInternal() { DCHECK(!request_->is_pending()); + // Note: at this point any possible deferred start actions are already over. + if (!request_->status().is_success()) { return; } + if (delegate_->HandleExternalProtocol(this, request_->url())) { + CancelAndIgnore(); + return; + } + started_request_ = true; request_->Start(); @@ -534,6 +536,17 @@ } } +void ResourceLoader::FollowDeferredRedirectInternal() { + DCHECK(!deferred_redirect_url_.is_empty()); + GURL redirect_url = deferred_redirect_url_; + deferred_redirect_url_ = GURL(); + if (delegate_->HandleExternalProtocol(this, deferred_redirect_url_)) { + CancelAndIgnore(); + } else { + request_->FollowDeferredRedirect(); + } +} + void ResourceLoader::CompleteResponseStarted() { ResourceRequestInfoImpl* info = GetRequestInfo(); scoped_refptr<ResourceResponse> response = new ResourceResponse();
diff --git a/content/browser/loader/resource_loader.h b/content/browser/loader/resource_loader.h index 43b7530..40603a4 100644 --- a/content/browser/loader/resource_loader.h +++ b/content/browser/loader/resource_loader.h
@@ -16,6 +16,7 @@ #include "content/browser/ssl/ssl_error_handler.h" #include "content/common/content_export.h" #include "net/url_request/url_request.h" +#include "url/gurl.h" namespace net { class X509Certificate; @@ -83,6 +84,7 @@ void StartRequestInternal(); void CancelRequestInternal(int error, bool from_renderer); + void FollowDeferredRedirectInternal(); void CompleteResponseStarted(); void ReadMore(bool is_continuation); void ResumeReading(); @@ -139,6 +141,9 @@ bool started_request_; int times_cancelled_after_request_start_; + // Stores the URL from a deferred redirect. + GURL deferred_redirect_url_; + base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ResourceLoader);
diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc index 6515453..cda1a544 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc
@@ -7,8 +7,10 @@ #include <stddef.h> #include <stdint.h> +#include <deque> #include <memory> #include <utility> +#include <vector> #include "base/files/file.h" #include "base/files/file_util.h" @@ -501,7 +503,18 @@ bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override { EXPECT_EQ(loader, loader_.get()); - return false; + ++handle_external_protocol_; + + // Check that calls to HandleExternalProtocol always happen after the calls + // to the ResourceHandler's OnWillStart and OnRequestRedirected. + EXPECT_EQ(handle_external_protocol_, + raw_ptr_resource_handler_->on_will_start_called() + + raw_ptr_resource_handler_->on_request_redirected_called()); + + bool return_value = handle_external_protocol_results_.front(); + if (handle_external_protocol_results_.size() > 1) + handle_external_protocol_results_.pop_front(); + return return_value; } void DidStartRequest(ResourceLoader* loader) override { EXPECT_EQ(loader, loader_.get()); @@ -548,6 +561,12 @@ int did_received_redirect_ = 0; int did_receive_response_ = 0; int did_finish_loading_ = 0; + int handle_external_protocol_ = 0; + + // Allows controlling the return values of sequential calls to + // HandleExternalProtocol. Values are removed by the measure they are used + // but the last one which is used for all following calls. + std::deque<bool> handle_external_protocol_results_{false}; net::URLRequestJobFactoryImpl job_factory_; TestNetworkQualityEstimator network_quality_estimator_; @@ -749,6 +768,7 @@ EXPECT_EQ(1, did_received_redirect_); EXPECT_EQ(1, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(2, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); EXPECT_EQ(net::OK, raw_ptr_resource_handler_->final_status().error()); @@ -765,12 +785,53 @@ EXPECT_EQ(0, did_received_redirect_); EXPECT_EQ(1, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); EXPECT_EQ(net::OK, raw_ptr_resource_handler_->final_status().error()); EXPECT_EQ(test_data(), raw_ptr_resource_handler_->body()); } +// Test the case where ResourceHandler defers nothing and the request is handled +// as an external protocol on start. +TEST_F(ResourceLoaderTest, SyncExternalProtocolHandlingOnStart) { + handle_external_protocol_results_ = {true}; + + loader_->StartRequest(); + raw_ptr_resource_handler_->WaitUntilResponseComplete(); + EXPECT_EQ(0, did_start_request_); + EXPECT_EQ(0, did_received_redirect_); + EXPECT_EQ(0, did_receive_response_); + EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); + EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(net::ERR_ABORTED, + raw_ptr_resource_handler_->final_status().error()); + EXPECT_TRUE(raw_ptr_resource_handler_->body().empty()); +} + +// Test the case where ResourceHandler defers nothing and the request is handled +// as an external protocol on redirect. +TEST_F(ResourceLoaderTest, SyncExternalProtocolHandlingOnRedirect) { + handle_external_protocol_results_ = {false, true}; + + loader_->StartRequest(); + raw_ptr_resource_handler_->WaitUntilResponseComplete(); + EXPECT_EQ(1, did_start_request_); + EXPECT_EQ(1, did_received_redirect_); + EXPECT_EQ(0, did_receive_response_); + EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(2, handle_external_protocol_); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(net::ERR_ABORTED, + raw_ptr_resource_handler_->final_status().error()); + EXPECT_TRUE(raw_ptr_resource_handler_->body().empty()); +} + // Test the case the ResourceHandler defers everything. TEST_F(ResourceLoaderTest, AsyncResourceHandler) { raw_ptr_resource_handler_->set_defer_on_will_start(true); @@ -791,11 +852,13 @@ EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(0, handle_external_protocol_); // Resume and run until OnRequestRedirected. raw_ptr_resource_handler_->Resume(); raw_ptr_resource_handler_->WaitUntilDeferred(); EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); + EXPECT_EQ(1, handle_external_protocol_); // Spinning the message loop should not advance the state further. base::RunLoop().RunUntilIdle(); @@ -804,11 +867,13 @@ EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_will_read_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(1, handle_external_protocol_); // Resume and run until OnResponseStarted. raw_ptr_resource_handler_->Resume(); raw_ptr_resource_handler_->WaitUntilDeferred(); EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_started_called()); + EXPECT_EQ(2, handle_external_protocol_); // Spinning the message loop should not advance the state further. base::RunLoop().RunUntilIdle(); @@ -830,7 +895,7 @@ EXPECT_EQ(0, raw_ptr_resource_handler_->on_read_eof()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); - // Resume and run until the final 0-byte read, signalling EOF. + // Resume and run until the final 0-byte read, signaling EOF. raw_ptr_resource_handler_->Resume(); raw_ptr_resource_handler_->WaitUntilDeferred(); EXPECT_EQ(1, raw_ptr_resource_handler_->on_read_eof()); @@ -860,6 +925,7 @@ EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); EXPECT_EQ(net::OK, raw_ptr_resource_handler_->final_status().error()); EXPECT_EQ(test_data(), raw_ptr_resource_handler_->body()); + EXPECT_EQ(2, handle_external_protocol_); } // Same as above, except reads complete asynchronously and there's no redirect. @@ -883,11 +949,13 @@ EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(0, handle_external_protocol_); // Resume and run until OnResponseStarted. raw_ptr_resource_handler_->Resume(); raw_ptr_resource_handler_->WaitUntilDeferred(); EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_started_called()); + EXPECT_EQ(1, handle_external_protocol_); // Spinning the message loop should not advance the state further. base::RunLoop().RunUntilIdle(); @@ -939,6 +1007,7 @@ EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); EXPECT_EQ(net::OK, raw_ptr_resource_handler_->final_status().error()); EXPECT_EQ(test_data(), raw_ptr_resource_handler_->body()); + EXPECT_EQ(1, handle_external_protocol_); } TEST_F(ResourceLoaderTest, SyncCancelOnWillStart) { @@ -949,6 +1018,7 @@ base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, did_start_request_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(0, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); @@ -968,6 +1038,7 @@ EXPECT_EQ(1, did_received_redirect_); EXPECT_EQ(0, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_will_read_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_read_completed_called()); @@ -1090,6 +1161,7 @@ base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, did_start_request_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(0, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); @@ -1109,6 +1181,7 @@ EXPECT_EQ(1, did_received_redirect_); EXPECT_EQ(0, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_will_read_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_read_completed_called()); @@ -1204,6 +1277,67 @@ EXPECT_EQ(test_data(), raw_ptr_resource_handler_->body()); } +// Tests the request being deferred and then being handled as an external +// protocol, both on start. +TEST_F(ResourceLoaderTest, AsyncExternalProtocolHandlingOnStart) { + handle_external_protocol_results_ = {true}; + raw_ptr_resource_handler_->set_defer_on_will_start(true); + + loader_->StartRequest(); + raw_ptr_resource_handler_->WaitUntilDeferred(); + EXPECT_EQ(0, did_finish_loading_); + EXPECT_EQ(0, handle_external_protocol_); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); + EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + + raw_ptr_resource_handler_->Resume(); + raw_ptr_resource_handler_->WaitUntilResponseComplete(); + EXPECT_EQ(0, did_start_request_); + EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); + EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); + EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); + + EXPECT_EQ(net::ERR_ABORTED, + raw_ptr_resource_handler_->final_status().error()); + EXPECT_EQ("", raw_ptr_resource_handler_->body()); +} + +// Tests the request being deferred and then being handled as an external +// protocol, both on redirect. +TEST_F(ResourceLoaderTest, AsyncExternalProtocolHandlingOnRedirect) { + handle_external_protocol_results_ = {false, true}; + raw_ptr_resource_handler_->set_defer_on_request_redirected(true); + + loader_->StartRequest(); + raw_ptr_resource_handler_->WaitUntilDeferred(); + EXPECT_EQ(1, did_start_request_); + EXPECT_EQ(1, did_received_redirect_); + EXPECT_EQ(0, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); + EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + + raw_ptr_resource_handler_->Resume(); + raw_ptr_resource_handler_->WaitUntilResponseComplete(); + EXPECT_EQ(1, did_start_request_); + EXPECT_EQ(1, did_received_redirect_); + EXPECT_EQ(0, did_receive_response_); + EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(2, handle_external_protocol_); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_request_redirected_called()); + EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); + EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_completed_called()); + + EXPECT_EQ(net::ERR_ABORTED, + raw_ptr_resource_handler_->final_status().error()); + EXPECT_EQ("", raw_ptr_resource_handler_->body()); +} + TEST_F(ResourceLoaderTest, RequestFailsOnStart) { SetUpResourceLoaderForUrl( net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( @@ -1215,6 +1349,7 @@ EXPECT_EQ(0, did_received_redirect_); EXPECT_EQ(0, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); @@ -1274,6 +1409,7 @@ EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(1, handle_external_protocol_); raw_ptr_resource_handler_->CancelWithError(net::ERR_FAILED); raw_ptr_resource_handler_->WaitUntilResponseComplete(); @@ -1281,6 +1417,7 @@ EXPECT_EQ(0, did_received_redirect_); EXPECT_EQ(0, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_started_called()); @@ -1301,12 +1438,14 @@ EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_started_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_read_completed_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_response_completed_called()); + EXPECT_EQ(1, handle_external_protocol_); raw_ptr_resource_handler_->CancelWithError(net::ERR_FAILED); raw_ptr_resource_handler_->WaitUntilResponseComplete(); EXPECT_EQ(0, did_received_redirect_); EXPECT_EQ(1, did_receive_response_); EXPECT_EQ(1, did_finish_loading_); + EXPECT_EQ(1, handle_external_protocol_); EXPECT_EQ(1, raw_ptr_resource_handler_->on_will_start_called()); EXPECT_EQ(0, raw_ptr_resource_handler_->on_request_redirected_called()); EXPECT_EQ(1, raw_ptr_resource_handler_->on_response_started_called());
diff --git a/content/browser/payments/payment_app_content_unittest_base.cc b/content/browser/payments/payment_app_content_unittest_base.cc index 32b8faa..f5b70ce 100644 --- a/content/browser/payments/payment_app_content_unittest_base.cc +++ b/content/browser/payments/payment_app_content_unittest_base.cc
@@ -33,6 +33,12 @@ *called = true; } +void UnregisterServiceWorkerCallback(bool* called, + ServiceWorkerStatusCode status) { + EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); + *called = true; +} + } // namespace PaymentAppContentUnitTestBase::PaymentAppContentUnitTestBase() @@ -88,8 +94,11 @@ // Find a last registered payment app manager. for (const auto& candidate_manager : payment_app_context_->payment_app_managers_) { - if (!base::ContainsKey(existing_managers, candidate_manager.first)) + if (!base::ContainsKey(existing_managers, candidate_manager.first)) { + candidate_manager.first->Init(scope_url.spec()); + base::RunLoop().RunUntilIdle(); return candidate_manager.first; + } } NOTREACHED(); @@ -98,20 +107,18 @@ void PaymentAppContentUnitTestBase::SetManifest( PaymentAppManager* manager, - const std::string& scope, payments::mojom::PaymentAppManifestPtr manifest, const PaymentAppManager::SetManifestCallback& callback) { ASSERT_NE(nullptr, manager); - manager->SetManifest(scope, std::move(manifest), callback); + manager->SetManifest(std::move(manifest), callback); base::RunLoop().RunUntilIdle(); } void PaymentAppContentUnitTestBase::GetManifest( PaymentAppManager* manager, - const std::string& scope, const PaymentAppManager::GetManifestCallback& callback) { ASSERT_NE(nullptr, manager); - manager->GetManifest(scope, callback); + manager->GetManifest(callback); base::RunLoop().RunUntilIdle(); } @@ -134,4 +141,14 @@ return manifest; } +void PaymentAppContentUnitTestBase::UnregisterServiceWorker( + const GURL& scope_url) { + // Unregister service worker. + bool called = false; + embedded_worker_helper_->context()->UnregisterServiceWorker( + scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); + base::RunLoop().RunUntilIdle(); + EXPECT_TRUE(called); +} + } // namespace content
diff --git a/content/browser/payments/payment_app_content_unittest_base.h b/content/browser/payments/payment_app_content_unittest_base.h index 39c99a2..3e4413a2 100644 --- a/content/browser/payments/payment_app_content_unittest_base.h +++ b/content/browser/payments/payment_app_content_unittest_base.h
@@ -34,14 +34,13 @@ PaymentAppManager* CreatePaymentAppManager(const GURL& scope_url, const GURL& sw_script_url); void SetManifest(PaymentAppManager* manager, - const std::string& scope, payments::mojom::PaymentAppManifestPtr manifest, const PaymentAppManager::SetManifestCallback& callback); void GetManifest(PaymentAppManager* manager, - const std::string& scope, const PaymentAppManager::GetManifestCallback& callback); payments::mojom::PaymentAppManifestPtr CreatePaymentAppManifestForTest( const std::string& name); + void UnregisterServiceWorker(const GURL& scope_url); private: std::unique_ptr<TestBrowserThreadBundle> thread_bundle_;
diff --git a/content/browser/payments/payment_app_context_impl_unittest.cc b/content/browser/payments/payment_app_context_impl_unittest.cc index 99bde5c..0a76508 100644 --- a/content/browser/payments/payment_app_context_impl_unittest.cc +++ b/content/browser/payments/payment_app_context_impl_unittest.cc
@@ -57,8 +57,7 @@ PaymentAppManifestError error = PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; bool called = false; - SetManifest(manager, scope_url.spec(), - CreatePaymentAppManifestForTest(scope_url.spec()), + SetManifest(manager, CreatePaymentAppManifestForTest(scope_url.spec()), base::Bind(&SetManifestCallback, &called, &error)); ASSERT_TRUE(called);
diff --git a/content/browser/payments/payment_app_manager.cc b/content/browser/payments/payment_app_manager.cc index 52b3c7d..9735028 100644 --- a/content/browser/payments/payment_app_manager.cc +++ b/content/browser/payments/payment_app_manager.cc
@@ -35,8 +35,12 @@ base::Unretained(this))); } +void PaymentAppManager::Init(const std::string& scope) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + scope_ = GURL(scope); +} + void PaymentAppManager::SetManifest( - const std::string& scope, payments::mojom::PaymentAppManifestPtr manifest, const SetManifestCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -45,15 +49,13 @@ // the payment app to be registered. Please see http://crbug.com/665949. payment_app_context_->payment_app_database()->WriteManifest( - GURL(scope), std::move(manifest), callback); + scope_, std::move(manifest), callback); } -void PaymentAppManager::GetManifest(const std::string& scope, - const GetManifestCallback& callback) { +void PaymentAppManager::GetManifest(const GetManifestCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - payment_app_context_->payment_app_database()->ReadManifest(GURL(scope), - callback); + payment_app_context_->payment_app_database()->ReadManifest(scope_, callback); } void PaymentAppManager::OnConnectionError() {
diff --git a/content/browser/payments/payment_app_manager.h b/content/browser/payments/payment_app_manager.h index bff1918..d5149b59 100644 --- a/content/browser/payments/payment_app_manager.h +++ b/content/browser/payments/payment_app_manager.h
@@ -12,6 +12,7 @@ #include "components/payments/payment_app.mojom.h" #include "content/common/content_export.h" #include "mojo/public/cpp/bindings/binding.h" +#include "url/gurl.h" namespace content { @@ -30,11 +31,10 @@ friend class PaymentAppContentUnitTestBase; // payments::mojom::PaymentAppManager methods: - void SetManifest(const std::string& scope, - payments::mojom::PaymentAppManifestPtr manifest, + void Init(const std::string& scope) override; + void SetManifest(payments::mojom::PaymentAppManifestPtr manifest, const SetManifestCallback& callback) override; - void GetManifest(const std::string& scope, - const GetManifestCallback& callback) override; + void GetManifest(const GetManifestCallback& callback) override; // Called when an error is detected on binding_. void OnConnectionError(); @@ -42,10 +42,9 @@ // PaymentAppContextImpl owns PaymentAppManager PaymentAppContextImpl* payment_app_context_; + GURL scope_; mojo::Binding<payments::mojom::PaymentAppManager> binding_; - base::WeakPtrFactory<PaymentAppManager> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(PaymentAppManager); };
diff --git a/content/browser/payments/payment_app_manager_unittest.cc b/content/browser/payments/payment_app_manager_unittest.cc index 6597f37..3880f48 100644 --- a/content/browser/payments/payment_app_manager_unittest.cc +++ b/content/browser/payments/payment_app_manager_unittest.cc
@@ -18,8 +18,6 @@ const char kServiceWorkerPattern[] = "https://example.com/a"; const char kServiceWorkerScript[] = "https://example.com/a/script.js"; -const char kUnregisteredServiceWorkerPattern[] = - "https://example.com/unregistered"; void SetManifestCallback(bool* called, PaymentAppManifestError* out_error, @@ -61,7 +59,7 @@ bool called = false; PaymentAppManifestError error = PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; - SetManifest(payment_app_manager(), kServiceWorkerPattern, + SetManifest(payment_app_manager(), CreatePaymentAppManifestForTest(kServiceWorkerPattern), base::Bind(&SetManifestCallback, &called, &error)); ASSERT_TRUE(called); @@ -72,9 +70,8 @@ PaymentAppManifestPtr read_manifest; PaymentAppManifestError read_error = PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; - GetManifest( - payment_app_manager(), kServiceWorkerPattern, - base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); + GetManifest(payment_app_manager(), base::Bind(&GetManifestCallback, &called, + &read_manifest, &read_error)); ASSERT_TRUE(called); ASSERT_EQ(payments::mojom::PaymentAppManifestError::NONE, read_error); @@ -91,7 +88,8 @@ TEST_F(PaymentAppManagerTest, SetManifestWithoutAssociatedServiceWorker) { bool called = false; PaymentAppManifestError error = PaymentAppManifestError::NONE; - SetManifest(payment_app_manager(), kUnregisteredServiceWorkerPattern, + UnregisterServiceWorker(GURL(kServiceWorkerPattern)); + SetManifest(payment_app_manager(), CreatePaymentAppManifestForTest(kServiceWorkerPattern), base::Bind(&SetManifestCallback, &called, &error)); ASSERT_TRUE(called); @@ -103,9 +101,9 @@ bool called = false; PaymentAppManifestPtr read_manifest; PaymentAppManifestError read_error = PaymentAppManifestError::NONE; - GetManifest( - payment_app_manager(), kUnregisteredServiceWorkerPattern, - base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); + UnregisterServiceWorker(GURL(kServiceWorkerPattern)); + GetManifest(payment_app_manager(), base::Bind(&GetManifestCallback, &called, + &read_manifest, &read_error)); ASSERT_TRUE(called); EXPECT_EQ(PaymentAppManifestError::NO_ACTIVE_WORKER, read_error); @@ -115,9 +113,8 @@ bool called = false; PaymentAppManifestPtr read_manifest; PaymentAppManifestError read_error = PaymentAppManifestError::NONE; - GetManifest( - payment_app_manager(), kServiceWorkerPattern, - base::Bind(&GetManifestCallback, &called, &read_manifest, &read_error)); + GetManifest(payment_app_manager(), base::Bind(&GetManifestCallback, &called, + &read_manifest, &read_error)); ASSERT_TRUE(called); EXPECT_EQ(PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED,
diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc index 3485bdf1..bf7b89e 100644 --- a/content/renderer/media/rtc_peer_connection_handler.cc +++ b/content/renderer/media/rtc_peer_connection_handler.cc
@@ -1395,12 +1395,6 @@ return native_peer_connection_->SetConfiguration(configuration_); } -void RTCPeerConnectionHandler::logSelectedRtcpMuxPolicy( - blink::RtcpMuxPolicy selectedRtcpMuxPolicy) { - UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SelectedRtcpMuxPolicy", - selectedRtcpMuxPolicy, blink::RtcpMuxPolicyMax); -} - bool RTCPeerConnectionHandler::addICECandidate( const blink::WebRTCVoidRequest& request, const blink::WebRTCICECandidate& candidate) {
diff --git a/content/renderer/media/rtc_peer_connection_handler.h b/content/renderer/media/rtc_peer_connection_handler.h index a8832ce0..cc179dc 100644 --- a/content/renderer/media/rtc_peer_connection_handler.h +++ b/content/renderer/media/rtc_peer_connection_handler.h
@@ -134,8 +134,6 @@ bool setConfiguration( const blink::WebRTCConfiguration& configuration) override; - void logSelectedRtcpMuxPolicy( - blink::RtcpMuxPolicy selectedRtcpMuxPolicy) override; bool addICECandidate(const blink::WebRTCICECandidate& candidate) override; bool addICECandidate(const blink::WebRTCVoidRequest& request, const blink::WebRTCICECandidate& candidate) override;
diff --git a/content/test/gpu/generate_buildbot_json.py b/content/test/gpu/generate_buildbot_json.py index 6b814a0..1e022fe8 100755 --- a/content/test/gpu/generate_buildbot_json.py +++ b/content/test/gpu/generate_buildbot_json.py
@@ -1093,6 +1093,10 @@ 'os_types': ['win'] }, ], + 'args': [ + '--test_video_data=' + '../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1' + ], }, }
diff --git a/device/usb/usb_device_handle_usbfs.cc b/device/usb/usb_device_handle_usbfs.cc index cddb2f6..79166660 100644 --- a/device/usb/usb_device_handle_usbfs.cc +++ b/device/usb/usb_device_handle_usbfs.cc
@@ -236,9 +236,6 @@ scoped_refptr<net::IOBuffer> control_transfer_buffer; scoped_refptr<net::IOBuffer> buffer; - TransferCallback callback; - IsochronousTransferCallback isoc_callback; - scoped_refptr<base::SingleThreadTaskRunner> callback_runner; base::CancelableClosure timeout_closure; bool cancelled = false; @@ -248,13 +245,18 @@ bool discarded = false; bool reaped = false; + private: + TransferCallback callback; + IsochronousTransferCallback isoc_callback; + scoped_refptr<base::SingleThreadTaskRunner> callback_runner; + + DISALLOW_COPY_AND_ASSIGN(Transfer); + + public: // The |urb| field must be the last in the struct so that the extra space // allocated by the overridden new function above extends the length of its // |iso_frame_desc| field. usbdevfs_urb urb; - - private: - DISALLOW_COPY_AND_ASSIGN(Transfer); }; UsbDeviceHandleUsbfs::Transfer::Transfer( @@ -292,20 +294,22 @@ void UsbDeviceHandleUsbfs::Transfer::RunCallback(UsbTransferStatus status, size_t bytes_transferred) { DCHECK_NE(urb.type, USBDEVFS_URB_TYPE_ISO); - DCHECK(!callback.is_null()); + DCHECK(callback); if (!callback_runner || callback_runner->BelongsToCurrentThread()) { callback.Run(status, buffer, bytes_transferred); } else { callback_runner->PostTask( FROM_HERE, base::Bind(callback, status, buffer, bytes_transferred)); } + callback.Reset(); } void UsbDeviceHandleUsbfs::Transfer::RunIsochronousCallback( const std::vector<IsochronousPacket>& packets) { DCHECK_EQ(urb.type, USBDEVFS_URB_TYPE_ISO); - DCHECK(!isoc_callback.is_null()); + DCHECK(isoc_callback); isoc_callback.Run(buffer, packets); + isoc_callback.Reset(); } UsbDeviceHandleUsbfs::UsbDeviceHandleUsbfs( @@ -339,10 +343,12 @@ // On the |task_runner_| thread check |device_| to see if the handle is // closed. On the |blocking_task_runner_| thread check |fd_.is_valid()| to // see if the handle is closed. - for (const auto& transfer : transfers_) - CancelTransfer(transfer.get(), USB_TRANSFER_CANCELLED); device_->HandleClosed(this); device_ = nullptr; + + for (const auto& transfer : transfers_) + CancelTransfer(transfer.get(), USB_TRANSFER_CANCELLED); + blocking_task_runner_->PostTask( FROM_HERE, base::Bind(&UsbDeviceHandleUsbfs::CloseBlocking, this)); } @@ -848,6 +854,9 @@ void UsbDeviceHandleUsbfs::CancelTransfer(Transfer* transfer, UsbTransferStatus status) { + if (transfer->cancelled) + return; + // |transfer| must stay in |transfers_| as it is still being processed by the // kernel and will be reaped later. transfer->cancelled = true;
diff --git a/ios/build/bots/chromium.fyi/EarlGreyiOS.json b/ios/build/bots/chromium.fyi/EarlGreyiOS.json index 42040ea..1f625fe 100644 --- a/ios/build/bots/chromium.fyi/EarlGreyiOS.json +++ b/ios/build/bots/chromium.fyi/EarlGreyiOS.json
@@ -51,6 +51,12 @@ "xctest": true }, { + "app": "ios_showcase_egtests", + "device type": "iPhone 6s", + "os": "10.0", + "xctest": true + }, + { "app": "ios_web_shell_egtests", "device type": "iPhone 6s", "os": "10.0", @@ -87,6 +93,12 @@ "xctest": true }, { + "app": "ios_showcase_egtests", + "device type": "iPad Air 2", + "os": "10.0", + "xctest": true + }, + { "app": "ios_web_shell_egtests", "device type": "iPad Air 2", "os": "10.0",
diff --git a/ios/chrome/browser/ui/alert_coordinator/OWNERS b/ios/chrome/browser/ui/alert_coordinator/OWNERS index 936c0336..0f2892e 100644 --- a/ios/chrome/browser/ui/alert_coordinator/OWNERS +++ b/ios/chrome/browser/ui/alert_coordinator/OWNERS
@@ -1 +1,2 @@ -jyquinn@chromium.org +gambard@chromium.org +michaeldo@chromium.org
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm index 11c998d..b56a670e 100644 --- a/ios/chrome/browser/ui/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -1571,12 +1571,15 @@ _isOffTheRecord, NULL, ^{ [newPage removeFromSuperview]; _inNewTabAnimation = NO; - // Only show |tab|'s view if it is the current tab in its TabModel. - // It is possible that the current Tab can be reset to a new value - // before the new Tab animation finished (e.g. if another Tab shows - // a dialog via |dialogPresenter|). - if ([_model currentTab] == tab) - [self tabSelected:tab]; + // Use the model's currentTab here because it is possible that it can + // be reset to a new value before the new Tab animation finished (e.g. + // if another Tab shows a dialog via |dialogPresenter|). However, that + // tab's view hasn't been displayed yet because it was in a new tab + // animation. + Tab* currentTab = [_model currentTab]; + if (currentTab) { + [self tabSelected:currentTab]; + } startVoiceSearchIfNecessaryBlock(); }); } else {
diff --git a/ios/chrome/browser/ui/context_menu/OWNERS b/ios/chrome/browser/ui/context_menu/OWNERS index 936c0336..49ba79e 100644 --- a/ios/chrome/browser/ui/context_menu/OWNERS +++ b/ios/chrome/browser/ui/context_menu/OWNERS
@@ -1 +1 @@ -jyquinn@chromium.org +michaeldo@chromium.org
diff --git a/ios/chrome/browser/ui/elements/OWNERS b/ios/chrome/browser/ui/elements/OWNERS index 936c0336..f49ed38 100644 --- a/ios/chrome/browser/ui/elements/OWNERS +++ b/ios/chrome/browser/ui/elements/OWNERS
@@ -1 +1 @@ -jyquinn@chromium.org +marq@chromium.org
diff --git a/ios/chrome/browser/ui/history/OWNERS b/ios/chrome/browser/ui/history/OWNERS index 936c0336..1085212 100644 --- a/ios/chrome/browser/ui/history/OWNERS +++ b/ios/chrome/browser/ui/history/OWNERS
@@ -1 +1,2 @@ -jyquinn@chromium.org +lpromero@chromium.org +sczs@chromium.org
diff --git a/ios/chrome/browser/ui/history/history_collection_view_controller.mm b/ios/chrome/browser/ui/history/history_collection_view_controller.mm index c2c01036..efa969a 100644 --- a/ios/chrome/browser/ui/history/history_collection_view_controller.mm +++ b/ios/chrome/browser/ui/history/history_collection_view_controller.mm
@@ -21,6 +21,8 @@ #include "ios/chrome/browser/chrome_url_constants.h" #import "ios/chrome/browser/signin/authentication_service.h" #include "ios/chrome/browser/signin/authentication_service_factory.h" +#include "ios/chrome/browser/sync/sync_setup_service.h" +#include "ios/chrome/browser/sync/sync_setup_service_factory.h" #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h" #import "ios/chrome/browser/ui/collection_view/cells/activity_indicator_cell.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" @@ -45,6 +47,11 @@ #include "ui/base/l10n/l10n_util_mac.h" namespace { +typedef NS_ENUM(NSInteger, ItemType) { + ItemTypeHistoryEntry = kItemTypeEnumZero, + ItemTypeEntriesStatus, + ItemTypeActivityIndicator, +}; // Section identifier for the header (sync information) section. const NSInteger kEntriesStatusSectionIdentifier = kSectionIdentifierEnumZero; // Maximum number of entries to retrieve in a single query to history service. @@ -107,6 +114,9 @@ - (void)removeSelectedItemsFromCollection; // Removes all items in the collection that are not included in entries. - (void)filterForHistoryEntries:(NSArray*)entries; +// Adds loading indicator to the top of the history collection, if one is not +// already present. +- (void)addLoadingIndicator; // Displays context menu on cell pressed with gestureRecognizer. - (void)displayContextMenuInvokedByGestureRecognizer: (UILongPressGestureRecognizer*)gestureRecognizer; @@ -315,15 +325,15 @@ - (void)historyServiceFacade:(HistoryServiceFacade*)facade didReceiveQueryResult:(HistoryServiceFacade::QueryResult)result { self.loading = NO; - // Remove loading indicator. - CollectionViewItem* headerItem = [self.collectionViewModel - itemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]; - if ([headerItem.cellClass isSubclassOfClass:[ActivityIndicatorCell class]]) { - [self.collectionViewModel removeItemWithType:kItemTypeEnumZero - fromSectionWithIdentifier:kSectionIdentifierEnumZero]; - [self.collectionView - deleteItemsAtIndexPaths:@[ [NSIndexPath indexPathForItem:0 - inSection:0] ]]; + // If history sync is enabled and there hasn't been a response from synced + // history, try fetching again. + SyncSetupService* syncSetupService = + SyncSetupServiceFactory::GetForBrowserState(_browserState); + if (syncSetupService->IsSyncEnabled() && + syncSetupService->IsDataTypeEnabled(syncer::HISTORY_DELETE_DIRECTIVES) && + !result.sync_returned) { + [self showHistoryMatchingQuery:_currentQuery]; + return; } // If there are no results and no URLs have been loaded, report that no @@ -354,7 +364,7 @@ DCHECK([[self collectionViewModel] numberOfSections]); for (const history::HistoryEntry& entry : entries) { HistoryEntryItem* item = - [[[HistoryEntryItem alloc] initWithType:kItemTypeEnumZero + [[[HistoryEntryItem alloc] initWithType:ItemTypeHistoryEntry historyEntry:entry browserState:_browserState delegate:self] autorelease]; @@ -526,24 +536,9 @@ - (void)fetchHistoryForQuery:(NSString*)query priorToTime:(const base::Time&)time { self.loading = YES; - // Add loading indicator if nothing else is shown. + // Add loading indicator if no items are shown. if (!self.hasHistoryEntries && !self.isSearching) { - [self.collectionView performBatchUpdates:^{ - NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; - if ([self.collectionViewModel hasItemAtIndexPath:indexPath]) { - [self.collectionViewModel - removeItemWithType:kItemTypeEnumZero - fromSectionWithIdentifier:kSectionIdentifierEnumZero]; - [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; - } - CollectionViewItem* loadingIndicatorItem = [[[CollectionViewItem alloc] - initWithType:kItemTypeEnumZero] autorelease]; - loadingIndicatorItem.cellClass = [ActivityIndicatorCell class]; - [self.collectionViewModel addItem:loadingIndicatorItem - toSectionWithIdentifier:kEntriesStatusSectionIdentifier]; - [self.collectionView insertItemsAtIndexPaths:@[ indexPath ]]; - } - completion:nil]; + [self addLoadingIndicator]; } BOOL fetchAllHistory = !query || [query isEqualToString:@""]; @@ -557,7 +552,6 @@ options.max_count = kMaxFetchCount; options.matching_algorithm = query_parser::MatchingAlgorithm::ALWAYS_PREFIX_SEARCH; - _historyServiceFacade->QueryOtherFormsOfBrowsingHistory(); _historyServiceFacade->QueryHistory(queryString, options); // Also determine whether notice regarding other forms of browsing history // should be shown. @@ -568,14 +562,14 @@ CollectionViewItem* entriesStatusItem = nil; if (!self.hasHistoryEntries) { CollectionViewTextItem* noResultsItem = [[[CollectionViewTextItem alloc] - initWithType:kItemTypeEnumZero] autorelease]; + initWithType:ItemTypeEntriesStatus] autorelease]; noResultsItem.text = self.isSearching ? l10n_util::GetNSString(IDS_HISTORY_NO_SEARCH_RESULTS) : l10n_util::GetNSString(IDS_HISTORY_NO_RESULTS); entriesStatusItem = noResultsItem; } else { HistoryEntriesStatusItem* historyEntriesStatusItem = - [[[HistoryEntriesStatusItem alloc] initWithType:kItemTypeEnumZero] + [[[HistoryEntriesStatusItem alloc] initWithType:ItemTypeEntriesStatus] autorelease]; historyEntriesStatusItem.delegate = self; AuthenticationService* authService = @@ -604,7 +598,8 @@ NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; if ([items count]) { [self.collectionViewModel - removeItemWithType:kItemTypeEnumZero + removeItemWithType:[self.collectionViewModel + itemTypeForIndexPath:indexPath] fromSectionWithIdentifier:kEntriesStatusSectionIdentifier]; [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; } @@ -667,6 +662,33 @@ [self removeSelectedItemsFromCollection]; } +- (void)addLoadingIndicator { + NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; + if ([self.collectionViewModel hasItemAtIndexPath:indexPath] && + [self.collectionViewModel itemTypeForIndexPath:indexPath] == + ItemTypeActivityIndicator) { + // Do not add indicator a second time. + return; + } + + [self.collectionView performBatchUpdates:^{ + if ([self.collectionViewModel hasItemAtIndexPath:indexPath]) { + [self.collectionViewModel + removeItemWithType:[self.collectionViewModel + itemTypeForIndexPath:indexPath] + fromSectionWithIdentifier:kSectionIdentifierEnumZero]; + [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; + } + CollectionViewItem* loadingIndicatorItem = [[[CollectionViewItem alloc] + initWithType:ItemTypeActivityIndicator] autorelease]; + loadingIndicatorItem.cellClass = [ActivityIndicatorCell class]; + [self.collectionViewModel addItem:loadingIndicatorItem + toSectionWithIdentifier:kEntriesStatusSectionIdentifier]; + [self.collectionView insertItemsAtIndexPaths:@[ indexPath ]]; + } + completion:nil]; +} + #pragma mark Context Menu - (void)displayContextMenuInvokedByGestureRecognizer:
diff --git a/ios/chrome/browser/ui/history/history_service_facade.h b/ios/chrome/browser/ui/history/history_service_facade.h index bb37186..a6580941 100644 --- a/ios/chrome/browser/ui/history/history_service_facade.h +++ b/ios/chrome/browser/ui/history/history_service_facade.h
@@ -46,8 +46,13 @@ base::string16 query; base::string16 query_start_time; base::string16 query_end_time; + // true if all local history from History service has been retrieved. bool finished; + // true if a query to WebHistoryService has returned successfully. + bool sync_returned; + // true if results from WebHistoryService have been retrieved. bool has_synced_results; + // true if all remote history from WebHistoryService has been retrieved. bool sync_finished; std::vector<history::HistoryEntry> entries; };
diff --git a/ios/chrome/browser/ui/history/history_service_facade.mm b/ios/chrome/browser/ui/history/history_service_facade.mm index 7f685822..caea37d 100644 --- a/ios/chrome/browser/ui/history/history_service_facade.mm +++ b/ios/chrome/browser/ui/history/history_service_facade.mm
@@ -78,6 +78,7 @@ query_start_time(base::string16()), query_end_time(base::string16()), finished(false), + sync_returned(false), has_synced_results(false), sync_finished(false), entries(std::vector<history::HistoryEntry>()) {} @@ -140,18 +141,6 @@ query_results_.clear(); results_info_value_ = QueryResult(); - // Query local history. - history::HistoryService* history_service = - ios::HistoryServiceFactory::GetForBrowserState( - browser_state_, ServiceAccessType::EXPLICIT_ACCESS); - if (history_service) { - history_service->QueryHistory( - search_text, options, - base::Bind(&HistoryServiceFacade::QueryComplete, base::Unretained(this), - search_text, options), - &query_task_tracker_); - } - // Query synced history. history::WebHistoryService* web_history = ios::WebHistoryServiceFactory::GetForBrowserState(browser_state_); @@ -167,6 +156,18 @@ FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), this, &HistoryServiceFacade::WebHistoryTimeout); } + + // Query local history. + history::HistoryService* history_service = + ios::HistoryServiceFactory::GetForBrowserState( + browser_state_, ServiceAccessType::EXPLICIT_ACCESS); + if (history_service) { + history_service->QueryHistory( + search_text, options, + base::Bind(&HistoryServiceFacade::QueryComplete, base::Unretained(this), + search_text, options), + &query_task_tracker_); + } } void HistoryServiceFacade::RemoveHistoryEntries( @@ -374,6 +375,7 @@ } results_info_value_.has_synced_results = results_value != NULL; + results_info_value_.sync_returned = true; if (results_value) { std::string continuation_token; results_value->GetString("continuation_token", &continuation_token);
diff --git a/ios/chrome/browser/ui/settings/OWNERS b/ios/chrome/browser/ui/settings/OWNERS index b79a55ef..ccddf8d 100644 --- a/ios/chrome/browser/ui/settings/OWNERS +++ b/ios/chrome/browser/ui/settings/OWNERS
@@ -1,3 +1,2 @@ -jyquinn@chromium.org lpromero@chromium.org sdefresne@chromium.org
diff --git a/ios/chrome/browser/ui/webui/OWNERS b/ios/chrome/browser/ui/webui/OWNERS index 936c0336..a01ab6c 100644 --- a/ios/chrome/browser/ui/webui/OWNERS +++ b/ios/chrome/browser/ui/webui/OWNERS
@@ -1 +1,2 @@ -jyquinn@chromium.org +eugenebut@chromium.org +michaeldo@chromium.org
diff --git a/ios/third_party/requirejs/OWNERS b/ios/third_party/requirejs/OWNERS index 5ec57da..ea2dcf4 100644 --- a/ios/third_party/requirejs/OWNERS +++ b/ios/third_party/requirejs/OWNERS
@@ -1,2 +1 @@ eugenebut@chromium.org -jyquinn@chromium.org
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn index add468b..6076341a 100644 --- a/ios/web/BUILD.gn +++ b/ios/web/BUILD.gn
@@ -590,7 +590,6 @@ "webui/resources/web_ui_base.js", "webui/resources/web_ui_bind.js", "webui/resources/web_ui_bundle.js", - "webui/resources/web_ui_favicons.js", "webui/resources/web_ui_module_load_notifier.js", "webui/resources/web_ui_send.js", ]
diff --git a/ios/web/navigation/crw_session_controller.mm b/ios/web/navigation/crw_session_controller.mm index e592cce..c4c0785 100644 --- a/ios/web/navigation/crw_session_controller.mm +++ b/ios/web/navigation/crw_session_controller.mm
@@ -373,7 +373,7 @@ // between new navigations and history stack navigation, hence the inclusion // of specific transiton type logic here, in order to make it reliable with // real-world observed behavior. - // TODO(stuartmorgan): Fix the way changes are detected/reported elsewhere + // TODO(crbug.com/676129): Fix the way changes are detected/reported elsewhere // in the web layer so that this hack can be removed. // Remove the workaround code from -presentSafeBrowsingWarningForResource:. CRWSessionEntry* currentEntry = self.currentEntry;
diff --git a/ios/web/payments/OWNERS b/ios/web/payments/OWNERS index 9973497e..cda1316 100644 --- a/ios/web/payments/OWNERS +++ b/ios/web/payments/OWNERS
@@ -1,2 +1,2 @@ jdonnelly@chromium.org -jyquinn@chromium.org +lpromero@chromium.org
diff --git a/ios/web/public/payments/OWNERS b/ios/web/public/payments/OWNERS index 9973497e..cda1316 100644 --- a/ios/web/public/payments/OWNERS +++ b/ios/web/public/payments/OWNERS
@@ -1,2 +1,2 @@ jdonnelly@chromium.org -jyquinn@chromium.org +lpromero@chromium.org
diff --git a/ios/web/public/test/earl_grey/web_view_matchers.h b/ios/web/public/test/earl_grey/web_view_matchers.h index 450d39c..1933471 100644 --- a/ios/web/public/test/earl_grey/web_view_matchers.h +++ b/ios/web/public/test/earl_grey/web_view_matchers.h
@@ -30,6 +30,11 @@ id<GREYMatcher> webViewContainingBlockedImage(std::string image_id, WebState* web_state); +// Matcher for WKWebView containing loaded image with |image_id|. When loaded, +// the image element will have the same size as actual image. +id<GREYMatcher> webViewContainingLoadedImage(std::string image_id, + WebState* web_state); + // Matcher for WKWebView containing an html element which matches |selector|. id<GREYMatcher> webViewCssSelector(std::string selector, WebState* web_state);
diff --git a/ios/web/public/test/earl_grey/web_view_matchers.mm b/ios/web/public/test/earl_grey/web_view_matchers.mm index 435e303..984e731 100644 --- a/ios/web/public/test/earl_grey/web_view_matchers.mm +++ b/ios/web/public/test/earl_grey/web_view_matchers.mm
@@ -43,43 +43,20 @@ namespace { +// Enum describing loaded/blocked state of an image html element. +enum ImageState { + // Element was not loaded by WebState. + IMAGE_STATE_BLOCKED = 1, + // Element was fullt loaded by WebState. + IMAGE_STATE_LOADED, +}; + // Script that returns document.body as a string. char kGetDocumentBodyJavaScript[] = "document.body ? document.body.textContent : null"; // Script that tests presence of css selector. char kTestCssSelectorJavaScriptTemplate[] = "!!document.querySelector(\"%s\");"; -// Helper function for matching web views containing or not containing |text|, -// depending on the value of |should_contain_text|. -id<GREYMatcher> webViewWithText(std::string text, - web::WebState* web_state, - bool should_contain_text) { - MatchesBlock matches = ^BOOL(WKWebView*) { - return WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ - std::unique_ptr<base::Value> value = - web::test::ExecuteJavaScript(web_state, kGetDocumentBodyJavaScript); - std::string body; - if (value && value->GetAsString(&body)) { - BOOL contains_text = body.find(text) != std::string::npos; - return contains_text == should_contain_text; - } - return false; - }); - }; - - DescribeToBlock describe = ^(id<GREYDescription> description) { - [description appendText:should_contain_text ? @"web view containing " - : @"web view not containing "]; - [description appendText:base::SysUTF8ToNSString(text)]; - }; - - return grey_allOf(webViewInWebState(web_state), - [[[GREYElementMatcherBlock alloc] - initWithMatchesBlock:matches - descriptionBlock:describe] autorelease], - nil); -} - // Fetches the image from |image_url|. UIImage* LoadImage(const GURL& image_url) { __block base::scoped_nsobject<UIImage> image; @@ -114,40 +91,47 @@ return [[image retain] autorelease]; } -} // namespace - -namespace web { - -id<GREYMatcher> webViewInWebState(WebState* web_state) { - MatchesBlock matches = ^BOOL(UIView* view) { - return [view isKindOfClass:[WKWebView class]] && - [view isDescendantOfView:web_state->GetView()]; +// Helper function for matching web views containing or not containing |text|, +// depending on the value of |should_contain_text|. +id<GREYMatcher> webViewWithText(std::string text, + web::WebState* web_state, + bool should_contain_text) { + MatchesBlock matches = ^BOOL(WKWebView*) { + return WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ + std::unique_ptr<base::Value> value = + web::test::ExecuteJavaScript(web_state, kGetDocumentBodyJavaScript); + std::string body; + if (value && value->GetAsString(&body)) { + BOOL contains_text = body.find(text) != std::string::npos; + return contains_text == should_contain_text; + } + return false; + }); }; DescribeToBlock describe = ^(id<GREYDescription> description) { - [description appendText:@"web view in web state"]; + [description appendText:should_contain_text ? @"web view containing " + : @"web view not containing "]; + [description appendText:base::SysUTF8ToNSString(text)]; }; - return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches - descriptionBlock:describe] - autorelease]; + return grey_allOf(webViewInWebState(web_state), + [[[GREYElementMatcherBlock alloc] + initWithMatchesBlock:matches + descriptionBlock:describe] autorelease], + nil); } -id<GREYMatcher> webViewContainingText(std::string text, WebState* web_state) { - return webViewWithText(text, web_state, true); -} - -id<GREYMatcher> webViewNotContainingText(std::string text, - WebState* web_state) { - return webViewWithText(text, web_state, false); -} - -id<GREYMatcher> webViewContainingBlockedImage(std::string image_id, - WebState* web_state) { +// Matcher for WKWebView containing loaded or blocked image with |image_id|. +// Pass IMAGE_STATE_LOADED |image_state| to match fully loaded image and +// IMAGE_STATE_BLOCKED to match fully blocked image. +id<GREYMatcher> webViewContainingImage(std::string image_id, + web::WebState* web_state, + ImageState image_state) { std::string get_url_script = base::StringPrintf("document.getElementById('%s').src", image_id.c_str()); std::unique_ptr<base::Value> url_as_value = - test::ExecuteJavaScript(web_state, get_url_script); + web::test::ExecuteJavaScript(web_state, get_url_script); std::string url_as_string; if (!url_as_value->GetAsString(&url_as_string)) return grey_nil(); @@ -182,14 +166,28 @@ error:nil]; CGFloat height = [image_attributes[@"height"] floatValue]; CGFloat width = [image_attributes[@"width"] floatValue]; - return (height < expected_size.height && width < expected_size.width); + switch (image_state) { + case IMAGE_STATE_BLOCKED: + return height < expected_size.height && width < expected_size.width; + case IMAGE_STATE_LOADED: + return height == expected_size.height && + width == expected_size.width; + } } return false; }); }; DescribeToBlock describe = ^(id<GREYDescription> description) { - [description appendText:@"web view blocking resource with id "]; + switch (image_state) { + case IMAGE_STATE_BLOCKED: + [description appendText:@"web view blocked resource with id "]; + break; + case IMAGE_STATE_LOADED: + [description appendText:@"web view loaded resource with id "]; + break; + } + [description appendText:base::SysUTF8ToNSString(image_id)]; }; @@ -200,6 +198,44 @@ nil); } +} // namespace + +namespace web { + +id<GREYMatcher> webViewInWebState(WebState* web_state) { + MatchesBlock matches = ^BOOL(UIView* view) { + return [view isKindOfClass:[WKWebView class]] && + [view isDescendantOfView:web_state->GetView()]; + }; + + DescribeToBlock describe = ^(id<GREYDescription> description) { + [description appendText:@"web view in web state"]; + }; + + return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches + descriptionBlock:describe] + autorelease]; +} + +id<GREYMatcher> webViewContainingText(std::string text, WebState* web_state) { + return webViewWithText(text, web_state, true); +} + +id<GREYMatcher> webViewNotContainingText(std::string text, + WebState* web_state) { + return webViewWithText(text, web_state, false); +} + +id<GREYMatcher> webViewContainingBlockedImage(std::string image_id, + WebState* web_state) { + return webViewContainingImage(image_id, web_state, IMAGE_STATE_BLOCKED); +} + +id<GREYMatcher> webViewContainingLoadedImage(std::string image_id, + WebState* web_state) { + return webViewContainingImage(image_id, web_state, IMAGE_STATE_LOADED); +} + id<GREYMatcher> webViewCssSelector(std::string selector, WebState* web_state) { MatchesBlock matches = ^BOOL(WKWebView*) { std::string script = base::StringPrintf(kTestCssSelectorJavaScriptTemplate,
diff --git a/ios/web/public/webui/OWNERS b/ios/web/public/webui/OWNERS index 5ec57da..a01ab6c 100644 --- a/ios/web/public/webui/OWNERS +++ b/ios/web/public/webui/OWNERS
@@ -1,2 +1,2 @@ eugenebut@chromium.org -jyquinn@chromium.org +michaeldo@chromium.org
diff --git a/ios/web/webui/crw_web_ui_manager.mm b/ios/web/webui/crw_web_ui_manager.mm index 8100606..d7660f7a 100644 --- a/ios/web/webui/crw_web_ui_manager.mm +++ b/ios/web/webui/crw_web_ui_manager.mm
@@ -30,7 +30,7 @@ #endif namespace { -// Prefix for history.requestFavicon JavaScript message. +// Prefix for JavaScript messages. const char kScriptCommandPrefix[] = "webui"; } @@ -51,9 +51,6 @@ // Handles JavaScript message from the WebUI page. - (BOOL)handleWebUIJSMessage:(const base::DictionaryValue&)message; -// Handles webui.requestFavicon JavaScript message from the WebUI page. -- (BOOL)handleRequestFavicon:(const base::ListValue*)arguments; - // Handles webui.loadMojo JavaScript message from the WebUI page. - (BOOL)handleLoadMojo:(const base::ListValue*)arguments; @@ -197,8 +194,6 @@ return NO; } - if (command == "webui.requestFavicon") - return [self handleRequestFavicon:arguments]; if (command == "webui.loadMojo") return [self handleLoadMojo:arguments]; @@ -206,33 +201,6 @@ return NO; } -- (BOOL)handleRequestFavicon:(const base::ListValue*)arguments { - std::string favicon; - if (!arguments->GetString(0, &favicon)) { - DLOG(WARNING) << "JS message parameter not found: Favicon URL"; - return NO; - } - GURL faviconURL(favicon); - DCHECK(faviconURL.is_valid()); - // Retrieve favicon resource and set favicon background image via JavaScript. - base::WeakNSObject<CRWWebUIManager> weakSelf(self); - void (^faviconHandler)(NSData*) = ^void(NSData* data) { - base::scoped_nsobject<CRWWebUIManager> strongSelf(weakSelf); - if (!strongSelf) - return; - NSString* base64EncodedResource = [data base64EncodedStringWithOptions:0]; - NSString* dataURLString = [NSString - stringWithFormat:@"data:image/png;base64,%@", base64EncodedResource]; - NSString* faviconURLString = base::SysUTF8ToNSString(faviconURL.spec()); - NSString* script = - [NSString stringWithFormat:@"chrome.setFaviconBackground('%@', '%@');", - faviconURLString, dataURLString]; - [strongSelf webState]->ExecuteJavaScript(base::SysNSStringToUTF16(script)); - }; - [self fetchResourceWithURL:faviconURL completionHandler:faviconHandler]; - return YES; -} - - (BOOL)handleLoadMojo:(const base::ListValue*)arguments { std::string moduleName; if (!arguments->GetString(0, &moduleName)) {
diff --git a/ios/web/webui/crw_web_ui_manager_unittest.mm b/ios/web/webui/crw_web_ui_manager_unittest.mm index e5274d85..27288b4 100644 --- a/ios/web/webui/crw_web_ui_manager_unittest.mm +++ b/ios/web/webui/crw_web_ui_manager_unittest.mm
@@ -149,36 +149,6 @@ } // Tests that CRWWebUIManager responds to OnScriptCommandReceieved call and runs -// JavaScript to set favicon background. -TEST_F(CRWWebUIManagerTest, HandleFaviconRequest) { - GURL test_url(kTestWebUIUrl); - std::string favicon_url_string(kFaviconUrl); - - // Create mock JavaScript message to request favicon. - base::ListValue* arguments(new base::ListValue()); - arguments->AppendString(favicon_url_string); - std::unique_ptr<base::DictionaryValue> message(new base::DictionaryValue()); - message->SetString("message", "webui.requestFavicon"); - message->Set("arguments", arguments); - - // Create expected JavaScript to call. - base::FilePath favicon_path; - ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &favicon_path)); - favicon_path = favicon_path.AppendASCII(kFaviconPath); - NSData* expected_data = [NSData - dataWithContentsOfFile:base::SysUTF8ToNSString(favicon_path.value())]; - base::string16 expected_javascript = base::SysNSStringToUTF16([NSString - stringWithFormat: - @"chrome.setFaviconBackground('%s', 'data:image/png;base64,%@');", - favicon_url_string.c_str(), - [expected_data base64EncodedStringWithOptions:0]]); - - EXPECT_CALL(*web_state_impl_, ExecuteJavaScript(expected_javascript)); - web_state_impl_->OnScriptCommandReceived("webui.requestFavicon", *message, - test_url, false); -} - -// Tests that CRWWebUIManager responds to OnScriptCommandReceieved call and runs // JavaScript to fetch a mojo resource. TEST_F(CRWWebUIManagerTest, HandleLoadMojoRequest) { // Create mock JavaScript message to request a mojo resource.
diff --git a/ios/web/webui/resources/web_ui_bundle.js b/ios/web/webui/resources/web_ui_bundle.js index 84889d6..036b982 100644 --- a/ios/web/webui/resources/web_ui_bundle.js +++ b/ios/web/webui/resources/web_ui_bundle.js
@@ -5,6 +5,5 @@ goog.provide('__crWeb.webUIBundle'); goog.require('__crWeb.webUIBind'); -goog.require('__crWeb.webUIFavicons'); goog.require('__crWeb.webUIRequire'); goog.require('__crWeb.webUISend');
diff --git a/ios/web/webui/resources/web_ui_favicons.js b/ios/web/webui/resources/web_ui_favicons.js deleted file mode 100644 index ff18cc2..0000000 --- a/ios/web/webui/resources/web_ui_favicons.js +++ /dev/null
@@ -1,56 +0,0 @@ -// Copyright 2014 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. - -// This file adheres to closure-compiler conventions in order to enable -// compilation with ADVANCED_OPTIMIZATIONS. In particular, members that are to -// be accessed externally should be specified in this['style'] as opposed to -// this.style because member identifiers are minified by default. -// See http://goo.gl/FwOgy - -goog.require('__crWeb.webUIBase'); - -goog.provide('__crWeb.webUIFavicons'); - -/** - * Sends message requesting favicon at the URL from imageSet for el. Sets - * favicon-url attribute on el to the favicon URL. - * @param {Element} el The DOM element to request the favicon for. - * @param {string} imageSet The CSS -webkit-image-set. - */ -window['chrome']['requestFavicon'] = function(el, imageSet) { - var cssUrls = imageSet.match(/url\([^\)]+\) \dx/g); - // TODO(jyquinn): Review match above (crbug.com/528080). - if (!cssUrls) { - return; - } - // Extract url from CSS -webkit-image-set. - var faviconUrl = ''; - for (var i = 0; i < cssUrls.length; ++i) { - var scaleFactorExp = /(\d)x$/; - var scaleFactor = window.devicePixelRatio; - if (parseInt(scaleFactorExp.exec(cssUrls[i])[1], 10) === scaleFactor) { - var urlExp = /url\(\"(.+)\"\)/; - faviconUrl = urlExp.exec(cssUrls[i])[1]; - break; - } - } - el.setAttribute('favicon-url', url(faviconUrl)); - chrome.send('webui.requestFavicon', [faviconUrl]); -}; - -/** - * Called to set elements with favicon-url attribute equal to faviconUrl to - * provided dataUrl. - * @param {string} faviconUrl Favicon URL used to locate favicon element - * via the favicon-url attribute. - * @param {string} dataUrl The data URL to assign to the favicon element's - * backgroundImage. - */ -window['chrome']['setFaviconBackground'] = function(faviconUrl, dataUrl) { - var selector = "[favicon-url='" + url(faviconUrl) + "']"; - var elements = document.querySelectorAll(selector); - for (var i = 0; i < elements.length; ++i) { - elements[i].style.backgroundImage = url(dataUrl); - } -};
diff --git a/media/capture/video/file_video_capture_device.cc b/media/capture/video/file_video_capture_device.cc index b52f352..bdac8fbfe 100644 --- a/media/capture/video/file_video_capture_device.cc +++ b/media/capture/video/file_video_capture_device.cc
@@ -91,7 +91,8 @@ // Pixel aspect ratio ignored. break; case 'C': - CHECK(token == "420" || token == "420jpeg" || token == "420paldv") + CHECK(token == "420" || token == "420jpeg" || token == "420mpeg2" || + token == "420paldv") << token; // Only I420 is supported, and we fudge the variants. break; default:
diff --git a/media/ffmpeg/ffmpeg_regression_tests.cc b/media/ffmpeg/ffmpeg_regression_tests.cc index 836b073..1c0b0a5 100644 --- a/media/ffmpeg/ffmpeg_regression_tests.cc +++ b/media/ffmpeg/ffmpeg_regression_tests.cc
@@ -194,7 +194,7 @@ FFMPEG_TEST_CASE(Cr665305, "crbug665305.flac", PIPELINE_OK, - PIPELINE_ERROR_DECODE); + DEMUXER_ERROR_COULD_NOT_PARSE); FFMPEG_TEST_CASE_SEEKING(Cr666770, "security/666770.mp4", PIPELINE_OK,
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index 0c532d0e..31c706e 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc
@@ -553,9 +553,14 @@ : base::TimeDelta::FromMicroseconds(1))); } + if (buffer->timestamp() == kNoTimestamp) { + // If we didn't get a valid timestamp and didn't fix it up, then fail. + demuxer_->NotifyDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE); + return; + } + // The demuxer should always output positive timestamps. DCHECK(buffer->timestamp() >= base::TimeDelta()); - DCHECK(buffer->timestamp() != kNoTimestamp); if (last_packet_timestamp_ < buffer->timestamp()) { buffered_ranges_.Add(last_packet_timestamp_, buffer->timestamp()); @@ -1802,6 +1807,12 @@ host_->OnDemuxerError(PIPELINE_ERROR_READ); } +void FFmpegDemuxer::NotifyDemuxerError(PipelineStatus status) { + MEDIA_LOG(ERROR, media_log_) << GetDisplayName() + << ": demuxer error: " << status; + host_->OnDemuxerError(status); +} + void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { DCHECK(task_runner_->BelongsToCurrentThread()); for (const auto& stream : streams_) {
diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h index 2011d821..6575644 100644 --- a/media/filters/ffmpeg_demuxer.h +++ b/media/filters/ffmpeg_demuxer.h
@@ -235,6 +235,9 @@ void NotifyCapacityAvailable(); void NotifyBufferingChanged(); + // Allow FFmpegDemxuerStream to notify us about an error. + void NotifyDemuxerError(PipelineStatus error); + void OnEnabledAudioTracksChanged(const std::vector<MediaTrack::Id>& track_ids, base::TimeDelta currTime) override; // |track_ids| is either empty or contains a single video track id.
diff --git a/net/http2/hpack/hpack_string.cc b/net/http2/hpack/hpack_string.cc new file mode 100644 index 0000000..f84bedbf --- /dev/null +++ b/net/http2/hpack/hpack_string.cc
@@ -0,0 +1,47 @@ +// Copyright 2016 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. + +#include "net/http2/hpack/hpack_string.h" + +#include <utility> + +using base::StringPiece; +using std::string; + +namespace net { + +HpackString::HpackString(const char* data) : str_(data) {} +HpackString::HpackString(StringPiece str) : str_(str.as_string()) {} +HpackString::HpackString(string str) : str_(std::move(str)) {} +HpackString::HpackString(const HpackString& other) : str_(other.str_) {} +HpackString::~HpackString() {} + +HpackString::operator StringPiece() const { + return str_; +} + +bool HpackString::operator==(const HpackString& other) const { + return str_ == other.str_; +} +bool HpackString::operator==(StringPiece str) const { + return str == str_; +} + +bool operator==(StringPiece a, const HpackString& b) { + return b == a; +} +bool operator!=(StringPiece a, const HpackString& b) { + return !(b == a); +} +bool operator!=(const HpackString& a, const HpackString& b) { + return !(a == b); +} +bool operator!=(const HpackString& a, StringPiece b) { + return !(a == b); +} +std::ostream& operator<<(std::ostream& out, const HpackString& v) { + return out << v.ToString(); +} + +} // namespace net
diff --git a/net/http2/hpack/hpack_string.h b/net/http2/hpack/hpack_string.h new file mode 100644 index 0000000..aeb0c96c --- /dev/null +++ b/net/http2/hpack/hpack_string.h
@@ -0,0 +1,56 @@ +// Copyright 2016 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. + +#ifndef NET_HTTP2_HPACK_HPACK_STRING_H_ +#define NET_HTTP2_HPACK_HPACK_STRING_H_ + +// HpackString is currently a very simple container for a string, but allows us +// to relatively easily experiment with alternate string storage mechanisms for +// handling strings to be encoded with HPACK, or decoded from HPACK, such as +// a ref-counted string. + +#include <stddef.h> + +#include <iosfwd> +#include <string> + +#include "base/strings/string_piece.h" +#include "net/base/net_export.h" + +namespace net { + +class NET_EXPORT_PRIVATE HpackString { + public: + explicit HpackString(const char* data); + explicit HpackString(base::StringPiece str); + explicit HpackString(std::string str); + HpackString(const HpackString& other); + + // Not sure yet whether this move ctor is required/sensible. + HpackString(HpackString&& other) = default; + + ~HpackString(); + + size_t size() const { return str_.size(); } + const std::string& ToString() const { return str_; } + operator base::StringPiece() const; + + bool operator==(const HpackString& other) const; + + bool operator==(base::StringPiece str) const; + + private: + std::string str_; +}; + +NET_EXPORT_PRIVATE bool operator==(base::StringPiece a, const HpackString& b); +NET_EXPORT_PRIVATE bool operator!=(base::StringPiece a, const HpackString& b); +NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, const HpackString& b); +NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, base::StringPiece b); +NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const HpackString& v); + +} // namespace net + +#endif // NET_HTTP2_HPACK_HPACK_STRING_H_
diff --git a/net/http2/hpack/hpack_string_test.cc b/net/http2/hpack/hpack_string_test.cc new file mode 100644 index 0000000..b2181f8 --- /dev/null +++ b/net/http2/hpack/hpack_string_test.cc
@@ -0,0 +1,150 @@ +// Copyright 2016 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. + +#include "net/http2/hpack/hpack_string.h" + +// Tests of HpackString. + +#include <utility> + +#include "base/logging.h" +#include "net/http2/tools/failure.h" +#include "testing/gtest/include/gtest/gtest.h" + +using ::testing::AssertionFailure; +using ::testing::AssertionResult; +using ::testing::AssertionSuccess; +using base::StringPiece; +using std::string; + +namespace net { +namespace test { +namespace { + +const char kStr0[] = "s0: Some string to be copied into another string."; +const char kStr1[] = "S1 - some string to be copied into yet another string."; + +class HpackStringTest : public ::testing::Test { + protected: + AssertionResult VerifyNotEqual(HpackString* actual, + const string& not_expected_str) { + const char* not_expected_ptr = not_expected_str.c_str(); + StringPiece not_expected_sp(not_expected_str); + + VERIFY_NE(*actual, not_expected_ptr); + VERIFY_NE(*actual, not_expected_sp); + VERIFY_NE(*actual, not_expected_str); + VERIFY_NE(static_cast<StringPiece>(*actual), not_expected_sp); + + if (!(not_expected_ptr != *actual)) { + return AssertionFailure(); + } + if (!(not_expected_sp != *actual)) { + return AssertionFailure(); + } + if (!(not_expected_str != *actual)) { + return AssertionFailure(); + } + if (!(not_expected_sp != static_cast<StringPiece>(*actual))) { + return AssertionFailure(); + } + + return AssertionSuccess(); + } + + AssertionResult VerifyEqual(HpackString* actual, const string& expected_str) { + VERIFY_EQ(actual->size(), expected_str.size()); + + const char* expected_ptr = expected_str.c_str(); + const StringPiece expected_sp(expected_str); + + VERIFY_EQ(*actual, expected_ptr); + VERIFY_EQ(*actual, expected_sp); + VERIFY_EQ(*actual, expected_str); + VERIFY_EQ(static_cast<StringPiece>(*actual), expected_sp); + + if (!(expected_sp == *actual)) { + return AssertionFailure(); + } + if (!(expected_ptr == *actual)) { + return AssertionFailure(); + } + if (!(expected_str == *actual)) { + return AssertionFailure(); + } + if (!(expected_sp == static_cast<StringPiece>(*actual))) { + return AssertionFailure(); + } + + return AssertionSuccess(); + } +}; + +TEST_F(HpackStringTest, CharArrayConstructor) { + HpackString hs0(kStr0); + EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); + EXPECT_TRUE(VerifyNotEqual(&hs0, kStr1)); + + HpackString hs1(kStr1); + EXPECT_TRUE(VerifyEqual(&hs1, kStr1)); + EXPECT_TRUE(VerifyNotEqual(&hs1, kStr0)); +} + +TEST_F(HpackStringTest, StringPieceConstructor) { + StringPiece sp0(kStr0); + HpackString hs0(sp0); + EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); + EXPECT_TRUE(VerifyNotEqual(&hs0, kStr1)); + + StringPiece sp1(kStr1); + HpackString hs1(sp1); + EXPECT_TRUE(VerifyEqual(&hs1, kStr1)); + EXPECT_TRUE(VerifyNotEqual(&hs1, kStr0)); +} + +TEST_F(HpackStringTest, MoveStringConstructor) { + string str0(kStr0); + HpackString hs0(str0); + EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); + EXPECT_TRUE(VerifyNotEqual(&hs0, kStr1)); + + string str1(kStr1); + HpackString hs1(str1); + EXPECT_TRUE(VerifyEqual(&hs1, kStr1)); + EXPECT_TRUE(VerifyNotEqual(&hs1, kStr0)); +} + +TEST_F(HpackStringTest, CopyConstructor) { + StringPiece sp0(kStr0); + HpackString hs0(sp0); + HpackString hs1(hs0); + EXPECT_EQ(hs0, hs1); + + EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); + EXPECT_TRUE(VerifyEqual(&hs1, kStr0)); + + EXPECT_TRUE(VerifyNotEqual(&hs0, kStr1)); + EXPECT_TRUE(VerifyNotEqual(&hs1, kStr1)); +} + +TEST_F(HpackStringTest, MoveConstructor) { + StringPiece sp0(kStr0); + HpackString hs0(sp0); + EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); + EXPECT_TRUE(VerifyNotEqual(&hs0, "")); + + HpackString hs1(std::move(hs0)); + EXPECT_NE(hs0, hs1); + + EXPECT_TRUE(VerifyEqual(&hs1, kStr0)); + EXPECT_TRUE(VerifyEqual(&hs0, "")); + EXPECT_TRUE(VerifyNotEqual(&hs1, "")); + + LOG(INFO) << hs0; + LOG(INFO) << hs1; +} + +} // namespace +} // namespace test +} // namespace net
diff --git a/net/log/bounded_file_net_log_observer.cc b/net/log/bounded_file_net_log_observer.cc deleted file mode 100644 index d7b78f31..0000000 --- a/net/log/bounded_file_net_log_observer.cc +++ /dev/null
@@ -1,407 +0,0 @@ -// Copyright 2016 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. - -#include "net/log/bounded_file_net_log_observer.h" - -#include <memory> -#include <set> -#include <utility> -#include <vector> - -#include "base/bind.h" -#include "base/files/file_util.h" -#include "base/json/json_writer.h" -#include "base/logging.h" -#include "base/strings/string_number_conversions.h" -#include "base/synchronization/lock.h" -#include "base/threading/thread.h" -#include "base/values.h" -#include "net/log/net_log_entry.h" -#include "net/log/net_log_util.h" -#include "net/url_request/url_request_context.h" - -namespace { - -// Number of events that can build up in |write_queue_| before file thread -// is triggered to drain the queue. -const int kNumWriteQueueEvents = 15; - -} // namespace - -namespace net { - -// Used to store events to be written to file. -using EventQueue = std::queue<std::unique_ptr<std::string>>; - -// WriteQueue receives events from BoundedFileNetLogObserver on the main -// thread and holds them in a queue until they are drained from the queue -// and written to file on the file thread. -// -// WriteQueue contains the resources shared between the main thread and the -// file thread. |lock_| must be acquired to read or write to |queue_| and -// |memory_|. -// -// WriteQueue is refcounted and should be destroyed once all events on the -// file thread have finished executing. -class BoundedFileNetLogObserver::WriteQueue - : public base::RefCountedThreadSafe<WriteQueue> { - public: - // |memory_max| indicates the maximum amount of memory that the virtual write - // queue can use. If |memory_| exceeds |memory_max_|, the |queue_| of events - // is overwritten. - WriteQueue(size_t memory_max); - - // Adds |event| to |queue_|. Also manages the size of |memory_|; if it - // exceeds |memory_max_|, then old events are dropped from |queue_| without - // being written to file. - // - // Returns the number of events in the |queue_|. - size_t AddEntryToQueue(std::unique_ptr<std::string> event); - - // Swaps |queue_| with |local_queue|. |local_queue| should be empty, so that - // |queue_| is emptied. Resets |memory_| to 0. - void SwapQueue(EventQueue* local_queue); - - private: - friend class base::RefCountedThreadSafe<WriteQueue>; - - ~WriteQueue(); - - // Queue of events to be written shared between main thread and file thread. - // Main thread adds events to the queue and the file thread drains them and - // writes the events to file. - // - // |lock_| must be acquired to read or write to this. - EventQueue queue_; - - // Tracks how much memory is being used by the virtual write queue. - // Incremented in AddEntryToQueue() when events are added to the - // buffer, and decremented when SwapQueue() is called and the file thread's - // local queue is swapped with the shared write queue. - // - // |lock_| must be acquired to read or write to this. - size_t memory_; - - // Indicates the maximum amount of memory that the |queue_| is allowed to - // use. - const size_t memory_max_; - - // Protects access to |queue_| and |memory_|. - // - // A lock is necessary because |queue_| and |memory_| are shared between the - // file thread and the main thread. NetLog's lock protects OnAddEntry(), - // which calls AddEntryToQueue(), but it does not protect access to the - // observer's member variables. Thus, a race condition exists if a thread is - // calling OnAddEntry() at the same time that the file thread is accessing - // |memory_| and |queue_| to write events to file. The |queue_| and |memory_| - // counter are necessary to bound the amount of memory that is used for the - // queue in the event that the file thread lags significantly behind the main - // thread in writing events to file. - base::Lock lock_; - - DISALLOW_COPY_AND_ASSIGN(WriteQueue); -}; - -// FileWriter drains events from WriteQueue and writes them to file. -// -// Owned by BoundedFileNetLogObserver. FileWriter can be constructed on any -// thread, and afterwards is only accessed on the file thread. -class BoundedFileNetLogObserver::FileWriter { - public: - FileWriter(const base::FilePath& path, - size_t max_file_size, - size_t total_num_files, - scoped_refptr<base::SingleThreadTaskRunner> task_runner); - - ~FileWriter(); - - // Writes |constants_value| to constants.json, and opens the - // events array (closed in Stop()). - void Initialize(std::unique_ptr<base::Value> constants_value); - - // Closes the events array opened in Initialize() and writes |tab_info| to - // end_netlog.json. If |tab_info| cannot be converted to proper JSON, then it - // is ignored. - void Stop(std::unique_ptr<base::Value> tab_info); - - // Drains |queue_| from WriteQueue into a local file queue and writes the - // events in the queue to file. - void Flush(scoped_refptr<WriteQueue> write_queue); - - // Deletes all netlog files, including constants.json and end_netlog.json. - // It is not valid to call any method of BoundedFileNetLogObserver after - // DeleteAllFiles(). - void DeleteAllFiles(); - - private: - // Increments |current_file_idx_|, and handles the clearing and openining of - // the new current file. Also sets |event_files_[current_file_idx_]| to point - // to the new current file. - void IncrementCurrentFile(); - - // Each ScopedFILE points to a netlog event file with the file name - // "event_file_<index>.json". - std::vector<base::ScopedFILE> event_files_; - - // The directory where the netlog files are created. - const base::FilePath directory_; - - // Indicates the total number of netlog event files, which does not include - // the constants file (constants.json), or closing file (end_netlog.json). - const size_t total_num_files_; - - // Indicates the index of the file in |event_files_| currently being written - // into. - size_t current_file_idx_; - - // Indicates the maximum size of each individual netlogging file, excluding - // the constant file. - const size_t max_file_size_; - - // Task runner from the file thread. - const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; - - DISALLOW_COPY_AND_ASSIGN(FileWriter); -}; - -BoundedFileNetLogObserver::BoundedFileNetLogObserver( - scoped_refptr<base::SingleThreadTaskRunner> task_runner) - : capture_mode_(NetLogCaptureMode::Default()), task_runner_(task_runner) {} - -BoundedFileNetLogObserver::~BoundedFileNetLogObserver() { - if (net_log()) { - // StopObserving was not called. - task_runner_->PostTask( - FROM_HERE, - base::Bind(&BoundedFileNetLogObserver::FileWriter::DeleteAllFiles, - base::Unretained(file_writer_))); - net_log()->DeprecatedRemoveObserver(this); - } - - task_runner_->DeleteSoon(FROM_HERE, file_writer_); -} - -void BoundedFileNetLogObserver::set_capture_mode( - NetLogCaptureMode capture_mode) { - DCHECK(!net_log()); - capture_mode_ = capture_mode; -} - -void BoundedFileNetLogObserver::StartObserving( - NetLog* net_log, - const base::FilePath& filepath, - base::Value* constants, - URLRequestContext* url_request_context, - size_t max_total_size, - size_t total_num_files) { - DCHECK_GT(total_num_files, 0u); - - file_writer_ = new FileWriter(filepath, max_total_size / total_num_files, - total_num_files, task_runner_); - - // The |file_writer_| uses a soft limit to write events to file that allows - // the size of the file to exceed the limit, but the |write_queue_| uses a - // hard limit which the size of the |queue_| cannot exceed. Thus, the - // |file_writer_| may write more events to file than can be contained by the - // |write_queue_| if they have the same size limit. The maximum size of the - // |write_queue_| is doubled to allow the |queue_| to hold enough events for - // the |file_writer_| to fill all files. As long as all events have sizes <= - // the size of an individual event file, the discrepancy between the hard - // limit and the soft limit will not cause an issue. - // TODO(dconnol): Handle the case when the |write_queue_| still doesn't - // contain enough events to fill all files, because of very large events - // relative to file size. - write_queue_ = make_scoped_refptr(new WriteQueue(max_total_size * 2)); - - task_runner_->PostTask( - FROM_HERE, base::Bind(&BoundedFileNetLogObserver::FileWriter::Initialize, - base::Unretained(file_writer_), - base::Passed(constants ? constants->CreateDeepCopy() - : GetNetConstants()))); - - if (url_request_context) { - DCHECK(url_request_context->CalledOnValidThread()); - std::set<URLRequestContext*> contexts; - contexts.insert(url_request_context); - CreateNetLogEntriesForActiveObjects(contexts, this); - } - - net_log->DeprecatedAddObserver(this, capture_mode_); -} - -void BoundedFileNetLogObserver::StopObserving( - URLRequestContext* url_request_context, - const base::Closure& callback) { - task_runner_->PostTask( - FROM_HERE, base::Bind(&BoundedFileNetLogObserver::FileWriter::Flush, - base::Unretained(file_writer_), write_queue_)); - - task_runner_->PostTaskAndReply( - FROM_HERE, base::Bind(&BoundedFileNetLogObserver::FileWriter::Stop, - base::Unretained(file_writer_), - base::Passed(url_request_context - ? GetNetInfo(url_request_context, - NET_INFO_ALL_SOURCES) - : nullptr)), - callback); - - net_log()->DeprecatedRemoveObserver(this); -} - -void BoundedFileNetLogObserver::OnAddEntry(const NetLogEntry& entry) { - std::unique_ptr<std::string> json(new std::string); - - // If |entry| cannot be converted to proper JSON, ignore it. - if (!base::JSONWriter::Write(*entry.ToValue(), json.get())) - return; - - size_t queue_size = write_queue_->AddEntryToQueue(std::move(json)); - - // If events build up in |write_queue_|, trigger the file thread to drain - // the queue. Because only 1 item is added to the queue at a time, if - // queue_size > kNumWriteQueueEvents a task has already been posted, or will - // be posted. - if (queue_size == kNumWriteQueueEvents) { - task_runner_->PostTask( - FROM_HERE, base::Bind(&BoundedFileNetLogObserver::FileWriter::Flush, - base::Unretained(file_writer_), write_queue_)); - } -} - -BoundedFileNetLogObserver::WriteQueue::WriteQueue(size_t memory_max) - : memory_(0), memory_max_(memory_max) {} - -size_t BoundedFileNetLogObserver::WriteQueue::AddEntryToQueue( - std::unique_ptr<std::string> event) { - base::AutoLock lock(lock_); - - memory_ += event->size(); - queue_.push(std::move(event)); - - while (memory_ > memory_max_ && !queue_.empty()) { - // Delete oldest events in the queue. - DCHECK(queue_.front()); - memory_ -= queue_.front()->size(); - queue_.pop(); - } - - return queue_.size(); -} -void BoundedFileNetLogObserver::WriteQueue::SwapQueue(EventQueue* local_queue) { - DCHECK(local_queue->empty()); - base::AutoLock lock(lock_); - queue_.swap(*local_queue); - memory_ = 0; -} - -BoundedFileNetLogObserver::WriteQueue::~WriteQueue() {} - -BoundedFileNetLogObserver::FileWriter::FileWriter( - const base::FilePath& path, - size_t max_file_size, - size_t total_num_files, - scoped_refptr<base::SingleThreadTaskRunner> task_runner) - : directory_(path), - total_num_files_(total_num_files), - current_file_idx_(0), - max_file_size_(max_file_size), - task_runner_(task_runner) { - event_files_.resize(total_num_files_); -} - -BoundedFileNetLogObserver::FileWriter::~FileWriter() {} - -void BoundedFileNetLogObserver::FileWriter::Initialize( - std::unique_ptr<base::Value> constants_value) { - DCHECK(task_runner_->RunsTasksOnCurrentThread()); - - event_files_[current_file_idx_] = base::ScopedFILE( - base::OpenFile(directory_.AppendASCII("event_file_0.json"), "w")); - - base::ScopedFILE constants_file( - base::OpenFile(directory_.AppendASCII("constants.json"), "w")); - - // Print constants to file and open events array. - std::string json; - - // It should always be possible to convert constants to JSON. - if (!base::JSONWriter::Write(*constants_value, &json)) - DCHECK(false); - fprintf(constants_file.get(), "{\"constants\":%s,\n\"events\": [\n", - json.c_str()); -} - -void BoundedFileNetLogObserver::FileWriter::Stop( - std::unique_ptr<base::Value> tab_info) { - DCHECK(task_runner_->RunsTasksOnCurrentThread()); - - base::ScopedFILE closing_file( - base::OpenFile(directory_.AppendASCII("end_netlog.json"), "w")); - - std::string json; - if (tab_info) - base::JSONWriter::Write(*tab_info, &json); - - fprintf(closing_file.get(), "]%s}", - json.empty() ? "" : (",\"tabInfo\": " + json + "\n").c_str()); - - // Flush all fprintfs to disk so that files can be safely accessed on - // callback. - event_files_.clear(); -} - -void BoundedFileNetLogObserver::FileWriter::IncrementCurrentFile() { - DCHECK(task_runner_->RunsTasksOnCurrentThread()); - - current_file_idx_++; - current_file_idx_ %= total_num_files_; - event_files_[current_file_idx_].reset(); - event_files_[current_file_idx_] = base::ScopedFILE(base::OpenFile( - directory_.AppendASCII("event_file_" + - base::SizeTToString(current_file_idx_) + ".json"), - "w")); -} - -void BoundedFileNetLogObserver::FileWriter::Flush( - scoped_refptr<BoundedFileNetLogObserver::WriteQueue> write_queue) { - DCHECK(task_runner_->RunsTasksOnCurrentThread()); - - EventQueue local_file_queue; - write_queue->SwapQueue(&local_file_queue); - - std::string to_print; - size_t file_size = ftell(event_files_[current_file_idx_].get()); - size_t memory_freed = 0; - - while (!local_file_queue.empty()) { - if (file_size >= max_file_size_) { - // The current file is full. Start a new current file. - IncrementCurrentFile(); - file_size = 0; - } - fprintf(event_files_[current_file_idx_].get(), "%s,\n", - local_file_queue.front().get()->c_str()); - file_size += local_file_queue.front()->size(); - memory_freed += local_file_queue.front()->size(); - local_file_queue.pop(); - } -} - -void BoundedFileNetLogObserver::FileWriter::DeleteAllFiles() { - DCHECK(task_runner_->RunsTasksOnCurrentThread()); - - // Reset |event_files_| to release all file handles so base::DeleteFile can - // safely access files. - event_files_.clear(); - - base::DeleteFile(directory_.AppendASCII("constants.json"), false); - base::DeleteFile(directory_.AppendASCII("end_netlog.json"), false); - for (size_t i = 0; i < total_num_files_; i++) { - base::DeleteFile(directory_.AppendASCII("event_file_" + - base::SizeTToString(i) + ".json"), - false); - } -} - -} // namespace net
diff --git a/net/log/bounded_file_net_log_observer.h b/net/log/bounded_file_net_log_observer.h deleted file mode 100644 index 8925551c..0000000 --- a/net/log/bounded_file_net_log_observer.h +++ /dev/null
@@ -1,135 +0,0 @@ -// Copyright 2016 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. - -#ifndef NET_LOG_BOUNDED_FILE_NET_LOG_OBSERVER_H_ -#define NET_LOG_BOUNDED_FILE_NET_LOG_OBSERVER_H_ - -#include <queue> - -#include "base/files/file_path.h" -#include "base/files/scoped_file.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" -#include "base/synchronization/lock.h" -#include "base/threading/thread.h" -#include "base/threading/thread_task_runner_handle.h" -#include "net/base/net_export.h" -#include "net/log/net_log.h" -#include "net/log/net_log_capture_mode.h" - -namespace base { -class Value; -} // namespace base - -namespace net { - -class URLRequestContext; - -// BoundedFileNetLogObserver watches the NetLog event stream and sends all -// entries to a group of files in the directory specified when observation -// starts. -// -// The events are written to a single JSON object that is split across the -// files, and the files must be stitched together once the observation period -// is over. The first file is constants.json, followed by a consumer-specified -// number of event files named event_file_<index>.json, and the last file is -// end_netlog.json. -// -// The user is able to specify an approximate maximum cumulative size for the -// netlog files and the observer overwrites old events when the maximum file -// size is reached. -// -// The consumer must call StartObserving before calling StopObserving, and must -// call each method exactly once in the lifetime of the observer. StartObserving -// and StopObserving must be called on the same thread, but there is no -// restriction on which thread is used. -class NET_EXPORT BoundedFileNetLogObserver : public NetLog::ThreadSafeObserver { - public: - // |task_runner| indicates the task runner that should be used to post tasks - // from the main thread to the file thread. - // - // |num_event_files| sets the number of event files that should be used to - // write events to file. - BoundedFileNetLogObserver( - scoped_refptr<base::SingleThreadTaskRunner> task_runner); - - ~BoundedFileNetLogObserver() override; - - // Sets the capture mode to log at. Must be called before StartObserving. - void set_capture_mode(NetLogCaptureMode capture_mode); - - // Starts observing |net_log| and writes output to files in |filepath|. - // May only be called once in the lifetime of the object. - // - // |max_total_size| is the approximate limit on the cumulative size of all - // netlog files. - // - // |total_num_files| sets the total number of event files that are used to - // write the events. It must be greater than 0. - // - // |constants| is an optional legend for decoding constant values used in - // the log. It should generally be a modified version of GetNetConstants(). - // If not present, the output of GetNetConstants() will be used. - // - // |url_request_context| is an optional URLRequestContext that will be used - // to pre-populate the log with information about in-progress events. If the - // context is non-NULL, StartObserving() must be called on the context's - // thread. - void StartObserving(NetLog* net_log, - const base::FilePath& filepath, - base::Value* constants, - URLRequestContext* url_request_context, - size_t max_total_size, - size_t total_num_files); - - // Stops observing net_log(). Must be called after StartObserving(). Should - // be called before destruction of the BoundedFileNetLogObserver and the - // NetLog, or the NetLog files will be deleted when the observer is - // destroyed. - // - // |callback| will be run on whichever thread StopObserving() was called on - // once all file writing is complete and the netlog files can be accessed - // safely. - // - // |url_request_context| is an optional argument used to add additional - // network stack state to the log. If the context is non-NULL, - // StopObserving() must be called on the context's thread. - void StopObserving(URLRequestContext* url_request_context, - const base::Closure& callback); - - // NetLog::ThreadSafeObserver - void OnAddEntry(const NetLogEntry& entry) override; - - private: - class WriteQueue; - class FileWriter; - - // The capture mode to log at. - NetLogCaptureMode capture_mode_; - - scoped_refptr<base::SingleThreadTaskRunner> task_runner_; - - // The |write_queue_| object is shared between the file thread and the main - // thread, and should be alive for the entirety of the observer's lifetime. - // It should be destroyed once both the observer has been destroyed and all - // tasks posted to the file thread have completed. - scoped_refptr<WriteQueue> write_queue_; - - // This is the owning reference to a file thread object. The observer is - // responsible for destroying the file thread object by posting a task from - // the main thread to the file thread to destroy the FileWriter when the - // observer is destroyed. - // - // The use of base::Unretained with |file_writer_| to post tasks to the file - // thread is safe because the FileWriter object will be alive until the - // observer's destruction. - FileWriter* file_writer_; - - DISALLOW_COPY_AND_ASSIGN(BoundedFileNetLogObserver); -}; - -} // namespace net - -#endif // NET_LOG_BOUNDED_FILE_NET_LOG_OBSERVER_H_
diff --git a/net/log/file_net_log_observer.cc b/net/log/file_net_log_observer.cc new file mode 100644 index 0000000..e49452df8 --- /dev/null +++ b/net/log/file_net_log_observer.cc
@@ -0,0 +1,541 @@ +// Copyright 2016 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. + +#include "net/log/file_net_log_observer.h" + +#include <limits> +#include <memory> +#include <queue> +#include <set> +#include <string> +#include <utility> +#include <vector> + +#include "base/bind.h" +#include "base/files/file_util.h" +#include "base/json/json_writer.h" +#include "base/logging.h" +#include "base/strings/string_number_conversions.h" +#include "base/synchronization/lock.h" +#include "base/threading/thread.h" +#include "base/values.h" +#include "net/log/net_log_capture_mode.h" +#include "net/log/net_log_entry.h" +#include "net/log/net_log_util.h" +#include "net/url_request/url_request_context.h" + +namespace { + +// Number of events that can build up in |write_queue_| before file thread +// is triggered to drain the queue. +const int kNumWriteQueueEvents = 15; + +} // namespace + +namespace net { + +// Used to store events to be written to file. +using EventQueue = std::queue<std::unique_ptr<std::string>>; + +// WriteQueue receives events from FileNetLogObserver on the main thread and +// holds them in a queue until they are drained from the queue and written to +// file on the file thread. +// +// WriteQueue contains the resources shared between the main thread and the +// file thread. |lock_| must be acquired to read or write to |queue_| and +// |memory_|. +// +// WriteQueue is refcounted and should be destroyed once all events on the +// file thread have finished executing. +class FileNetLogObserver::WriteQueue + : public base::RefCountedThreadSafe<WriteQueue> { + public: + // |memory_max| indicates the maximum amount of memory that the virtual write + // queue can use. If |memory_| exceeds |memory_max_|, the |queue_| of events + // is overwritten. + explicit WriteQueue(size_t memory_max); + + // Adds |event| to |queue_|. Also manages the size of |memory_|; if it + // exceeds |memory_max_|, then old events are dropped from |queue_| without + // being written to file. + // + // Returns the number of events in the |queue_|. + size_t AddEntryToQueue(std::unique_ptr<std::string> event); + + // Swaps |queue_| with |local_queue|. |local_queue| should be empty, so that + // |queue_| is emptied. Resets |memory_| to 0. + void SwapQueue(EventQueue* local_queue); + + private: + friend class base::RefCountedThreadSafe<WriteQueue>; + + ~WriteQueue(); + + // Queue of events to be written shared between main thread and file thread. + // Main thread adds events to the queue and the file thread drains them and + // writes the events to file. + // + // |lock_| must be acquired to read or write to this. + EventQueue queue_; + + // Tracks how much memory is being used by the virtual write queue. + // Incremented in AddEntryToQueue() when events are added to the + // buffer, and decremented when SwapQueue() is called and the file thread's + // local queue is swapped with the shared write queue. + // + // |lock_| must be acquired to read or write to this. + size_t memory_; + + // Indicates the maximum amount of memory that the |queue_| is allowed to + // use. + const size_t memory_max_; + + // Protects access to |queue_| and |memory_|. + // + // A lock is necessary because |queue_| and |memory_| are shared between the + // file thread and the main thread. NetLog's lock protects OnAddEntry(), + // which calls AddEntryToQueue(), but it does not protect access to the + // observer's member variables. Thus, a race condition exists if a thread is + // calling OnAddEntry() at the same time that the file thread is accessing + // |memory_| and |queue_| to write events to file. The |queue_| and |memory_| + // counter are necessary to bound the amount of memory that is used for the + // queue in the event that the file thread lags significantly behind the main + // thread in writing events to file. + base::Lock lock_; + + DISALLOW_COPY_AND_ASSIGN(WriteQueue); +}; + +// FileWriter is an interface describing an object that drains events from a +// WriteQueue and writes them to disk. +class FileNetLogObserver::FileWriter { + public: + virtual ~FileWriter(); + + // Writes |constants_value| to disk and opens the events array (closed in + // Stop()). + virtual void Initialize(std::unique_ptr<base::Value> constants_value) = 0; + + // Closes the events array opened in Initialize() and writes |tab_info| to + // disk. If |tab_info| cannot be converted to proper JSON, then it + // is ignored. + virtual void Stop(std::unique_ptr<base::Value> tab_info) = 0; + + // Drains |queue_| from WriteQueue into a local file queue and writes the + // events in the queue to disk. + virtual void Flush(scoped_refptr<WriteQueue> write_queue) = 0; + + // Deletes all netlog files. It is not valid to call any method of + // FileNetLogObserver after DeleteAllFiles(). + virtual void DeleteAllFiles() = 0; +}; + +// This implementation of FileWriter is used when the observer is in bounded +// mode. +// BoundedFileWriter can be constructed on any thread, and afterwards is only +// accessed on the file thread. +class FileNetLogObserver::BoundedFileWriter + : public FileNetLogObserver::FileWriter { + public: + BoundedFileWriter(const base::FilePath& directory, + size_t max_file_size, + size_t total_num_files, + scoped_refptr<base::SingleThreadTaskRunner> task_runner); + + ~BoundedFileWriter() override; + + // FileNetLogObserver::FileWriter implementation + void Initialize(std::unique_ptr<base::Value> constants_value) override; + void Stop(std::unique_ptr<base::Value> tab_info) override; + void Flush(scoped_refptr<WriteQueue> write_queue) override; + void DeleteAllFiles() override; + + private: + // Increments |current_file_idx_|, and handles the clearing and openining of + // the new current file. Also sets |event_files_[current_file_idx_]| to point + // to the new current file. + void IncrementCurrentFile(); + + // Each ScopedFILE points to a netlog event file with the file name + // "event_file_<index>.json". + std::vector<base::ScopedFILE> event_files_; + + // The directory where the netlog files are created. + const base::FilePath directory_; + + // Indicates the total number of netlog event files, which does not include + // the constants file (constants.json), or closing file (end_netlog.json). + const size_t total_num_files_; + + // Indicates the index of the file in |event_files_| currently being written + // into. + size_t current_file_idx_; + + // Indicates the maximum size of each individual netlogging file, excluding + // the constant file. + const size_t max_file_size_; + + // Task runner from the file thread. + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; + + DISALLOW_COPY_AND_ASSIGN(BoundedFileWriter); +}; + +// This implementation of FileWriter is used when the observer is in unbounded +// mode. +// UnboundedFileWriter can be constructed on any thread, and afterwards is only +// accessed on the file thread. +class FileNetLogObserver::UnboundedFileWriter + : public FileNetLogObserver::FileWriter { + public: + UnboundedFileWriter(const base::FilePath& path, + scoped_refptr<base::SingleThreadTaskRunner> task_runner); + + ~UnboundedFileWriter() override; + + // FileNetLogObserver::FileWriter implementation + void Initialize(std::unique_ptr<base::Value> constants_value) override; + void Stop(std::unique_ptr<base::Value> tab_info) override; + void Flush(scoped_refptr<WriteQueue> write_queue) override; + void DeleteAllFiles() override; + + private: + base::FilePath file_path_; + base::ScopedFILE file_; + + // Is set to true after the first event is written to the log file. + bool first_event_written_; + + // Task runner from the file thread. + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; + + DISALLOW_COPY_AND_ASSIGN(UnboundedFileWriter); +}; + +FileNetLogObserver::FileNetLogObserver( + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) + : file_task_runner_(file_task_runner) {} + +FileNetLogObserver::~FileNetLogObserver() { + if (net_log()) { + // StopObserving was not called. + file_task_runner_->PostTask( + FROM_HERE, base::Bind(&FileNetLogObserver::FileWriter::DeleteAllFiles, + base::Unretained(file_writer_))); + net_log()->DeprecatedRemoveObserver(this); + } + + file_task_runner_->DeleteSoon(FROM_HERE, file_writer_); +} + +void FileNetLogObserver::StartObservingBounded( + NetLog* net_log, + NetLogCaptureMode capture_mode, + const base::FilePath& directory, + std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context, + size_t max_total_size, + size_t total_num_files) { + DCHECK_GT(total_num_files, 0u); + + file_writer_ = + new BoundedFileWriter(directory, max_total_size / total_num_files, + total_num_files, file_task_runner_); + + // The |file_writer_| uses a soft limit to write events to file that allows + // the size of the file to exceed the limit, but the |write_queue_| uses a + // hard limit which the size of the |queue_| cannot exceed. Thus, the + // |file_writer_| may write more events to file than can be contained by the + // |write_queue_| if they have the same size limit. The maximum size of the + // |write_queue_| is doubled to allow the |queue_| to hold enough events for + // the |file_writer_| to fill all files. As long as all events have sizes <= + // the size of an individual event file, the discrepancy between the hard + // limit and the soft limit will not cause an issue. + // TODO(dconnol): Handle the case when the |write_queue_| still doesn't + // contain enough events to fill all files, because of very large events + // relative to file size. + write_queue_ = new WriteQueue(max_total_size * 2); + + StartObservingHelper(net_log, capture_mode, std::move(constants), + url_request_context); +} + +void FileNetLogObserver::StartObservingUnbounded( + NetLog* net_log, + NetLogCaptureMode capture_mode, + const base::FilePath& filepath, + std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context) { + file_writer_ = new UnboundedFileWriter(filepath, file_task_runner_); + + write_queue_ = new WriteQueue(std::numeric_limits<size_t>::max()); + + StartObservingHelper(net_log, capture_mode, std::move(constants), + url_request_context); +} + +void FileNetLogObserver::StartObservingHelper( + NetLog* net_log, + NetLogCaptureMode capture_mode, + std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context) { + if (!constants) + constants = GetNetConstants(); + file_task_runner_->PostTask( + FROM_HERE, + base::Bind(&FileNetLogObserver::FileWriter::Initialize, + base::Unretained(file_writer_), base::Passed(&constants))); + + if (url_request_context) { + DCHECK(url_request_context->CalledOnValidThread()); + std::set<URLRequestContext*> contexts; + contexts.insert(url_request_context); + CreateNetLogEntriesForActiveObjects(contexts, this); + } + + net_log->DeprecatedAddObserver(this, capture_mode); +} + +void FileNetLogObserver::StopObserving(URLRequestContext* url_request_context, + const base::Closure& callback) { + file_task_runner_->PostTask( + FROM_HERE, base::Bind(&FileNetLogObserver::FileWriter::Flush, + base::Unretained(file_writer_), write_queue_)); + + file_task_runner_->PostTaskAndReply( + FROM_HERE, + base::Bind( + &FileNetLogObserver::FileWriter::Stop, base::Unretained(file_writer_), + base::Passed(url_request_context ? GetNetInfo(url_request_context, + NET_INFO_ALL_SOURCES) + : nullptr)), + callback); + + net_log()->DeprecatedRemoveObserver(this); +} + +void FileNetLogObserver::OnAddEntry(const NetLogEntry& entry) { + std::unique_ptr<std::string> json(new std::string); + + // If |entry| cannot be converted to proper JSON, ignore it. + if (!base::JSONWriter::Write(*entry.ToValue(), json.get())) + return; + + size_t queue_size = write_queue_->AddEntryToQueue(std::move(json)); + + // If events build up in |write_queue_|, trigger the file thread to drain + // the queue. Because only 1 item is added to the queue at a time, if + // queue_size > kNumWriteQueueEvents a task has already been posted, or will + // be posted. + if (queue_size == kNumWriteQueueEvents) { + file_task_runner_->PostTask( + FROM_HERE, base::Bind(&FileNetLogObserver::FileWriter::Flush, + base::Unretained(file_writer_), write_queue_)); + } +} + +FileNetLogObserver::WriteQueue::WriteQueue(size_t memory_max) + : memory_(0), memory_max_(memory_max) {} + +size_t FileNetLogObserver::WriteQueue::AddEntryToQueue( + std::unique_ptr<std::string> event) { + base::AutoLock lock(lock_); + + memory_ += event->size(); + queue_.push(std::move(event)); + + while (memory_ > memory_max_ && !queue_.empty()) { + // Delete oldest events in the queue. + DCHECK(queue_.front()); + memory_ -= queue_.front()->size(); + queue_.pop(); + } + + return queue_.size(); +} +void FileNetLogObserver::WriteQueue::SwapQueue(EventQueue* local_queue) { + DCHECK(local_queue->empty()); + base::AutoLock lock(lock_); + queue_.swap(*local_queue); + memory_ = 0; +} + +FileNetLogObserver::WriteQueue::~WriteQueue() {} + +FileNetLogObserver::FileWriter::~FileWriter() {} + +FileNetLogObserver::BoundedFileWriter::BoundedFileWriter( + const base::FilePath& directory, + size_t max_file_size, + size_t total_num_files, + scoped_refptr<base::SingleThreadTaskRunner> task_runner) + : directory_(directory), + total_num_files_(total_num_files), + current_file_idx_(0), + max_file_size_(max_file_size), + task_runner_(task_runner) { + event_files_.resize(total_num_files_); +} + +FileNetLogObserver::BoundedFileWriter::~BoundedFileWriter() {} + +void FileNetLogObserver::BoundedFileWriter::Initialize( + std::unique_ptr<base::Value> constants_value) { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + event_files_[current_file_idx_] = base::ScopedFILE( + base::OpenFile(directory_.AppendASCII("event_file_0.json"), "w")); + + base::ScopedFILE constants_file( + base::OpenFile(directory_.AppendASCII("constants.json"), "w")); + + // Print constants to file and open events array. + std::string json; + + // It should always be possible to convert constants to JSON. + if (!base::JSONWriter::Write(*constants_value, &json)) + DCHECK(false); + fprintf(constants_file.get(), "{\"constants\":%s,\n\"events\": [\n", + json.c_str()); +} + +void FileNetLogObserver::BoundedFileWriter::Stop( + std::unique_ptr<base::Value> tab_info) { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + base::ScopedFILE closing_file( + base::OpenFile(directory_.AppendASCII("end_netlog.json"), "w")); + + std::string json; + if (tab_info) + base::JSONWriter::Write(*tab_info, &json); + + fprintf(closing_file.get(), "]%s}\n", + json.empty() ? "" : (",\"tabInfo\": " + json + "\n").c_str()); + + // Flush all fprintfs to disk so that files can be safely accessed on + // callback. + event_files_.clear(); +} + +void FileNetLogObserver::BoundedFileWriter::IncrementCurrentFile() { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + current_file_idx_++; + current_file_idx_ %= total_num_files_; + event_files_[current_file_idx_].reset(); + event_files_[current_file_idx_] = base::ScopedFILE(base::OpenFile( + directory_.AppendASCII("event_file_" + + base::SizeTToString(current_file_idx_) + ".json"), + "w")); +} + +void FileNetLogObserver::BoundedFileWriter::Flush( + scoped_refptr<FileNetLogObserver::WriteQueue> write_queue) { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + EventQueue local_file_queue; + write_queue->SwapQueue(&local_file_queue); + + std::string to_print; + size_t file_size = ftell(event_files_[current_file_idx_].get()); + size_t memory_freed = 0; + + while (!local_file_queue.empty()) { + if (file_size >= max_file_size_) { + // The current file is full. Start a new current file. + IncrementCurrentFile(); + file_size = 0; + } + fprintf(event_files_[current_file_idx_].get(), "%s,\n", + local_file_queue.front().get()->c_str()); + file_size += local_file_queue.front()->size(); + memory_freed += local_file_queue.front()->size(); + local_file_queue.pop(); + } +} + +void FileNetLogObserver::BoundedFileWriter::DeleteAllFiles() { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + // Reset |event_files_| to release all file handles so base::DeleteFile can + // safely access files. + event_files_.clear(); + + base::DeleteFile(directory_.AppendASCII("constants.json"), false); + base::DeleteFile(directory_.AppendASCII("end_netlog.json"), false); + for (size_t i = 0; i < total_num_files_; i++) { + base::DeleteFile(directory_.AppendASCII("event_file_" + + base::SizeTToString(i) + ".json"), + false); + } +} + +FileNetLogObserver::UnboundedFileWriter::UnboundedFileWriter( + const base::FilePath& path, + scoped_refptr<base::SingleThreadTaskRunner> task_runner) + : file_path_(path), task_runner_(task_runner) {} + +FileNetLogObserver::UnboundedFileWriter::~UnboundedFileWriter() {} + +void FileNetLogObserver::UnboundedFileWriter::Initialize( + std::unique_ptr<base::Value> constants_value) { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + file_.reset(base::OpenFile(file_path_, "w")); + first_event_written_ = false; + + // Print constants to file and open events array. + std::string json; + + // It should always be possible to convert constants to JSON. + if (!base::JSONWriter::Write(*constants_value, &json)) + DCHECK(false); + fprintf(file_.get(), "{\"constants\":%s,\n\"events\": [\n", json.c_str()); +} + +void FileNetLogObserver::UnboundedFileWriter::Stop( + std::unique_ptr<base::Value> tab_info) { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + std::string json; + if (tab_info) + base::JSONWriter::Write(*tab_info, &json); + + fprintf(file_.get(), "]%s}\n", + json.empty() ? "" : (",\n\"tabInfo\": " + json + "\n").c_str()); + + // Flush all fprintfs to disk so that the file can be safely accessed on + // callback. + file_.reset(); +} + +void FileNetLogObserver::UnboundedFileWriter::Flush( + scoped_refptr<FileNetLogObserver::WriteQueue> write_queue) { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + EventQueue local_file_queue; + write_queue->SwapQueue(&local_file_queue); + + while (!local_file_queue.empty()) { + if (first_event_written_) { + fputs(",\n", file_.get()); + } else { + first_event_written_ = true; + } + fputs(local_file_queue.front()->c_str(), file_.get()); + local_file_queue.pop(); + } +} + +void FileNetLogObserver::UnboundedFileWriter::DeleteAllFiles() { + DCHECK(task_runner_->RunsTasksOnCurrentThread()); + + // Reset |file_| to release the file handle so base::DeleteFile can + // safely access it. + file_.reset(); + base::DeleteFile(file_path_, false); +} + +} // namespace net
diff --git a/net/log/file_net_log_observer.h b/net/log/file_net_log_observer.h new file mode 100644 index 0000000..f8a8d90 --- /dev/null +++ b/net/log/file_net_log_observer.h
@@ -0,0 +1,157 @@ +// Copyright 2016 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. + +#ifndef NET_LOG_FILE_NET_LOG_OBSERVER_H_ +#define NET_LOG_FILE_NET_LOG_OBSERVER_H_ + +#include <memory> + +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "net/base/net_export.h" +#include "net/log/net_log.h" + +namespace base { +class Value; +class FilePath; +class SingleThreadTaskRunner; +} // namespace base + +namespace net { + +class NetLogCaptureMode; +class URLRequestContext; + +// FileNetLogObserver watches the NetLog event stream and sends all entries to +// either a group of files in a directory (bounded mode) or to a single file +// (unbounded mode). +// +// Bounded mode: +// The events are written to a single JSON object that is split across the +// files, and the files must be stitched together once the observation period +// is over. The first file is constants.json, followed by a consumer-specified +// number of event files named event_file_<index>.json, and the last file is +// end_netlog.json. +// +// The user is able to specify an approximate maximum cumulative size for the +// netlog files and the observer overwrites old events when the maximum file +// size is reached. +// +// Unbounded mode: +// The entire JSON object is put into one file. There is no size limit to how +// large this file can grow; all events added will be written to the file. +// +// The consumer must call StartObservingBounded/StartObservingUnbounded before +// calling StopObserving, and must call each method exactly once in the lifetime +// of the observer. StartObservingBounded/StartObservingUnbounded and +// StopObserving must be called on the same thread, but there is no restriction +// on which thread is used. +class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { + public: + // |file_task_runner| indicates the task runner that should be used to post + // tasks from the main thread to the file thread. + explicit FileNetLogObserver( + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); + + ~FileNetLogObserver() override; + + // Starts observing |net_log| in bounded mode and writes output files to + // |directory|. + // May only be called once in the lifetime of the object. + // + // |max_total_size| is the approximate limit on the cumulative size of all + // netlog files. + // + // |total_num_files| sets the total number of event files that are used to + // write the events. It must be greater than 0. + // + // |constants| is an optional legend for decoding constant values used in + // the log. It should generally be a modified version of GetNetConstants(). + // If not present, the output of GetNetConstants() will be used. + // + // |url_request_context| is an optional URLRequestContext that will be used + // to pre-populate the log with information about in-progress events. If the + // context is non-NULL, StartObservingBounded() must be called on the + // context's thread. + void StartObservingBounded(NetLog* net_log, + NetLogCaptureMode capture_mode, + const base::FilePath& directory, + std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context, + size_t max_total_size, + size_t total_num_files); + + // Starts observing |net_log| in unbounded mode and writes to the file at + // |filepath|. + // May only be called once in the lifetime of the object. + // + // |constants| is an optional legend for decoding constant values used in + // the log. It should generally be a modified version of GetNetConstants(). + // If not present, the output of GetNetConstants() will be used. + // + // |url_request_context| is an optional URLRequestContext that will be used + // to pre-populate the log with information about in-progress events. If the + // context is non-NULL, StartObservingUnbounded() must be called on + // the context's thread. + void StartObservingUnbounded(NetLog* net_log, + NetLogCaptureMode capture_mode, + const base::FilePath& filepath, + std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context); + + // Stops observing net_log(). Must be called after StartObservingBounded/ + // StartObservingUnbounded. Should be called before destruction of the + // FileNetLogObserver and the NetLog, or the NetLog files will be deleted when + // the observer is destroyed. + // + // |callback| will be run on whichever thread StopObserving() was called on + // once all file writing is complete and the netlog files can be accessed + // safely. + // + // |url_request_context| is an optional argument used to add additional + // network stack state to the log. If the context is non-NULL, + // StopObserving() must be called on the context's thread. + void StopObserving(URLRequestContext* url_request_context, + const base::Closure& callback); + + // NetLog::ThreadSafeObserver + void OnAddEntry(const NetLogEntry& entry) override; + + private: + class WriteQueue; + class FileWriter; + class BoundedFileWriter; + class UnboundedFileWriter; + + // Performs tasks common to both StartObservingBounded() and + // StartObservingUnbounded(). + void StartObservingHelper(NetLog* net_log, + NetLogCaptureMode capture_mode, + std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context); + + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; + + // The |write_queue_| object is shared between the file thread and the main + // thread, and should be alive for the entirety of the observer's lifetime. + // It should be destroyed once both the observer has been destroyed and all + // tasks posted to the file thread have completed. + scoped_refptr<WriteQueue> write_queue_; + + // This is the owning reference to a file thread object. The observer is + // responsible for destroying the file thread object by posting a task from + // the main thread to the file thread to destroy the FileWriter when the + // observer is destroyed. + // + // The use of base::Unretained with |file_writer_| to post tasks to the file + // thread is safe because the FileWriter object will be alive until the + // observer's destruction. + FileWriter* file_writer_; + + DISALLOW_COPY_AND_ASSIGN(FileNetLogObserver); +}; + +} // namespace net + +#endif // NET_LOG_FILE_NET_LOG_OBSERVER_H_
diff --git a/net/log/bounded_file_net_log_observer_unittest.cc b/net/log/file_net_log_observer_unittest.cc similarity index 62% rename from net/log/bounded_file_net_log_observer_unittest.cc rename to net/log/file_net_log_observer_unittest.cc index 4e1aeb8..0f795fa 100644 --- a/net/log/bounded_file_net_log_observer_unittest.cc +++ b/net/log/file_net_log_observer_unittest.cc
@@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/log/bounded_file_net_log_observer.h" +#include "net/log/file_net_log_observer.h" #include <math.h> #include <memory> #include <string> #include <utility> +#include <vector> #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -18,6 +19,7 @@ #include "base/json/json_writer.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/threading/thread.h" #include "base/values.h" #include "net/base/test_completion_callback.h" #include "net/log/net_log_entry.h" @@ -46,162 +48,251 @@ // where event size doesn't matter. const size_t kDummyEventSize = 150; -const std::string kWinLineEnd = "\r\n"; -const std::string kLinuxLineEnd = "\n"; +const char kWinLineEnd[] = "\r\n"; +const char kLinuxLineEnd[] = "\n"; -class BoundedFileNetLogObserverTest : public testing::Test { - public: - void SetUp() override { - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - log_path_ = temp_dir_.GetPath(); - file_thread_.reset(new base::Thread("NetLog File Thread")); - file_thread_->StartWithOptions( - base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0)); - if (file_thread_->WaitUntilThreadStarted()) { - logger_ = std::unique_ptr<BoundedFileNetLogObserver>( - new BoundedFileNetLogObserver(file_thread_->task_runner())); - } +void AddEntries(FileNetLogObserver* logger, + int num_entries, + size_t entry_size) { + // Get base size of event. + const int kDummyId = 0; + std::string message = ""; + NetLogParametersCallback callback = + NetLog::StringCallback("message", &message); + NetLogSource source(NetLogSourceType::HTTP2_SESSION, kDummyId); + NetLogEntryData base_entry_data(NetLogEventType::PAC_JAVASCRIPT_ERROR, source, + NetLogEventPhase::BEGIN, + base::TimeTicks::Now(), &callback); + NetLogEntry base_entry(&base_entry_data, + NetLogCaptureMode::IncludeSocketBytes()); + std::unique_ptr<base::Value> value(base_entry.ToValue()); + std::string json; + base::JSONWriter::Write(*value, &json); + size_t base_entry_size = json.size(); + + // The maximum value of base::TimeTicks::Now() will be the maximum value of + // int64_t, and if the maximum number of digits are included, the + // |base_entry_size| could be up to 101 characters. Check that the event + // format does not include additional padding. + DCHECK_LE(base_entry_size, 101u); + + // |entry_size| should be at least as big as the largest possible base + // entry. + EXPECT_GE(entry_size, 101u); + + // |entry_size| cannot be smaller than the minimum event size. + EXPECT_GE(entry_size, base_entry_size); + + for (int i = 0; i < num_entries; i++) { + source = NetLogSource(NetLogSourceType::HTTP2_SESSION, i); + std::string id = std::to_string(i); + + // String size accounts for the number of digits in id so that all events + // are the same size. + message = std::string(entry_size - base_entry_size - id.size() + 1, 'x'); + callback = NetLog::StringCallback("message", &message); + NetLogEntryData entry_data(NetLogEventType::PAC_JAVASCRIPT_ERROR, source, + NetLogEventPhase::BEGIN, base::TimeTicks::Now(), + &callback); + NetLogEntry entry(&entry_data, NetLogCaptureMode::IncludeSocketBytes()); + logger->OnAddEntry(entry); } +} - // Concatenates all files together, including constants file and end file. - void AddAllFiles(std::string* input) { - base::ReadFileToString(log_path_.AppendASCII("constants.json"), input); - std::string to_add; - size_t input_no_events = input->length(); - for (int i = 0; i < kTotalNumFiles; i++) { - base::ReadFileToString( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"), - &to_add); - *input += to_add; - } - - // Delete the hanging comma and newline from the events array. - if (input->length() > input_no_events) { - // Remove carriage returns in case of Windows machine. - base::ReplaceSubstringsAfterOffset(input, 0, kWinLineEnd, kLinuxLineEnd); - ASSERT_GE(input->length() - input_no_events, 2u); - ASSERT_EQ(std::string(",\n"), std::string(*input, input->length() - 2)); - input->erase(input->end() - 2, input->end() - 1); - } - - base::ReadFileToString(log_path_.AppendASCII("end_netlog.json"), &to_add); +// Loads and concatenates the contents of bounded log files into a string +void ReadBoundedLogFiles(const base::FilePath& log_dir, std::string* input) { + base::ReadFileToString(log_dir.AppendASCII("constants.json"), input); + size_t input_no_events = input->length(); + std::string to_add; + for (int i = 0; base::ReadFileToString( + log_dir.AppendASCII("event_file_" + std::to_string(i) + ".json"), + &to_add); + ++i) { *input += to_add; } - // Sends |num_entries_to_add| number of events of size |entry_size| to - // |logger_|. - // - // |entry_size| must be >= 101, since the size of entries without a message, - // |base_entry_size|, is dependent on TimeTicks formatting, and - // |base_entry_size| can be up to 101 and cannot be shortened. - void AddEntries(int num_entries_to_add, size_t entry_size) { - // Get base size of event. - const int kDummyId = 0; - std::string message = ""; - NetLogParametersCallback callback = - NetLog::StringCallback("message", &message); - NetLogSource source(NetLogSourceType::HTTP2_SESSION, kDummyId); - NetLogEntryData base_entry_data(NetLogEventType::PAC_JAVASCRIPT_ERROR, - source, NetLogEventPhase::BEGIN, - base::TimeTicks::Now(), &callback); - NetLogEntry base_entry(&base_entry_data, - NetLogCaptureMode::IncludeSocketBytes()); - std::unique_ptr<base::Value> value(base_entry.ToValue()); - std::string json; - base::JSONWriter::Write(*value, &json); - size_t base_entry_size = json.size(); + // Delete the hanging comma and newline from the events array. + if (input->length() > input_no_events) { + // Remove carriage returns in case of Windows machine. + base::ReplaceSubstringsAfterOffset(input, 0, kWinLineEnd, kLinuxLineEnd); + ASSERT_GE(input->length() - input_no_events, 2u); + ASSERT_EQ(std::string(",\n"), std::string(*input, input->length() - 2)); + input->erase(input->end() - 2, input->end() - 1); + } - // The maximum value of base::TimeTicks::Now() will be the maximum value of - // int64_t, and if the maximum number of digits are included, the - // |base_entry_size| could be up to 101 characters. Check that the event - // format does not include additional padding. - DCHECK_LE(base_entry_size, 101u); + base::ReadFileToString(log_dir.AppendASCII("end_netlog.json"), &to_add); + *input += to_add; +} - // |entry_size| should be at least as big as the largest possible base - // entry. - EXPECT_GE(entry_size, 101u); +::testing::AssertionResult ParseNetLogString(const std::string& input, + std::unique_ptr<base::Value>* root, + base::ListValue** events) { + if (input.empty()) { + return ::testing::AssertionFailure() << "input is empty"; + } - // |entry_size| cannot be smaller than the minimum event size. - EXPECT_GE(entry_size, base_entry_size); + base::JSONReader reader; + *root = reader.ReadToValue(input); + if (!*root) { + return ::testing::AssertionFailure() << reader.GetErrorMessage(); + } - for (int i = 0; i < num_entries_to_add; i++) { - source = NetLogSource(NetLogSourceType::HTTP2_SESSION, i); - std::string id = std::to_string(i); + base::DictionaryValue* dict; + if (!(*root)->GetAsDictionary(&dict)) { + return ::testing::AssertionFailure() << "Not a dictionary"; + } - // String size accounts for the number of digits in id so that all events - // are the same size. - message = std::string(entry_size - base_entry_size - id.size() + 1, 'x'); - callback = NetLog::StringCallback("message", &message); - NetLogEntryData entry_data(NetLogEventType::PAC_JAVASCRIPT_ERROR, source, - NetLogEventPhase::BEGIN, - base::TimeTicks::Now(), &callback); - NetLogEntry entry(&entry_data, NetLogCaptureMode::IncludeSocketBytes()); - logger_->OnAddEntry(entry); + if (!dict->GetList("events", events)) { + return ::testing::AssertionFailure() << "No events list"; + } + + return ::testing::AssertionSuccess(); +} + +// Used for tests that are common to both bounded and unbounded modes of the +// the FileNetLogObserver. The param is true if bounded mode is used. +class FileNetLogObserverTest : public ::testing::TestWithParam<bool> { + public: + void SetUp() override { + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + bounded_log_dir_ = temp_dir_.GetPath(); + unbounded_log_path_ = bounded_log_dir_.AppendASCII("net-log.json"); + file_thread_.reset(new base::Thread("NetLog File Thread")); + file_thread_->StartWithOptions( + base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0)); + ASSERT_TRUE(file_thread_->WaitUntilThreadStarted()); + logger_.reset(new FileNetLogObserver(file_thread_->task_runner())); + } + + void StartObserving(std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context) { + bool bounded = GetParam(); + if (bounded) { + logger_->StartObservingBounded(&net_log_, NetLogCaptureMode::Default(), + bounded_log_dir_, std::move(constants), + url_request_context, kLargeFileSize, + kTotalNumFiles); + } else { + logger_->StartObservingUnbounded( + &net_log_, NetLogCaptureMode::Default(), unbounded_log_path_, + std::move(constants), url_request_context); } } - // Reads the NetLog data that was written to disk to |root|. |events| - // points at the "events" section. + ::testing::AssertionResult ReadNetLogFromDisk( + std::unique_ptr<base::Value>* root, + base::ListValue** events) { + bool bounded = GetParam(); + std::string input; + if (bounded) { + ReadBoundedLogFiles(bounded_log_dir_, &input); + } else { + base::ReadFileToString(unbounded_log_path_, &input); + } + return ParseNetLogString(input, root, events); + } + + bool LogFilesExist() { + bool bounded = GetParam(); + if (bounded) { + if (base::PathExists(bounded_log_dir_.AppendASCII("constants.json")) || + base::PathExists(bounded_log_dir_.AppendASCII("end_netlog.json"))) + return true; + for (int i = 0; i < kTotalNumFiles; i++) { + if (base::PathExists(bounded_log_dir_.AppendASCII( + "event_file_" + std::to_string(i) + ".json"))) + return true; + } + return false; + } else { + return base::PathExists(unbounded_log_path_); + } + } + + protected: + NetLog net_log_; + std::unique_ptr<base::Thread> file_thread_; + std::unique_ptr<FileNetLogObserver> logger_; + + private: + base::ScopedTempDir temp_dir_; + base::FilePath bounded_log_dir_; + base::FilePath unbounded_log_path_; +}; + +// Used for tests that are exclusive to the bounded mode of FileNetLogObserver. +class FileNetLogObserverBoundedTest : public ::testing::Test { + public: + void SetUp() override { + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + bounded_log_dir_ = temp_dir_.GetPath(); + file_thread_.reset(new base::Thread("NetLog File Thread")); + file_thread_->StartWithOptions( + base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0)); + ASSERT_TRUE(file_thread_->WaitUntilThreadStarted()); + logger_.reset(new FileNetLogObserver(file_thread_->task_runner())); + } + + void StartObserving(std::unique_ptr<base::Value> constants, + URLRequestContext* url_request_context, + int total_file_size, + int num_files) { + logger_->StartObservingBounded( + &net_log_, NetLogCaptureMode::Default(), bounded_log_dir_, + std::move(constants), url_request_context, total_file_size, num_files); + } + ::testing::AssertionResult ReadNetLogFromDisk( std::unique_ptr<base::Value>* root, base::ListValue** events) { std::string input; - AddAllFiles(&input); - if (input.empty()) { - return ::testing::AssertionFailure() << "input is empty"; - } + ReadBoundedLogFiles(bounded_log_dir_, &input); + return ParseNetLogString(input, root, events); + } - base::JSONReader reader; - *root = reader.ReadToValue(input); - if (!*root) { - return ::testing::AssertionFailure() << reader.GetErrorMessage(); - } + base::FilePath GetEventFilePath(int index) const { + return bounded_log_dir_.AppendASCII("event_file_" + std::to_string(index) + + ".json"); + } - base::DictionaryValue* dict; - if (!(*root)->GetAsDictionary(&dict)) { - return ::testing::AssertionFailure() << "Not a dictionary"; - } - - if (!dict->GetList("events", events)) { - return ::testing::AssertionFailure() << "No events list"; - } - - return ::testing::AssertionSuccess(); + static int64_t GetFileSize(const base::FilePath& path) { + int64_t file_size; + EXPECT_TRUE(base::GetFileSize(path, &file_size)); + return file_size; } protected: - base::FilePath log_path_; NetLog net_log_; std::unique_ptr<base::Thread> file_thread_; - std::unique_ptr<BoundedFileNetLogObserver> logger_; + std::unique_ptr<FileNetLogObserver> logger_; private: base::ScopedTempDir temp_dir_; + base::FilePath bounded_log_dir_; }; -TEST_F(BoundedFileNetLogObserverTest, ObserverDestroyedWithoutStopObserving) { - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); +// Instantiates each FileNetLogObserverTest to use bounded and unbounded modes. +INSTANTIATE_TEST_CASE_P(, + FileNetLogObserverTest, + ::testing::Values(true, false)); + +TEST_P(FileNetLogObserverTest, ObserverDestroyedWithoutStopObserving) { + StartObserving(nullptr, nullptr); // Send dummy event - AddEntries(1, kDummyEventSize); + AddEntries(logger_.get(), 1, kDummyEventSize); logger_.reset(); file_thread_.reset(); - ASSERT_FALSE(base::PathExists(log_path_.AppendASCII("constants.json"))); - ASSERT_FALSE(base::PathExists(log_path_.AppendASCII("end_netlog.json"))); - for (int i = 0; i < kTotalNumFiles; i++) { - ASSERT_FALSE(base::PathExists( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"))); - } + ASSERT_FALSE(LogFilesExist()); } -TEST_F(BoundedFileNetLogObserverTest, GeneratesValidJSONForNoEvents) { +TEST_P(FileNetLogObserverTest, GeneratesValidJSONWithNoEvents) { TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr); + logger_->StopObserving(nullptr, closure.closure()); closure.WaitForResult(); @@ -220,44 +311,13 @@ ASSERT_TRUE(dict->GetDictionary("constants", &constants)); } -// Checks that capture_mode_ defaults correctly when set_capture_mode is not -// called, and that |capture_mode_| is changed when set_capture_mode is called. -TEST_F(BoundedFileNetLogObserverTest, SetsCaptureMode) { - TestClosure default_closure; - - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); - EXPECT_EQ(NetLogCaptureMode::Default(), logger_->capture_mode()); - logger_->StopObserving(nullptr, default_closure.closure()); - - default_closure.WaitForResult(); - - TestClosure new_capture_mode_closure; - logger_ = std::unique_ptr<BoundedFileNetLogObserver>( - new BoundedFileNetLogObserver(file_thread_->task_runner())); - - logger_->set_capture_mode(NetLogCaptureMode::IncludeCookiesAndCredentials()); - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); - EXPECT_EQ(NetLogCaptureMode::IncludeCookiesAndCredentials(), - logger_->capture_mode()); - logger_->StopObserving(nullptr, new_capture_mode_closure.closure()); - - new_capture_mode_closure.WaitForResult(); - - std::string input; - AddAllFiles(&input); - ASSERT_FALSE(input.empty()); -} - -TEST_F(BoundedFileNetLogObserverTest, GeneratesValidJSONWithOneEvent) { +TEST_P(FileNetLogObserverTest, GeneratesValidJSONWithOneEvent) { TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr); // Send dummy event. - AddEntries(1, kDummyEventSize); + AddEntries(logger_.get(), 1, kDummyEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -271,14 +331,14 @@ ASSERT_EQ(1u, events->GetSize()); } -TEST_F(BoundedFileNetLogObserverTest, GeneratesValidJSONWithMultipleEvents) { - const int kTotalFileSize = 250000; +TEST_P(FileNetLogObserverTest, CustomConstants) { TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + const char kConstantString[] = "awesome constant"; + std::unique_ptr<base::Value> constants( + new base::StringValue(kConstantString)); - AddEntries(2, kDummyEventSize); + StartObserving(std::move(constants), nullptr); logger_->StopObserving(nullptr, closure.closure()); @@ -288,13 +348,133 @@ base::ListValue* events; ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); - // Check that 2 events are written. - ASSERT_EQ(2u, events->GetSize()); + // Check that custom constant was correctly printed. + base::DictionaryValue* dict; + ASSERT_TRUE(root->GetAsDictionary(&dict)); + std::string constants_string; + ASSERT_TRUE(dict->GetString("constants", &constants_string)); + ASSERT_EQ(kConstantString, constants_string); +} + +TEST_P(FileNetLogObserverTest, GeneratesValidJSONWithContext) { + TestClosure closure; + + StartObserving(nullptr, nullptr); + + // Create unique context. + TestURLRequestContext context(true); + context.set_net_log(&net_log_); + const int kDummyParam = 75; + std::unique_ptr<HttpNetworkSession::Params> params( + new HttpNetworkSession::Params); + params->quic_idle_connection_timeout_seconds = kDummyParam; + context.set_http_network_session_params(std::move(params)); + context.Init(); + + logger_->StopObserving(&context, closure.closure()); + + closure.WaitForResult(); + + std::unique_ptr<base::Value> root; + base::ListValue* events; + ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); + + // Check that no events were written. + ASSERT_EQ(0u, events->GetSize()); + + // Make sure additional information is present and validate it. + base::DictionaryValue* dict; + ASSERT_TRUE(root->GetAsDictionary(&dict)); + base::DictionaryValue* tab_info; + base::DictionaryValue* quic_info; + ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); + ASSERT_TRUE(tab_info->GetDictionary("quicInfo", &quic_info)); + base::Value* timeout_value = nullptr; + int timeout; + ASSERT_TRUE( + quic_info->Get("idle_connection_timeout_seconds", &timeout_value)); + ASSERT_TRUE(timeout_value->GetAsInteger(&timeout)); + ASSERT_EQ(timeout, kDummyParam); +} + +TEST_P(FileNetLogObserverTest, GeneratesValidJSONWithContextWithActiveRequest) { + TestClosure closure; + + // Create context, start a request. + TestURLRequestContext context(true); + context.set_net_log(&net_log_); + context.Init(); + TestDelegate delegate; + delegate.set_quit_on_complete(false); + + // URL doesn't matter. Requests can't fail synchronously. + std::unique_ptr<URLRequest> request( + context.CreateRequest(GURL("blah:blah"), IDLE, &delegate)); + request->Start(); + + StartObserving(nullptr, &context); + + logger_->StopObserving(&context, closure.closure()); + + closure.WaitForResult(); + + std::unique_ptr<base::Value> root; + base::ListValue* events; + ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); + + // Check that 1 event was written + ASSERT_EQ(1u, events->GetSize()); + + // Make sure additional information is present, but don't validate it. + base::DictionaryValue* dict; + ASSERT_TRUE(root->GetAsDictionary(&dict)); + base::DictionaryValue* tab_info; + ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); +} + +// Adds events concurrently from several different threads. The exact order of +// events seen by this test is non-deterministic. +TEST_P(FileNetLogObserverTest, AddEventsFromMultipleThreads) { + const size_t kNumThreads = 10; + std::vector<std::unique_ptr<base::Thread>> threads(kNumThreads); + // Start all the threads. Waiting for them to start is to hopefuly improve + // the odds of hitting interesting races once events start being added. + for (size_t i = 0; i < threads.size(); ++i) { + threads[i] = base::MakeUnique<base::Thread>( + base::StringPrintf("WorkerThread%i", static_cast<int>(i))); + threads[i]->Start(); + threads[i]->WaitUntilThreadStarted(); + } + + StartObserving(nullptr, nullptr); + + const size_t kNumEventsAddedPerThread = 200; + + // Add events in parallel from all the threads. + for (size_t i = 0; i < kNumThreads; ++i) { + threads[i]->task_runner()->PostTask( + FROM_HERE, base::Bind(&AddEntries, base::Unretained(logger_.get()), + kNumEventsAddedPerThread, kDummyEventSize)); + } + + // Join all the threads. + threads.clear(); + + // Stop observing. + TestClosure closure; + logger_->StopObserving(nullptr, closure.closure()); + closure.WaitForResult(); + + // Check that the expected number of events were written to disk. + std::unique_ptr<base::Value> root; + base::ListValue* events; + ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); + ASSERT_EQ(kNumEventsAddedPerThread * kNumThreads, events->GetSize()); } // Sends enough events to the observer to completely fill one file, but not // write any events to an additional file. Checks the file bounds. -TEST_F(BoundedFileNetLogObserverTest, EqualToOneFile) { +TEST_F(FileNetLogObserverBoundedTest, EqualToOneFile) { // The total size of the events is equal to the size of one file. // |kNumEvents| * |kEventSize| = |kTotalFileSize| / |kTotalNumEvents| const int kTotalFileSize = 5000; @@ -302,10 +482,9 @@ const int kEventSize = 250; TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); closure.WaitForResult(); @@ -329,23 +508,17 @@ ASSERT_EQ(kNumEvents - 1, id); // Check that events have been written to the first file. - base::ScopedFILE first_file(base::OpenFile( - log_path_.AppendASCII("event_file_" + std::to_string(0) + ".json"), - "rb")); - ASSERT_TRUE(first_file.get()); - fseek(first_file.get(), 0, SEEK_END); - ASSERT_TRUE(ftell(first_file.get())); + ASSERT_GT(GetFileSize(GetEventFilePath(0)), 0); // Check that all event files except the first do not exist. for (int i = 1; i < kTotalNumFiles; i++) { - ASSERT_FALSE(base::PathExists( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"))); + ASSERT_FALSE(base::PathExists(GetEventFilePath(i))); } } // Sends enough events to fill one file, and partially fill a second file. // Checks the file bounds and writing to a new file. -TEST_F(BoundedFileNetLogObserverTest, OneEventOverOneFile) { +TEST_F(FileNetLogObserverBoundedTest, OneEventOverOneFile) { // The total size of the events is greater than the size of one file, and // less than the size of two files. The total size of all events except one // is equal to the size of one file, so the last event will be the only event @@ -356,10 +529,9 @@ const int kEventSize = 200; TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -385,13 +557,12 @@ // Check that all event files except the first two do not exist. for (int i = 2; i < kTotalNumFiles; i++) { - ASSERT_FALSE(base::PathExists( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"))); + ASSERT_FALSE(base::PathExists(GetEventFilePath(i))); } } // Sends enough events to the observer to completely fill two files. -TEST_F(BoundedFileNetLogObserverTest, EqualToTwoFiles) { +TEST_F(FileNetLogObserverBoundedTest, EqualToTwoFiles) { // The total size of the events is equal to the total size of two files. // |kNumEvents| * |kEventSize| = 2 * |kTotalFileSize| / |kTotalNumEvents| const int kTotalFileSize = 6000; @@ -399,10 +570,9 @@ const int kEventSize = 200; TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -430,25 +600,20 @@ for (int i = 0; i < (kNumEvents * kEventSize) / ((kTotalFileSize - 1) / kTotalNumFiles + 1); i++) { - base::ScopedFILE file_to_test(base::OpenFile( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"), - "rb")); - ASSERT_TRUE(file_to_test.get()); - fseek(file_to_test.get(), 0, SEEK_END); - ASSERT_GE(ftell(file_to_test.get()), kTotalFileSize / kTotalNumFiles); + ASSERT_GE(GetFileSize(GetEventFilePath(i)), + static_cast<int64_t>(kTotalFileSize / kTotalNumFiles)); } // Check that all event files except the first two do not exist. for (int i = 2; i < kTotalNumFiles; i++) { - ASSERT_FALSE(base::PathExists( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"))); + ASSERT_FALSE(base::PathExists(GetEventFilePath(i))); } } // Sends exactly enough events to the observer to completely fill all files, // so that all events fit into the event files and no files need to be // overwritten. -TEST_F(BoundedFileNetLogObserverTest, FillAllFilesNoOverwriting) { +TEST_F(FileNetLogObserverBoundedTest, FillAllFilesNoOverwriting) { // The total size of events is equal to the total size of all files. // |kEventSize| * |kNumEvents| = |kTotalFileSize| const int kTotalFileSize = 10000; @@ -457,10 +622,9 @@ const int kNumEvents = kTotalNumFiles * ((kFileSize - 1) / kEventSize + 1); TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -486,18 +650,14 @@ // Check that all the event files are full. for (int i = 0; i < kTotalNumFiles; i++) { - base::ScopedFILE file_to_test(base::OpenFile( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"), - "rb")); - ASSERT_TRUE(file_to_test.get()); - fseek(file_to_test.get(), 0, SEEK_END); - ASSERT_GE(ftell(file_to_test.get()), kTotalFileSize / kTotalNumFiles); + ASSERT_GE(GetFileSize(GetEventFilePath(i)), + static_cast<int64_t>(kTotalFileSize / kTotalNumFiles)); } } // Sends more events to the observer than will fill the WriteQueue, forcing the // queue to drop an event. Checks that the queue drops the oldest event. -TEST_F(BoundedFileNetLogObserverTest, DropOldEventsFromWriteQueue) { +TEST_F(FileNetLogObserverBoundedTest, DropOldEventsFromWriteQueue) { // The total size of events is greater than the WriteQueue's memory limit, so // the oldest event must be dropped from the queue and not written to any // file. @@ -508,10 +668,9 @@ const int kFileSize = kTotalFileSize / kTotalNumFiles; TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -549,7 +708,7 @@ // Sends twice as many events as will fill all files to the observer, so that // all of the event files will be filled twice, and every file will be // overwritten. -TEST_F(BoundedFileNetLogObserverTest, OverwriteAllFiles) { +TEST_F(FileNetLogObserverBoundedTest, OverwriteAllFiles) { // The total size of the events is much greater than twice the number of // events that can fit in the event files, to make sure that the extra events // are written to a file, not just dropped from the queue. @@ -560,10 +719,9 @@ const int kFileSize = kTotalFileSize / kTotalNumFiles; TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -612,19 +770,15 @@ // Check that there are events written to all files. for (int i = 0; i < kTotalNumFiles; i++) { - base::ScopedFILE file_to_test(base::OpenFile( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"), - "rb")); - ASSERT_TRUE(file_to_test.get()); - fseek(file_to_test.get(), 0, SEEK_END); - ASSERT_GE(ftell(file_to_test.get()), kEventSize); + ASSERT_GE(GetFileSize(GetEventFilePath(i)), + static_cast<int64_t>(kEventSize)); } } // Sends enough events to the observer to fill all event files, plus overwrite // some files, without overwriting all of them. Checks that the FileWriter // overwrites the file with the oldest events. -TEST_F(BoundedFileNetLogObserverTest, PartiallyOverwriteFiles) { +TEST_F(FileNetLogObserverBoundedTest, PartiallyOverwriteFiles) { // The number of events sent to the observer is greater than the number of // events that can fit into the event files, but the events can fit in less // than twice the number of event files, so not every file will need to be @@ -637,10 +791,9 @@ const int kFileSize = kTotalFileSize / kTotalNumFiles; TestClosure closure; - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kTotalFileSize, kTotalNumFiles); + StartObserving(nullptr, nullptr, kTotalFileSize, kTotalNumFiles); - AddEntries(kNumEvents, kEventSize); + AddEntries(logger_.get(), kNumEvents, kEventSize); logger_->StopObserving(nullptr, closure.closure()); @@ -678,162 +831,11 @@ // Check that there are events written to all files. for (int i = 0; i < kTotalNumFiles; i++) { - base::ScopedFILE file_to_test(base::OpenFile( - log_path_.AppendASCII("event_file_" + std::to_string(i) + ".json"), - "rb")); - ASSERT_TRUE(file_to_test.get()); - fseek(file_to_test.get(), 0, SEEK_END); - ASSERT_GE(ftell(file_to_test.get()), kEventSize); + ASSERT_GE(GetFileSize(GetEventFilePath(i)), + static_cast<int64_t>(kEventSize)); } } -TEST_F(BoundedFileNetLogObserverTest, CustomConstants) { - TestClosure closure; - - const char kConstantString[] = "awesome constant"; - std::unique_ptr<base::Value> constants( - new base::StringValue(kConstantString)); - - logger_->StartObserving(&net_log_, log_path_, constants.get(), nullptr, - kLargeFileSize, kTotalNumFiles); - - logger_->StopObserving(nullptr, closure.closure()); - - closure.WaitForResult(); - - std::unique_ptr<base::Value> root; - base::ListValue* events; - ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); - - // Check that custom constant was correctly printed. - base::DictionaryValue* dict; - ASSERT_TRUE(root->GetAsDictionary(&dict)); - std::string constants_string; - ASSERT_TRUE(dict->GetString("constants", &constants_string)); - ASSERT_EQ(kConstantString, constants_string); -} - -TEST_F(BoundedFileNetLogObserverTest, GeneratesValidJSONWithContext) { - TestClosure closure; - - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); - - // Create unique context. - TestURLRequestContext context(true); - context.set_net_log(&net_log_); - const int kDummyParam = 75; - std::unique_ptr<HttpNetworkSession::Params> params( - new HttpNetworkSession::Params); - params->quic_idle_connection_timeout_seconds = kDummyParam; - context.set_http_network_session_params(std::move(params)); - context.Init(); - - logger_->StopObserving(&context, closure.closure()); - - closure.WaitForResult(); - - std::unique_ptr<base::Value> root; - base::ListValue* events; - ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); - - // Check that no events were written. - ASSERT_EQ(0u, events->GetSize()); - - // Make sure additional information is present and validate it. - base::DictionaryValue* dict; - ASSERT_TRUE(root->GetAsDictionary(&dict)); - base::DictionaryValue* tab_info; - base::DictionaryValue* quic_info; - ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); - ASSERT_TRUE(tab_info->GetDictionary("quicInfo", &quic_info)); - base::Value* timeout_value = nullptr; - int timeout; - ASSERT_TRUE( - quic_info->Get("idle_connection_timeout_seconds", &timeout_value)); - ASSERT_TRUE(timeout_value->GetAsInteger(&timeout)); - ASSERT_EQ(timeout, kDummyParam); -} - -TEST_F(BoundedFileNetLogObserverTest, - GeneratesValidJSONWithContextWithActiveRequest) { - TestClosure closure; - - // Create context, start a request. - TestURLRequestContext context(true); - context.set_net_log(&net_log_); - context.Init(); - TestDelegate delegate; - delegate.set_quit_on_complete(false); - - // URL doesn't matter. Requests can't fail synchronously. - std::unique_ptr<URLRequest> request( - context.CreateRequest(GURL("blah:blah"), IDLE, &delegate)); - request->Start(); - - logger_->StartObserving(&net_log_, log_path_, nullptr, &context, - kLargeFileSize, kTotalNumFiles); - - logger_->StopObserving(&context, closure.closure()); - - closure.WaitForResult(); - - std::unique_ptr<base::Value> root; - base::ListValue* events; - ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); - - // Check that 1 event was written - ASSERT_EQ(1u, events->GetSize()); - - // Make sure additional information is present, but don't validate it. - base::DictionaryValue* dict; - ASSERT_TRUE(root->GetAsDictionary(&dict)); - base::DictionaryValue* tab_info; - ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); -} - -// Adds events concurrently from several different threads. The exact order of -// events seen by this test is non-deterministic. -TEST_F(BoundedFileNetLogObserverTest, AddEventsFromMultipleThreads) { - const size_t kNumThreads = 10; - std::vector<std::unique_ptr<base::Thread>> threads(kNumThreads); - // Start all the threads. Waiting for them to start is to hopefuly improve - // the odds of hitting interesting races once events start being added. - for (size_t i = 0; i < threads.size(); ++i) { - threads[i] = base::MakeUnique<base::Thread>( - base::StringPrintf("WorkerThread%i", static_cast<int>(i))); - threads[i]->Start(); - threads[i]->WaitUntilThreadStarted(); - } - - logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, - kLargeFileSize, kTotalNumFiles); - - const size_t kNumEventsAddedPerThread = 200; - - // Add events in parallel from all the threads. - for (size_t i = 0; i < kNumThreads; ++i) { - threads[i]->task_runner()->PostTask( - FROM_HERE, base::Bind(&BoundedFileNetLogObserverTest::AddEntries, - base::Unretained(this), kNumEventsAddedPerThread, - kDummyEventSize)); - } - - // Join all the threads. - threads.clear(); - - // Stop observing. - TestClosure closure; - logger_->StopObserving(nullptr, closure.closure()); - closure.WaitForResult(); - - // Check that the expected number of events were written to disk. - std::unique_ptr<base::Value> root; - base::ListValue* events; - ASSERT_TRUE(ReadNetLogFromDisk(&root, &events)); - ASSERT_EQ(kNumEventsAddedPerThread * kNumThreads, events->GetSize()); -} - } // namespace } // namespace net
diff --git a/net/net.gypi b/net/net.gypi index f104a94..029f2264 100644 --- a/net/net.gypi +++ b/net/net.gypi
@@ -576,8 +576,8 @@ 'disk_cache/simple/simple_entry_operation.h', 'disk_cache/simple/simple_experiment.cc', 'disk_cache/simple/simple_experiment.h', - 'log/bounded_file_net_log_observer.cc', - 'log/bounded_file_net_log_observer.h', + 'log/file_net_log_observer.cc', + 'log/file_net_log_observer.h', 'log/net_log_util.cc', 'log/net_log_util.h', 'log/trace_net_log_observer.cc', @@ -838,6 +838,8 @@ 'http2/hpack/decoder/hpack_string_decoder_listener.h', 'http2/hpack/decoder/hpack_varint_decoder.cc', 'http2/hpack/decoder/hpack_varint_decoder.h', + 'http2/hpack/hpack_string.cc', + 'http2/hpack/hpack_string.h', 'http2/hpack/http2_hpack_constants.cc', 'http2/hpack/http2_hpack_constants.h', 'http2/hpack/huffman/http2_hpack_huffman_decoder.cc', @@ -1215,6 +1217,7 @@ 'quic/platform/api/quic_ip_address.h', 'quic/platform/api/quic_mutex.cc', 'quic/platform/api/quic_mutex.h', + 'quic/platform/api/quic_reference_counted.h', 'quic/platform/api/quic_socket_address.cc', 'quic/platform/api/quic_socket_address.h', 'quic/platform/impl/quic_chromium_clock.cc', @@ -1223,6 +1226,7 @@ 'quic/platform/impl/quic_ip_address_impl.h', 'quic/platform/impl/quic_mutex_impl.cc', 'quic/platform/impl/quic_mutex_impl.h', + 'quic/platform/impl/quic_reference_counted_impl.h', 'quic/platform/impl/quic_socket_address_impl.cc', 'quic/platform/impl/quic_socket_address_impl.h', 'quic/quartc/quartc_alarm_factory.cc', @@ -1793,6 +1797,7 @@ 'http2/hpack/decoder/hpack_string_collector.h', 'http2/hpack/decoder/hpack_string_decoder_test.cc', 'http2/hpack/decoder/hpack_varint_decoder_test.cc', + 'http2/hpack/hpack_string_test.cc', 'http2/hpack/http2_hpack_constants_test.cc', 'http2/hpack/huffman/http2_hpack_huffman_decoder_test.cc', 'http2/hpack/tools/hpack_block_builder.cc', @@ -1814,7 +1819,7 @@ 'http2/tools/http2_random.h', 'http2/tools/random_decoder_test.cc', 'http2/tools/random_decoder_test.h', - 'log/bounded_file_net_log_observer_unittest.cc', + 'log/file_net_log_observer_unittest.cc', 'log/net_log_capture_mode_unittest.cc', 'log/net_log_unittest.cc', 'log/net_log_util_unittest.cc', @@ -1959,6 +1964,7 @@ 'quic/core/quic_versions_test.cc', 'quic/core/quic_write_blocked_list_test.cc', 'quic/core/spdy_utils_test.cc', + 'quic/platform/api/quic_reference_counted_test.cc', 'quic/platform/impl/quic_chromium_clock_test.cc', 'quic/quartc/quartc_alarm_factory_test.cc', 'quic/quartc/quartc_session_test.cc',
diff --git a/net/quic/chromium/crypto/proof_source_chromium.cc b/net/quic/chromium/crypto/proof_source_chromium.cc index 8e2c46a..dd8ce1f8 100644 --- a/net/quic/chromium/crypto/proof_source_chromium.cc +++ b/net/quic/chromium/crypto/proof_source_chromium.cc
@@ -83,7 +83,7 @@ QuicVersion quic_version, base::StringPiece chlo_hash, const QuicTagVector& /* connection_options */, - scoped_refptr<ProofSource::Chain>* out_chain, + QuicReferenceCountedPointer<ProofSource::Chain>* out_chain, QuicCryptoProof* proof) { DCHECK(proof != nullptr); DCHECK(private_key_.get()) << " this: " << this; @@ -142,7 +142,7 @@ std::unique_ptr<Callback> callback) { // As a transitional implementation, just call the synchronous version of // GetProof, then invoke the callback with the results and destroy it. - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; string signature; string leaf_cert_sct; QuicCryptoProof out_proof;
diff --git a/net/quic/chromium/crypto/proof_source_chromium.h b/net/quic/chromium/crypto/proof_source_chromium.h index 5d50cc5..95b892d 100644 --- a/net/quic/chromium/crypto/proof_source_chromium.h +++ b/net/quic/chromium/crypto/proof_source_chromium.h
@@ -39,7 +39,7 @@ QuicVersion quic_version, base::StringPiece chlo_hash, const QuicTagVector& connection_options, - scoped_refptr<ProofSource::Chain>* out_chain, + QuicReferenceCountedPointer<ProofSource::Chain>* out_chain, QuicCryptoProof* proof) override; void GetProof(const QuicSocketAddress& server_ip, @@ -52,7 +52,7 @@ private: std::unique_ptr<crypto::RSAPrivateKey> private_key_; - scoped_refptr<ProofSource::Chain> chain_; + QuicReferenceCountedPointer<ProofSource::Chain> chain_; std::string signed_certificate_timestamp_; DISALLOW_COPY_AND_ASSIGN(ProofSourceChromium);
diff --git a/net/quic/chromium/crypto/proof_test_chromium.cc b/net/quic/chromium/crypto/proof_test_chromium.cc index 4d15e13a..023a433 100644 --- a/net/quic/chromium/crypto/proof_test_chromium.cc +++ b/net/quic/chromium/crypto/proof_test_chromium.cc
@@ -93,12 +93,12 @@ public: explicit TestCallback(bool* called, bool* ok, - scoped_refptr<ProofSource::Chain>* chain, + QuicReferenceCountedPointer<ProofSource::Chain>* chain, QuicCryptoProof* proof) : called_(called), ok_(ok), chain_(chain), proof_(proof) {} void Run(bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const QuicCryptoProof& proof, std::unique_ptr<ProofSource::Details> /* details */) override { *ok_ = ok; @@ -110,7 +110,7 @@ private: bool* called_; bool* ok_; - scoped_refptr<ProofSource::Chain>* chain_; + QuicReferenceCountedPointer<ProofSource::Chain>* chain_; QuicCryptoProof* proof_; }; @@ -135,8 +135,8 @@ const string second_chlo_hash = "first chlo hash bytes"; const QuicVersion quic_version = GetParam(); - scoped_refptr<ProofSource::Chain> chain; - scoped_refptr<ProofSource::Chain> first_chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> first_chain; string error_details; QuicCryptoProof proof, first_proof; QuicSocketAddress server_addr; @@ -187,7 +187,7 @@ QuicSocketAddress server_addr; // Call synchronous version - scoped_refptr<ProofSource::Chain> expected_chain; + QuicReferenceCountedPointer<ProofSource::Chain> expected_chain; QuicCryptoProof expected_proof; ASSERT_TRUE(source->GetProof(server_addr, hostname, server_config, quic_version, first_chlo_hash, QuicTagVector(), @@ -196,7 +196,7 @@ // Call asynchronous version and compare results bool called = false; bool ok; - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; QuicCryptoProof proof; std::unique_ptr<ProofSource::Callback> cb( new TestCallback(&called, &ok, &chain, &proof)); @@ -216,7 +216,7 @@ const string server_config = "server config bytes"; const string hostname = "test.example.com"; const string chlo_hash = "proof nonce bytes"; - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; string error_details; QuicCryptoProof proof; QuicSocketAddress server_addr;
diff --git a/net/quic/chromium/quic_chromium_client_stream.cc b/net/quic/chromium/quic_chromium_client_stream.cc index 2cff4b807..b533b49 100644 --- a/net/quic/chromium/quic_chromium_client_stream.cc +++ b/net/quic/chromium/quic_chromium_client_stream.cc
@@ -123,7 +123,8 @@ size_t QuicChromiumClientStream::WriteHeaders( SpdyHeaderBlock header_block, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { if (!session()->IsCryptoHandshakeConfirmed()) { auto entry = header_block.find(":method"); DCHECK(entry != header_block.end());
diff --git a/net/quic/chromium/quic_chromium_client_stream.h b/net/quic/chromium/quic_chromium_client_stream.h index 4cf4cd2..7b41e6790 100644 --- a/net/quic/chromium/quic_chromium_client_stream.h +++ b/net/quic/chromium/quic_chromium_client_stream.h
@@ -78,10 +78,10 @@ void OnDataAvailable() override; void OnClose() override; void OnCanWrite() override; - size_t WriteHeaders( - SpdyHeaderBlock header_block, - bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) override; + size_t WriteHeaders(SpdyHeaderBlock header_block, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) override; SpdyPriority priority() const override; // While the server's set_priority shouldn't be called externally, the creator
diff --git a/net/quic/chromium/quic_chromium_client_stream_test.cc b/net/quic/chromium/quic_chromium_client_stream_test.cc index 997e955..aa50e05 100644 --- a/net/quic/chromium/quic_chromium_client_stream_test.cc +++ b/net/quic/chromium/quic_chromium_client_stream_test.cc
@@ -79,13 +79,14 @@ MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); MOCK_METHOD1(CreateOutgoingDynamicStream, QuicChromiumClientStream*(SpdyPriority priority)); - MOCK_METHOD6(WritevData, - QuicConsumedData(QuicStream* stream, - QuicStreamId id, - QuicIOVector data, - QuicStreamOffset offset, - bool fin, - scoped_refptr<QuicAckListenerInterface>)); + MOCK_METHOD6( + WritevData, + QuicConsumedData(QuicStream* stream, + QuicStreamId id, + QuicIOVector data, + QuicStreamOffset offset, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface>)); MOCK_METHOD3(SendRstStream, void(QuicStreamId stream_id, QuicRstStreamErrorCode error, @@ -106,22 +107,23 @@ MOCK_METHOD0(IsCryptoHandshakeConfirmed, bool()); // Methods taking non-copyable types like SpdyHeaderBlock by value cannot be // mocked directly. - size_t WriteHeaders( - QuicStreamId id, - SpdyHeaderBlock headers, - bool fin, - SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) override { + size_t WriteHeaders(QuicStreamId id, + SpdyHeaderBlock headers, + bool fin, + SpdyPriority priority, + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) override { return WriteHeadersMock(id, headers, fin, priority, std::move(ack_notifier_delegate)); } - MOCK_METHOD5(WriteHeadersMock, - size_t(QuicStreamId id, - const SpdyHeaderBlock& headers, - bool fin, - SpdyPriority priority, - const scoped_refptr<QuicAckListenerInterface>& - ack_notifier_delegate)); + MOCK_METHOD5( + WriteHeadersMock, + size_t(QuicStreamId id, + const SpdyHeaderBlock& headers, + bool fin, + SpdyPriority priority, + const QuicReferenceCountedPointer<QuicAckListenerInterface>& + ack_notifier_delegate)); MOCK_METHOD1(OnHeadersHeadOfLineBlocking, void(QuicTime::Delta delta)); using QuicSession::ActivateStream;
diff --git a/net/quic/core/crypto/crypto_handshake.h b/net/quic/core/crypto/crypto_handshake.h index 9606fe4..c985e5bb 100644 --- a/net/quic/core/crypto/crypto_handshake.h +++ b/net/quic/core/crypto/crypto_handshake.h
@@ -100,7 +100,7 @@ // Parameters negotiated by the crypto handshake. struct QUIC_EXPORT_PRIVATE QuicCryptoNegotiatedParameters - : public base::RefCounted<QuicCryptoNegotiatedParameters> { + : public QuicReferenceCounted { // Initializes the members to 0 or empty values. QuicCryptoNegotiatedParameters(); @@ -150,9 +150,8 @@ // by sending CSCT tag with an empty value in client hello. bool sct_supported_by_client; - private: - friend class base::RefCounted<QuicCryptoNegotiatedParameters>; - virtual ~QuicCryptoNegotiatedParameters(); + protected: + ~QuicCryptoNegotiatedParameters() override; }; // QuicCryptoConfig contains common configuration between clients and servers.
diff --git a/net/quic/core/crypto/crypto_server_test.cc b/net/quic/core/crypto/crypto_server_test.cc index 8c1c688..ccdb50a9 100644 --- a/net/quic/core/crypto/crypto_server_test.cc +++ b/net/quic/core/crypto/crypto_server_test.cc
@@ -180,8 +180,8 @@ ASSERT_TRUE(server_config_->GetStringPiece(kSCID, &scid)); scid_hex_ = "#" + QuicUtils::HexEncode(scid); - signed_config_ = - scoped_refptr<QuicSignedServerConfig>(new QuicSignedServerConfig()); + signed_config_ = QuicReferenceCountedPointer<QuicSignedServerConfig>( + new QuicSignedServerConfig()); DCHECK(signed_config_->chain.get() == nullptr); } @@ -200,7 +200,7 @@ *called_ = false; } - void Run(scoped_refptr<Result> result, + void Run(QuicReferenceCountedPointer<Result> result, std::unique_ptr<ProofSource::Details> /* details */) override { ASSERT_FALSE(*called_); test_->ProcessValidationResult(std::move(result), should_succeed_, @@ -263,11 +263,12 @@ class ProcessCallback : public ProcessClientHelloResultCallback { public: - ProcessCallback(scoped_refptr<ValidateCallback::Result> result, - bool should_succeed, - const char* error_substr, - bool* called, - CryptoHandshakeMessage* out) + ProcessCallback( + QuicReferenceCountedPointer<ValidateCallback::Result> result, + bool should_succeed, + const char* error_substr, + bool* called, + CryptoHandshakeMessage* out) : result_(std::move(result)), should_succeed_(should_succeed), error_substr_(error_substr), @@ -300,16 +301,17 @@ } private: - const scoped_refptr<ValidateCallback::Result> result_; + const QuicReferenceCountedPointer<ValidateCallback::Result> result_; const bool should_succeed_; const char* const error_substr_; bool* called_; CryptoHandshakeMessage* out_; }; - void ProcessValidationResult(scoped_refptr<ValidateCallback::Result> result, - bool should_succeed, - const char* error_substr) { + void ProcessValidationResult( + QuicReferenceCountedPointer<ValidateCallback::Result> result, + bool should_succeed, + const char* error_substr) { QuicSocketAddress server_address; QuicConnectionId server_designated_connection_id = rand_for_id_generation_.RandUint64(); @@ -398,8 +400,8 @@ QuicCryptoServerConfig config_; QuicCompressedCertsCache compressed_certs_cache_; QuicCryptoServerConfig::ConfigOptions config_options_; - scoped_refptr<QuicCryptoNegotiatedParameters> params_; - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; CryptoHandshakeMessage out_; uint8_t orbit_[kOrbitSize]; bool use_stateless_rejects_;
diff --git a/net/quic/core/crypto/proof_source.h b/net/quic/core/crypto/proof_source.h index 88bf2d3..8db52f7 100644 --- a/net/quic/core/crypto/proof_source.h +++ b/net/quic/core/crypto/proof_source.h
@@ -9,10 +9,10 @@ #include <string> #include <vector> -#include "base/memory/ref_counted.h" #include "net/quic/core/crypto/quic_crypto_proof.h" #include "net/quic/core/quic_packets.h" #include "net/quic/platform/api/quic_export.h" +#include "net/quic/platform/api/quic_reference_counted.h" #include "net/quic/platform/api/quic_socket_address.h" namespace net { @@ -23,16 +23,15 @@ public: // Chain is a reference-counted wrapper for a std::vector of std::stringified // certificates. - struct QUIC_EXPORT_PRIVATE Chain : public base::RefCounted<Chain> { + struct QUIC_EXPORT_PRIVATE Chain : public QuicReferenceCounted { explicit Chain(const std::vector<std::string>& certs); const std::vector<std::string> certs; + protected: + ~Chain() override; + private: - friend class base::RefCounted<Chain>; - - virtual ~Chain(); - DISALLOW_COPY_AND_ASSIGN(Chain); }; @@ -65,7 +64,7 @@ // any, gathered during the operation of GetProof. If no stats are // available, this will be nullptr. virtual void Run(bool ok, - const scoped_refptr<Chain>& chain, + const QuicReferenceCountedPointer<Chain>& chain, const QuicCryptoProof& proof, std::unique_ptr<Details> details) = 0; @@ -109,7 +108,7 @@ QuicVersion quic_version, base::StringPiece chlo_hash, const QuicTagVector& connection_options, - scoped_refptr<Chain>* out_chain, + QuicReferenceCountedPointer<Chain>* out_chain, QuicCryptoProof* out_proof) = 0; // Async version of GetProof with identical semantics, except that the results
diff --git a/net/quic/core/crypto/quic_compressed_certs_cache.cc b/net/quic/core/crypto/quic_compressed_certs_cache.cc index a18f021..7bcddc4 100644 --- a/net/quic/core/crypto/quic_compressed_certs_cache.cc +++ b/net/quic/core/crypto/quic_compressed_certs_cache.cc
@@ -18,10 +18,11 @@ } // namespace -QuicCompressedCertsCache::UncompressedCerts::UncompressedCerts() {} +QuicCompressedCertsCache::UncompressedCerts::UncompressedCerts() + : chain(nullptr) {} QuicCompressedCertsCache::UncompressedCerts::UncompressedCerts( - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const string* client_common_set_hashes, const string* client_cached_cert_hashes) : chain(chain), @@ -67,7 +68,7 @@ } const string* QuicCompressedCertsCache::GetCompressedCert( - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const string& client_common_set_hashes, const string& client_cached_cert_hashes) { UncompressedCerts uncompressed_certs(chain, &client_common_set_hashes, @@ -87,7 +88,7 @@ } void QuicCompressedCertsCache::Insert( - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const string& client_common_set_hashes, const string& client_cached_cert_hashes, const string& compressed_cert) {
diff --git a/net/quic/core/crypto/quic_compressed_certs_cache.h b/net/quic/core/crypto/quic_compressed_certs_cache.h index 2e59af2..7ae67645 100644 --- a/net/quic/core/crypto/quic_compressed_certs_cache.h +++ b/net/quic/core/crypto/quic_compressed_certs_cache.h
@@ -9,7 +9,6 @@ #include <vector> #include "base/containers/mru_cache.h" -#include "base/memory/ref_counted.h" #include "net/quic/core/crypto/proof_source.h" #include "net/quic/platform/api/quic_export.h" @@ -26,7 +25,7 @@ // Otherwise, return nullptr. // Returned pointer might become invalid on the next call to Insert(). const std::string* GetCompressedCert( - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const std::string& client_common_set_hashes, const std::string& client_cached_cert_hashes); @@ -35,7 +34,7 @@ // client_cached_cert_hashes, compressed_cert| tuple to the cache. // If the insertion causes the cache to become overfull, entries will // be deleted in an LRU order to make room. - void Insert(const scoped_refptr<ProofSource::Chain>& chain, + void Insert(const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const std::string& client_common_set_hashes, const std::string& client_cached_cert_hashes, const std::string& compressed_cert); @@ -55,12 +54,13 @@ // to identify uncompressed representation of certs. struct UncompressedCerts { UncompressedCerts(); - UncompressedCerts(const scoped_refptr<ProofSource::Chain>& chain, - const std::string* client_common_set_hashes, - const std::string* client_cached_cert_hashes); + UncompressedCerts( + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, + const std::string* client_common_set_hashes, + const std::string* client_cached_cert_hashes); ~UncompressedCerts(); - const scoped_refptr<ProofSource::Chain> chain; + const QuicReferenceCountedPointer<ProofSource::Chain> chain; const std::string* client_common_set_hashes; const std::string* client_cached_cert_hashes; }; @@ -86,7 +86,7 @@ private: // Uncompressed certs data. - scoped_refptr<ProofSource::Chain> chain_; + QuicReferenceCountedPointer<ProofSource::Chain> chain_; const std::string client_common_set_hashes_; const std::string client_cached_cert_hashes_;
diff --git a/net/quic/core/crypto/quic_compressed_certs_cache_test.cc b/net/quic/core/crypto/quic_compressed_certs_cache_test.cc index 1ac853a5..456387e 100644 --- a/net/quic/core/crypto/quic_compressed_certs_cache_test.cc +++ b/net/quic/core/crypto/quic_compressed_certs_cache_test.cc
@@ -30,7 +30,8 @@ TEST_F(QuicCompressedCertsCacheTest, CacheHit) { std::vector<string> certs = {"leaf cert", "intermediate cert", "root cert"}; - scoped_refptr<ProofSource::Chain> chain(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain( + new ProofSource::Chain(certs)); string common_certs = "common certs"; string cached_certs = "cached certs"; string compressed = "compressed cert"; @@ -45,7 +46,8 @@ TEST_F(QuicCompressedCertsCacheTest, CacheMiss) { std::vector<string> certs = {"leaf cert", "intermediate cert", "root cert"}; - scoped_refptr<ProofSource::Chain> chain(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain( + new ProofSource::Chain(certs)); string common_certs = "common certs"; string cached_certs = "cached certs"; string compressed = "compressed cert"; @@ -56,7 +58,8 @@ chain, "mismatched common certs", cached_certs)); EXPECT_EQ(nullptr, certs_cache_.GetCompressedCert(chain, common_certs, "mismatched cached certs")); - scoped_refptr<ProofSource::Chain> chain2(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain2( + new ProofSource::Chain(certs)); EXPECT_EQ(nullptr, certs_cache_.GetCompressedCert(chain2, common_certs, cached_certs)); } @@ -65,7 +68,8 @@ // Test cache returns a miss when a queried uncompressed certs was cached but // then evicted. std::vector<string> certs = {"leaf cert", "intermediate cert", "root cert"}; - scoped_refptr<ProofSource::Chain> chain(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain( + new ProofSource::Chain(certs)); string common_certs = "common certs"; string cached_certs = "cached certs";
diff --git a/net/quic/core/crypto/quic_crypto_client_config.cc b/net/quic/core/crypto/quic_crypto_client_config.cc index 1fd4bd1..31c003a 100644 --- a/net/quic/core/crypto/quic_crypto_client_config.cc +++ b/net/quic/core/crypto/quic_crypto_client_config.cc
@@ -418,7 +418,7 @@ const CachedState* cached, QuicRandom* rand, bool demand_x509_proof, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, CryptoHandshakeMessage* out) const { out->set_tag(kCHLO); // TODO(rch): Remove this when we remove: @@ -491,7 +491,7 @@ QuicWallTime now, QuicRandom* rand, const ChannelIDKey* channel_id_key, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, CryptoHandshakeMessage* out, string* error_details) const { DCHECK(error_details != nullptr); @@ -785,7 +785,7 @@ const QuicVersion version, StringPiece chlo_hash, CachedState* cached, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, string* error_details) { DCHECK(error_details != nullptr); @@ -828,7 +828,7 @@ QuicVersion version, const QuicVersionVector& negotiated_versions, CachedState* cached, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, string* error_details) { DCHECK(error_details != nullptr); @@ -891,7 +891,7 @@ const QuicVersion version, StringPiece chlo_hash, CachedState* cached, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, string* error_details) { DCHECK(error_details != nullptr);
diff --git a/net/quic/core/crypto/quic_crypto_client_config.h b/net/quic/core/crypto/quic_crypto_client_config.h index cfc4892..c20ea1f 100644 --- a/net/quic/core/crypto/quic_crypto_client_config.h +++ b/net/quic/core/crypto/quic_crypto_client_config.h
@@ -19,6 +19,7 @@ #include "net/quic/core/quic_packets.h" #include "net/quic/core/quic_server_id.h" #include "net/quic/platform/api/quic_export.h" +#include "net/quic/platform/api/quic_reference_counted.h" namespace net { @@ -232,7 +233,7 @@ const CachedState* cached, QuicRandom* rand, bool demand_x509_proof, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, CryptoHandshakeMessage* out) const; // FillClientHello sets |out| to be a CHLO message based on the configuration @@ -257,7 +258,7 @@ QuicWallTime now, QuicRandom* rand, const ChannelIDKey* channel_id_key, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, CryptoHandshakeMessage* out, std::string* error_details) const; @@ -273,7 +274,7 @@ QuicVersion version, base::StringPiece chlo_hash, CachedState* cached, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details); // ProcessServerHello processes the message in |server_hello|, updates the @@ -291,7 +292,7 @@ QuicVersion version, const QuicVersionVector& negotiated_versions, CachedState* cached, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details); // Processes the message in |server_update|, updating the cached source @@ -305,7 +306,7 @@ const QuicVersion version, base::StringPiece chlo_hash, CachedState* cached, - scoped_refptr<QuicCryptoNegotiatedParameters> out_params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details); ProofVerifier* proof_verifier() const;
diff --git a/net/quic/core/crypto/quic_crypto_client_config_test.cc b/net/quic/core/crypto/quic_crypto_client_config_test.cc index 12d7dbc..5d15437 100644 --- a/net/quic/core/crypto/quic_crypto_client_config_test.cc +++ b/net/quic/core/crypto/quic_crypto_client_config_test.cc
@@ -169,7 +169,7 @@ TEST(QuicCryptoClientConfigTest, InchoateChlo) { QuicCryptoClientConfig::CachedState state; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); - scoped_refptr<QuicCryptoNegotiatedParameters> params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params( new QuicCryptoNegotiatedParameters); CryptoHandshakeMessage msg; QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED); @@ -196,7 +196,7 @@ TEST(QuicCryptoClientConfigTest, InchoateChloSecure) { QuicCryptoClientConfig::CachedState state; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); - scoped_refptr<QuicCryptoNegotiatedParameters> params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params( new QuicCryptoNegotiatedParameters); CryptoHandshakeMessage msg; QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED); @@ -225,7 +225,7 @@ &details); QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); - scoped_refptr<QuicCryptoNegotiatedParameters> params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params( new QuicCryptoNegotiatedParameters); CryptoHandshakeMessage msg; QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED); @@ -251,7 +251,7 @@ QuicWallTime::FromUNIXSeconds(0), &details); QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); - scoped_refptr<QuicCryptoNegotiatedParameters> params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params( new QuicCryptoNegotiatedParameters); CryptoHandshakeMessage msg; QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED); @@ -267,7 +267,7 @@ TEST(QuicCryptoClientConfigTest, FillClientHello) { QuicCryptoClientConfig::CachedState state; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); - scoped_refptr<QuicCryptoNegotiatedParameters> params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params( new QuicCryptoNegotiatedParameters); QuicConnectionId kConnectionId = 1234; string error_details; @@ -301,7 +301,7 @@ msg.SetVector(kVER, supported_version_tags); QuicCryptoClientConfig::CachedState cached; - scoped_refptr<QuicCryptoNegotiatedParameters> out_params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( new QuicCryptoNegotiatedParameters); string error; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); @@ -465,7 +465,7 @@ // Now process the rejection. QuicCryptoClientConfig::CachedState cached; - scoped_refptr<QuicCryptoNegotiatedParameters> out_params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( new QuicCryptoNegotiatedParameters); string error; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); @@ -486,7 +486,7 @@ // Now process the rejection. QuicCryptoClientConfig::CachedState cached; - scoped_refptr<QuicCryptoNegotiatedParameters> out_params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( new QuicCryptoNegotiatedParameters); string error; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); @@ -513,7 +513,7 @@ // Now process the rejection. QuicCryptoClientConfig::CachedState cached; - scoped_refptr<QuicCryptoNegotiatedParameters> out_params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( new QuicCryptoNegotiatedParameters); string error; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); @@ -534,7 +534,7 @@ // Now process the rejection. QuicCryptoClientConfig::CachedState cached; - scoped_refptr<QuicCryptoNegotiatedParameters> out_params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( new QuicCryptoNegotiatedParameters); string error; QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); @@ -560,7 +560,7 @@ QuicCryptoClientConfig config(CryptoTestUtils::ProofVerifierForTesting()); QuicCryptoClientConfig::CachedState cached; - scoped_refptr<QuicCryptoNegotiatedParameters> out_params( + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( new QuicCryptoNegotiatedParameters); string error_details; EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER,
diff --git a/net/quic/core/crypto/quic_crypto_server_config.cc b/net/quic/core/crypto/quic_crypto_server_config.cc index 4311296..61dc3b8 100644 --- a/net/quic/core/crypto/quic_crypto_server_config.cc +++ b/net/quic/core/crypto/quic_crypto_server_config.cc
@@ -10,7 +10,6 @@ #include <memory> #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "crypto/hkdf.h" #include "crypto/secure_hash.h" #include "net/base/ip_address.h" @@ -38,6 +37,7 @@ #include "net/quic/core/quic_socket_address_coder.h" #include "net/quic/core/quic_utils.h" #include "net/quic/platform/api/quic_clock.h" +#include "net/quic/platform/api/quic_reference_counted.h" using base::StringPiece; using crypto::SecureHash; @@ -70,7 +70,8 @@ // Note: stores a pointer to a unique_ptr, and std::moves the unique_ptr when // ValidationComplete is called. ValidateClientHelloHelper( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<ValidateClientHelloResultCallback>* done_cb) : result_(std::move(result)), done_cb_(done_cb) {} @@ -95,7 +96,8 @@ } private: - scoped_refptr<ValidateClientHelloResultCallback::Result> result_; + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result_; std::unique_ptr<ValidateClientHelloResultCallback>* done_cb_; DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloHelper); @@ -302,7 +304,7 @@ return nullptr; } - scoped_refptr<Config> config(ParseConfigProtobuf(protobuf)); + QuicReferenceCountedPointer<Config> config(ParseConfigProtobuf(protobuf)); if (!config.get()) { LOG(WARNING) << "Failed to parse server config message"; return nullptr; @@ -337,12 +339,12 @@ bool QuicCryptoServerConfig::SetConfigs( const std::vector<std::unique_ptr<QuicServerConfigProtobuf>>& protobufs, const QuicWallTime now) { - std::vector<scoped_refptr<Config>> parsed_configs; + std::vector<QuicReferenceCountedPointer<Config>> parsed_configs; bool ok = true; for (auto& protobuf : protobufs) { - scoped_refptr<Config> config(ParseConfigProtobuf(protobuf)); - if (!config.get()) { + QuicReferenceCountedPointer<Config> config(ParseConfigProtobuf(protobuf)); + if (!config) { ok = false; break; } @@ -363,10 +365,10 @@ QuicWriterMutexLock locked(&configs_lock_); ConfigMap new_configs; - for (std::vector<scoped_refptr<Config>>::const_iterator i = + for (std::vector<QuicReferenceCountedPointer<Config>>::const_iterator i = parsed_configs.begin(); i != parsed_configs.end(); ++i) { - scoped_refptr<Config> config = *i; + QuicReferenceCountedPointer<Config> config = *i; ConfigMap::iterator it = configs_.find(config->id); if (it != configs_.end()) { @@ -422,19 +424,19 @@ const QuicSocketAddress& server_address, QuicVersion version, const QuicClock* clock, - scoped_refptr<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const { const QuicWallTime now(clock->WallNow()); - scoped_refptr<ValidateClientHelloResultCallback::Result> result( + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> result( new ValidateClientHelloResultCallback::Result(client_hello, client_ip, now)); StringPiece requested_scid; client_hello.GetStringPiece(kSCID, &requested_scid); - scoped_refptr<Config> requested_config; - scoped_refptr<Config> primary_config; + QuicReferenceCountedPointer<Config> requested_config; + QuicReferenceCountedPointer<Config> primary_config; { QuicReaderMutexLock locked(&configs_lock_); @@ -512,7 +514,7 @@ public: ProcessClientHelloCallback( const QuicCryptoServerConfig* config, - scoped_refptr<ValidateClientHelloResultCallback::Result> + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> validate_chlo_result, bool reject_only, QuicConnectionId connection_id, @@ -524,12 +526,14 @@ const QuicClock* clock, QuicRandom* rand, QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, - scoped_refptr<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, - const scoped_refptr<QuicCryptoServerConfig::Config>& requested_config, - const scoped_refptr<QuicCryptoServerConfig::Config>& primary_config, + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config>& + requested_config, + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config>& + primary_config, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) : config_(config), validate_chlo_result_(std::move(validate_chlo_result)), @@ -552,7 +556,7 @@ done_cb_(std::move(done_cb)) {} void Run(bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const QuicCryptoProof& proof, std::unique_ptr<ProofSource::Details> details) override { if (ok) { @@ -570,7 +574,7 @@ private: const QuicCryptoServerConfig* config_; - const scoped_refptr<ValidateClientHelloResultCallback::Result> + const QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> validate_chlo_result_; const bool reject_only_; const QuicConnectionId connection_id_; @@ -582,17 +586,19 @@ const QuicClock* const clock_; QuicRandom* const rand_; QuicCompressedCertsCache* compressed_certs_cache_; - scoped_refptr<QuicCryptoNegotiatedParameters> params_; - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; const QuicByteCount total_framing_overhead_; const QuicByteCount chlo_packet_size_; - const scoped_refptr<QuicCryptoServerConfig::Config> requested_config_; - const scoped_refptr<QuicCryptoServerConfig::Config> primary_config_; + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + requested_config_; + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + primary_config_; std::unique_ptr<ProcessClientHelloResultCallback> done_cb_; }; void QuicCryptoServerConfig::ProcessClientHello( - scoped_refptr<ValidateClientHelloResultCallback::Result> + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> validate_chlo_result, bool reject_only, QuicConnectionId connection_id, @@ -605,8 +611,8 @@ const QuicClock* clock, QuicRandom* rand, QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, - scoped_refptr<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const { @@ -630,8 +636,8 @@ client_hello.GetStringPiece(kSCID, &requested_scid); const QuicWallTime now(clock->WallNow()); - scoped_refptr<Config> requested_config; - scoped_refptr<Config> primary_config; + QuicReferenceCountedPointer<Config> requested_config; + QuicReferenceCountedPointer<Config> primary_config; bool no_primary_config = false; { QuicReaderMutexLock locked(&configs_lock_); @@ -735,12 +741,12 @@ const QuicClock* clock, QuicRandom* rand, QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, - scoped_refptr<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, - const scoped_refptr<Config>& requested_config, - const scoped_refptr<Config>& primary_config, + const QuicReferenceCountedPointer<Config>& requested_config, + const QuicReferenceCountedPointer<Config>& primary_config, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const { ProcessClientHelloHelper helper(&done_cb); @@ -1003,7 +1009,7 @@ std::move(proof_source_details)); } -scoped_refptr<QuicCryptoServerConfig::Config> +QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> QuicCryptoServerConfig::GetConfigWithScid(StringPiece requested_scid) const { configs_lock_.AssertReaderHeld(); @@ -1012,19 +1018,19 @@ if (it != configs_.end()) { // We'll use the config that the client requested in order to do // key-agreement. - return scoped_refptr<Config>(it->second); + return QuicReferenceCountedPointer<Config>(it->second); } } - return scoped_refptr<Config>(); + return QuicReferenceCountedPointer<Config>(); } // ConfigPrimaryTimeLessThan is a comparator that implements "less than" for // Config's based on their primary_time. // static bool QuicCryptoServerConfig::ConfigPrimaryTimeLessThan( - const scoped_refptr<Config>& a, - const scoped_refptr<Config>& b) { + const QuicReferenceCountedPointer<Config>& a, + const QuicReferenceCountedPointer<Config>& b) { if (a->primary_time.IsBefore(b->primary_time) || b->primary_time.IsBefore(a->primary_time)) { // Primary times differ. @@ -1040,7 +1046,7 @@ void QuicCryptoServerConfig::SelectNewPrimaryConfig( const QuicWallTime now) const { - std::vector<scoped_refptr<Config>> configs; + std::vector<QuicReferenceCountedPointer<Config>> configs; configs.reserve(configs_.size()); for (ConfigMap::const_iterator it = configs_.begin(); it != configs_.end(); @@ -1060,10 +1066,10 @@ std::sort(configs.begin(), configs.end(), ConfigPrimaryTimeLessThan); - scoped_refptr<Config> best_candidate = configs[0]; + QuicReferenceCountedPointer<Config> best_candidate = configs[0]; for (size_t i = 0; i < configs.size(); ++i) { - const scoped_refptr<Config> config(configs[i]); + const QuicReferenceCountedPointer<Config> config(configs[i]); if (!config->primary_time.IsAfter(now)) { if (config->primary_time.IsAfter(best_candidate->primary_time)) { best_candidate = config; @@ -1074,7 +1080,7 @@ // This is the first config with a primary_time in the future. Thus the // previous Config should be the primary and this one should determine the // next_config_promotion_time_. - scoped_refptr<Config> new_primary = best_candidate; + QuicReferenceCountedPointer<Config> new_primary = best_candidate; if (i == 0) { // We need the primary_time of the next config. if (configs.size() > 1) { @@ -1104,8 +1110,8 @@ // All config's primary times are in the past. We should make the most recent // and highest priority candidate primary. - scoped_refptr<Config> new_primary = best_candidate; - if (primary_config_.get()) { + QuicReferenceCountedPointer<Config> new_primary = best_candidate; + if (primary_config_) { primary_config_->is_primary = false; } primary_config_ = new_primary; @@ -1129,10 +1135,12 @@ bool found_error, const QuicIpAddress& server_ip, QuicVersion version, - scoped_refptr<QuicCryptoServerConfig::Config> requested_config, - scoped_refptr<QuicCryptoServerConfig::Config> primary_config, - scoped_refptr<QuicSignedServerConfig> signed_config, - scoped_refptr<ValidateClientHelloResultCallback::Result> + QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + requested_config, + QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + primary_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> client_hello_state, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) : config_(config), @@ -1146,7 +1154,7 @@ done_cb_(std::move(done_cb)) {} void Run(bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const QuicCryptoProof& proof, std::unique_ptr<ProofSource::Details> details) override { if (ok) { @@ -1164,20 +1172,24 @@ const bool found_error_; const QuicIpAddress& server_ip_; const QuicVersion version_; - const scoped_refptr<QuicCryptoServerConfig::Config> requested_config_; - const scoped_refptr<QuicCryptoServerConfig::Config> primary_config_; - scoped_refptr<QuicSignedServerConfig> signed_config_; - scoped_refptr<ValidateClientHelloResultCallback::Result> client_hello_state_; + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + requested_config_; + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + primary_config_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + client_hello_state_; std::unique_ptr<ValidateClientHelloResultCallback> done_cb_; }; void QuicCryptoServerConfig::EvaluateClientHello( const QuicSocketAddress& server_address, QuicVersion version, - scoped_refptr<Config> requested_config, - scoped_refptr<Config> primary_config, - scoped_refptr<QuicSignedServerConfig> signed_config, - scoped_refptr<ValidateClientHelloResultCallback::Result> client_hello_state, + QuicReferenceCountedPointer<Config> requested_config, + QuicReferenceCountedPointer<Config> primary_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + client_hello_state, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const { ValidateClientHelloHelper helper(client_hello_state, &done_cb); @@ -1298,12 +1310,13 @@ bool found_error, const QuicIpAddress& server_ip, QuicVersion version, - scoped_refptr<Config> requested_config, - scoped_refptr<Config> primary_config, - scoped_refptr<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<Config> requested_config, + QuicReferenceCountedPointer<Config> primary_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, std::unique_ptr<ProofSource::Details> proof_source_details, bool get_proof_failed, - scoped_refptr<ValidateClientHelloResultCallback::Result> client_hello_state, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + client_hello_state, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const { ValidateClientHelloHelper helper(client_hello_state, &done_cb); const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello; @@ -1369,7 +1382,7 @@ out->SetValue(kSTTL, expiry_time.AbsoluteDifference(clock->WallNow()).ToSeconds()); - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; QuicCryptoProof proof; if (!proof_source_->GetProof(server_address, params.sni, serialized, version, chlo_hash, connection_options, &chain, &proof)) { @@ -1464,7 +1477,7 @@ void QuicCryptoServerConfig::BuildServerConfigUpdateMessageProofSourceCallback:: Run(bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const QuicCryptoProof& proof, std::unique_ptr<ProofSource::Details> details) { config_->FinishBuildServerConfigUpdateMessage( @@ -1483,7 +1496,7 @@ const string& client_cached_cert_hashes, bool sct_supported_by_client, bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const string& signature, const string& leaf_cert_sct, std::unique_ptr<ProofSource::Details> details, @@ -1522,7 +1535,7 @@ QuicConnectionId server_designated_connection_id, QuicRandom* rand, QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, const QuicSignedServerConfig& signed_config, QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, @@ -1615,7 +1628,7 @@ string QuicCryptoServerConfig::CompressChain( QuicCompressedCertsCache* compressed_certs_cache, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const string& client_common_set_hashes, const string& client_cached_cert_hashes, const CommonCertSets* common_sets) { @@ -1637,7 +1650,7 @@ return compressed; } -scoped_refptr<QuicCryptoServerConfig::Config> +QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> QuicCryptoServerConfig::ParseConfigProtobuf( const std::unique_ptr<QuicServerConfigProtobuf>& protobuf) { std::unique_ptr<CryptoHandshakeMessage> msg( @@ -1649,7 +1662,7 @@ return nullptr; } - scoped_refptr<Config> config(new Config); + QuicReferenceCountedPointer<Config> config(new Config); config->serialized = protobuf->config(); config->source_address_token_boxer = &source_address_token_boxer_;
diff --git a/net/quic/core/crypto/quic_crypto_server_config.h b/net/quic/core/crypto/quic_crypto_server_config.h index 28f65f75..a430b29 100644 --- a/net/quic/core/crypto/quic_crypto_server_config.h +++ b/net/quic/core/crypto/quic_crypto_server_config.h
@@ -14,7 +14,6 @@ #include <vector> #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "base/strings/string_piece.h" #include "net/base/ip_address.h" #include "net/base/ip_endpoint.h" @@ -30,6 +29,7 @@ #include "net/quic/core/quic_time.h" #include "net/quic/platform/api/quic_export.h" #include "net/quic/platform/api/quic_mutex.h" +#include "net/quic/platform/api/quic_reference_counted.h" #include "net/quic/platform/api/quic_socket_address.h" namespace net { @@ -87,8 +87,7 @@ public: // Opaque token that holds information about the client_hello and // its validity. Can be interpreted by calling ProcessClientHello. - struct QUIC_EXPORT_PRIVATE Result - : public base::RefCountedThreadSafe<Result> { + struct QUIC_EXPORT_PRIVATE Result : public QuicReferenceCounted { Result(const CryptoHandshakeMessage& in_client_hello, QuicIpAddress in_client_ip, QuicWallTime in_now); @@ -101,15 +100,14 @@ // Populated if the CHLO STK contained a CachedNetworkParameters proto. CachedNetworkParameters cached_network_params; - private: - friend class base::RefCountedThreadSafe<Result>; - ~Result(); + protected: + ~Result() override; }; ValidateClientHelloResultCallback(); - virtual void Run(scoped_refptr<Result> result, - std::unique_ptr<ProofSource::Details> details) = 0; virtual ~ValidateClientHelloResultCallback(); + virtual void Run(QuicReferenceCountedPointer<Result> result, + std::unique_ptr<ProofSource::Details> details) = 0; private: DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback); @@ -280,7 +278,7 @@ const QuicSocketAddress& server_address, QuicVersion version, const QuicClock* clock, - scoped_refptr<QuicSignedServerConfig> crypto_proof, + QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; // ProcessClientHello processes |client_hello| and decides whether to accept @@ -313,7 +311,7 @@ // chlo_packet_size: the size, in bytes, of the CHLO packet // done_cb: the callback invoked on completion void ProcessClientHello( - scoped_refptr<ValidateClientHelloResultCallback::Result> + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> validate_chlo_result, bool reject_only, QuicConnectionId connection_id, @@ -326,8 +324,8 @@ const QuicClock* clock, QuicRandom* rand, QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, - scoped_refptr<QuicSignedServerConfig> crypto_proof, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, + QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof, QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; @@ -430,7 +428,7 @@ // Config represents a server config: a collection of preferences and // Diffie-Hellman public values. class QUIC_EXPORT_PRIVATE Config : public QuicCryptoConfig, - public base::RefCounted<Config> { + public QuicReferenceCounted { public: Config(); @@ -486,23 +484,24 @@ std::unique_ptr<CryptoSecretBoxer> source_address_token_boxer_storage; private: - friend class base::RefCounted<Config>; - - virtual ~Config(); + ~Config() override; DISALLOW_COPY_AND_ASSIGN(Config); }; - typedef std::map<ServerConfigID, scoped_refptr<Config>> ConfigMap; + typedef std::map<ServerConfigID, QuicReferenceCountedPointer<Config>> + ConfigMap; // Get a ref to the config with a given server config id. - scoped_refptr<Config> GetConfigWithScid( - base::StringPiece requested_scid) const; + QuicReferenceCountedPointer<Config> GetConfigWithScid( + base::StringPiece requested_scid) const + SHARED_LOCKS_REQUIRED(configs_lock_); // ConfigPrimaryTimeLessThan returns true if a->primary_time < // b->primary_time. - static bool ConfigPrimaryTimeLessThan(const scoped_refptr<Config>& a, - const scoped_refptr<Config>& b); + static bool ConfigPrimaryTimeLessThan( + const QuicReferenceCountedPointer<Config>& a, + const QuicReferenceCountedPointer<Config>& b); // SelectNewPrimaryConfig reevaluates the primary config based on the // "primary_time" deadlines contained in each. @@ -514,10 +513,10 @@ void EvaluateClientHello( const QuicSocketAddress& server_address, QuicVersion version, - scoped_refptr<Config> requested_config, - scoped_refptr<Config> primary_config, - scoped_refptr<QuicSignedServerConfig> crypto_proof, - scoped_refptr<ValidateClientHelloResultCallback::Result> + QuicReferenceCountedPointer<Config> requested_config, + QuicReferenceCountedPointer<Config> primary_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> client_hello_state, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; @@ -535,12 +534,12 @@ bool found_error, const QuicIpAddress& server_ip, QuicVersion version, - scoped_refptr<Config> requested_config, - scoped_refptr<Config> primary_config, - scoped_refptr<QuicSignedServerConfig> crypto_proof, + QuicReferenceCountedPointer<Config> requested_config, + QuicReferenceCountedPointer<Config> primary_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof, std::unique_ptr<ProofSource::Details> proof_source_details, bool get_proof_failed, - scoped_refptr<ValidateClientHelloResultCallback::Result> + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> client_hello_state, std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; @@ -564,30 +563,31 @@ const QuicClock* clock, QuicRandom* rand, QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, - scoped_refptr<QuicSignedServerConfig> crypto_proof, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, + QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof, QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, - const scoped_refptr<Config>& requested_config, - const scoped_refptr<Config>& primary_config, + const QuicReferenceCountedPointer<Config>& requested_config, + const QuicReferenceCountedPointer<Config>& primary_config, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const; // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. - void BuildRejection(QuicVersion version, - QuicWallTime now, - const Config& config, - const CryptoHandshakeMessage& client_hello, - const ClientHelloInfo& info, - const CachedNetworkParameters& cached_network_params, - bool use_stateless_rejects, - QuicConnectionId server_designated_connection_id, - QuicRandom* rand, - QuicCompressedCertsCache* compressed_certs_cache, - scoped_refptr<QuicCryptoNegotiatedParameters> params, - const QuicSignedServerConfig& crypto_proof, - QuicByteCount total_framing_overhead, - QuicByteCount chlo_packet_size, - CryptoHandshakeMessage* out) const; + void BuildRejection( + QuicVersion version, + QuicWallTime now, + const Config& config, + const CryptoHandshakeMessage& client_hello, + const ClientHelloInfo& info, + const CachedNetworkParameters& cached_network_params, + bool use_stateless_rejects, + QuicConnectionId server_designated_connection_id, + QuicRandom* rand, + QuicCompressedCertsCache* compressed_certs_cache, + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params, + const QuicSignedServerConfig& crypto_proof, + QuicByteCount total_framing_overhead, + QuicByteCount chlo_packet_size, + CryptoHandshakeMessage* out) const; // CompressChain compresses the certificates in |chain->certs| and returns a // compressed representation. |common_sets| contains the common certificate @@ -596,15 +596,15 @@ // 64-bit, FNV-1a hashes of certificates that the peer already possesses. static std::string CompressChain( QuicCompressedCertsCache* compressed_certs_cache, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const std::string& client_common_set_hashes, const std::string& client_cached_cert_hashes, const CommonCertSets* common_sets); // ParseConfigProtobuf parses the given config protobuf and returns a - // scoped_refptr<Config> if successful. The caller adopts the reference to the - // Config. On error, ParseConfigProtobuf returns nullptr. - scoped_refptr<Config> ParseConfigProtobuf( + // QuicReferenceCountedPointer<Config> if successful. The caller adopts the + // reference to the Config. On error, ParseConfigProtobuf returns nullptr. + QuicReferenceCountedPointer<Config> ParseConfigProtobuf( const std::unique_ptr<QuicServerConfigProtobuf>& protobuf); // NewSourceAddressToken returns a fresh source address token for the given @@ -692,7 +692,7 @@ std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb); void Run(bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const QuicCryptoProof& proof, std::unique_ptr<ProofSource::Details> details) override; @@ -719,7 +719,7 @@ const std::string& client_cached_cert_hashes, bool sct_supported_by_client, bool ok, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const std::string& signature, const std::string& leaf_cert_sct, std::unique_ptr<ProofSource::Details> details, @@ -745,7 +745,8 @@ ConfigMap configs_ GUARDED_BY(configs_lock_); // primary_config_ points to a Config (which is also in |configs_|) which is // the primary config - i.e. the one that we'll give out to new clients. - mutable scoped_refptr<Config> primary_config_ GUARDED_BY(configs_lock_); + mutable QuicReferenceCountedPointer<Config> primary_config_ + GUARDED_BY(configs_lock_); // next_config_promotion_time_ contains the nearest, future time when an // active config will be promoted to primary. mutable QuicWallTime next_config_promotion_time_ GUARDED_BY(configs_lock_); @@ -788,19 +789,18 @@ }; struct QUIC_EXPORT_PRIVATE QuicSignedServerConfig - : public base::RefCounted<QuicSignedServerConfig> { + : public QuicReferenceCounted { QuicSignedServerConfig(); QuicCryptoProof proof; - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; // The server config that is used for this proof (and the rest of the // request). - scoped_refptr<QuicCryptoServerConfig::Config> config; + QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> config; std::string primary_scid; - private: - friend class base::RefCounted<QuicSignedServerConfig>; - virtual ~QuicSignedServerConfig(); + protected: + ~QuicSignedServerConfig() override; }; } // namespace net
diff --git a/net/quic/core/crypto/quic_crypto_server_config_test.cc b/net/quic/core/crypto/quic_crypto_server_config_test.cc index 6369466..a3d98f2 100644 --- a/net/quic/core/crypto/quic_crypto_server_config_test.cc +++ b/net/quic/core/crypto/quic_crypto_server_config_test.cc
@@ -60,7 +60,8 @@ QuicCryptoServerConfigPeer peer(&server); std::vector<string> certs = {"testcert"}; - scoped_refptr<ProofSource::Chain> chain(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain( + new ProofSource::Chain(certs)); string compressed = QuicCryptoServerConfigPeer::CompressChain( &compressed_certs_cache, chain, "", "", nullptr); @@ -79,7 +80,8 @@ // Compress the certs for the first time. std::vector<string> certs = {"testcert"}; - scoped_refptr<ProofSource::Chain> chain(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain( + new ProofSource::Chain(certs)); string common_certs = ""; string cached_certs = ""; @@ -106,7 +108,8 @@ QuicCryptoServerConfigPeer peer(&server); std::vector<string> certs = {"testcert"}; - scoped_refptr<ProofSource::Chain> chain(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain( + new ProofSource::Chain(certs)); string common_certs = ""; string cached_certs = ""; @@ -115,7 +118,8 @@ EXPECT_EQ(compressed_certs_cache.Size(), 1u); // Compress a similar certs which only differs in the chain. - scoped_refptr<ProofSource::Chain> chain2(new ProofSource::Chain(certs)); + QuicReferenceCountedPointer<ProofSource::Chain> chain2( + new ProofSource::Chain(certs)); string compressed2 = QuicCryptoServerConfigPeer::CompressChain( &compressed_certs_cache, chain2, common_certs, cached_certs, nullptr);
diff --git a/net/quic/core/crypto/quic_server_info.h b/net/quic/core/crypto/quic_server_info.h index 4a5e75e3..f214f2c0 100644 --- a/net/quic/core/crypto/quic_server_info.h +++ b/net/quic/core/crypto/quic_server_info.h
@@ -9,7 +9,6 @@ #include <vector> #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "net/base/completion_callback.h"
diff --git a/net/quic/core/quic_ack_listener_interface.cc b/net/quic/core/quic_ack_listener_interface.cc index e599d59..dc8d406 100644 --- a/net/quic/core/quic_ack_listener_interface.cc +++ b/net/quic/core/quic_ack_listener_interface.cc
@@ -6,8 +6,10 @@ namespace net { +QuicAckListenerInterface::~QuicAckListenerInterface() {} + AckListenerWrapper::AckListenerWrapper( - scoped_refptr<QuicAckListenerInterface> listener, + QuicReferenceCountedPointer<QuicAckListenerInterface> listener, QuicPacketLength data_length) : ack_listener(std::move(listener)), length(data_length) {}
diff --git a/net/quic/core/quic_ack_listener_interface.h b/net/quic/core/quic_ack_listener_interface.h index 8316da9..cd3373a 100644 --- a/net/quic/core/quic_ack_listener_interface.h +++ b/net/quic/core/quic_ack_listener_interface.h
@@ -5,16 +5,16 @@ #ifndef NET_QUIC_CORE_QUIC_ACK_LISTENER_INTERFACE_H_ #define NET_QUIC_CORE_QUIC_ACK_LISTENER_INTERFACE_H_ -#include "base/memory/ref_counted.h" #include "net/quic/core/quic_time.h" #include "net/quic/core/quic_types.h" #include "net/quic/platform/api/quic_export.h" +#include "net/quic/platform/api/quic_reference_counted.h" namespace net { // Pure virtual class to listen for packet acknowledgements. class QUIC_EXPORT_PRIVATE QuicAckListenerInterface - : public base::RefCounted<QuicAckListenerInterface> { + : public QuicReferenceCounted { public: QuicAckListenerInterface() {} @@ -28,19 +28,18 @@ virtual void OnPacketRetransmitted(int retransmitted_bytes) = 0; protected: - friend class base::RefCounted<QuicAckListenerInterface>; - // Delegates are ref counted. - virtual ~QuicAckListenerInterface() {} + ~QuicAckListenerInterface() override; }; struct QUIC_EXPORT_PRIVATE AckListenerWrapper { - AckListenerWrapper(scoped_refptr<QuicAckListenerInterface> listener, - QuicPacketLength data_length); + AckListenerWrapper( + QuicReferenceCountedPointer<QuicAckListenerInterface> listener, + QuicPacketLength data_length); AckListenerWrapper(const AckListenerWrapper& other); ~AckListenerWrapper(); - scoped_refptr<QuicAckListenerInterface> ack_listener; + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener; QuicPacketLength length; };
diff --git a/net/quic/core/quic_connection.cc b/net/quic/core/quic_connection.cc index b63b3ada..762c63e 100644 --- a/net/quic/core/quic_connection.cc +++ b/net/quic/core/quic_connection.cc
@@ -17,7 +17,6 @@ #include "base/format_macros.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" @@ -1116,7 +1115,7 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> listener) { if (!fin && iov.total_length == 0) { QUIC_BUG << "Attempt to send empty stream frame"; return QuicConsumedData(0, false);
diff --git a/net/quic/core/quic_connection.h b/net/quic/core/quic_connection.h index 97466180..ecbe8d6 100644 --- a/net/quic/core/quic_connection.h +++ b/net/quic/core/quic_connection.h
@@ -352,7 +352,7 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener); + QuicReferenceCountedPointer<QuicAckListenerInterface> listener); // Send a RST_STREAM frame to the peer. virtual void SendRstStream(QuicStreamId id,
diff --git a/net/quic/core/quic_connection_test.cc b/net/quic/core/quic_connection_test.cc index e60eac3e..5449770 100644 --- a/net/quic/core/quic_connection_test.cc +++ b/net/quic/core/quic_connection_test.cc
@@ -516,7 +516,7 @@ StringPiece data, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> listener) { if (id != kCryptoStreamId && this->encryption_level() == ENCRYPTION_NONE) { this->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); } @@ -4613,7 +4613,7 @@ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); // Create a listener which we expect to be called. - scoped_refptr<MockAckListener> listener(new MockAckListener); + QuicReferenceCountedPointer<MockAckListener> listener(new MockAckListener); EXPECT_CALL(*listener, OnPacketAcked(_, _)).Times(1); // Send some data, which will register the listener to be notified. @@ -4629,7 +4629,7 @@ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); // Create a listener which we don't expect to be called. - scoped_refptr<MockAckListener> listener(new MockAckListener); + QuicReferenceCountedPointer<MockAckListener> listener(new MockAckListener); EXPECT_CALL(*listener, OnPacketAcked(_, _)).Times(0); // Send some data, which will register the listener to be notified. This will @@ -4656,7 +4656,7 @@ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); // Create a listener which we expect to be called. - scoped_refptr<MockAckListener> listener(new MockAckListener); + QuicReferenceCountedPointer<MockAckListener> listener(new MockAckListener); EXPECT_CALL(*listener, OnPacketRetransmitted(3)).Times(1); EXPECT_CALL(*listener, OnPacketAcked(3, _)).Times(1); @@ -4692,7 +4692,8 @@ connection_.SetMaxTailLossProbes(kDefaultPathId, 0); // Create a listener which we expect to be called. - scoped_refptr<MockAckListener> listener(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> listener( + new StrictMock<MockAckListener>); QuicTime default_retransmission_time = clock_.ApproximateNow() + DefaultRetransmissionTime(); @@ -4729,7 +4730,8 @@ // packet number. TEST_P(QuicConnectionTest, AckNotifierCallbackForAckOfNackedPacket) { // Create a listener which we expect to be called. - scoped_refptr<MockAckListener> listener(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> listener( + new StrictMock<MockAckListener>()); // Send four packets, and register to be notified on ACK of packet 2. connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); @@ -4826,7 +4828,7 @@ // Make sure that a call to SendStreamWithData, with no data and no FIN, does // not result in a QuicAckNotifier being used-after-free (fail under ASAN). // Regression test for b/18594622 - scoped_refptr<MockAckListener> listener(new MockAckListener); + QuicReferenceCountedPointer<MockAckListener> listener(new MockAckListener); EXPECT_QUIC_BUG( connection_.SendStreamDataWithString(3, "", 0, !kFin, listener), "Attempt to send empty stream frame");
diff --git a/net/quic/core/quic_crypto_server_stream.cc b/net/quic/core/quic_crypto_server_stream.cc index 576d693..38d5312 100644 --- a/net/quic/core/quic_crypto_server_stream.cc +++ b/net/quic/core/quic_crypto_server_stream.cc
@@ -28,7 +28,8 @@ public: ProcessClientHelloCallback( QuicCryptoServerStream* stream, - const scoped_refptr<ValidateClientHelloResultCallback::Result>& result) + const QuicReferenceCountedPointer< + ValidateClientHelloResultCallback::Result>& result) : stream_(stream), result_(result) {} void Run(QuicErrorCode error, @@ -57,7 +58,8 @@ private: QuicCryptoServerStream* stream_; - scoped_refptr<ValidateClientHelloResultCallback::Result> result_; + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result_; }; QuicCryptoServerStreamBase::QuicCryptoServerStreamBase(QuicSession* session) @@ -167,7 +169,8 @@ } void QuicCryptoServerStream::FinishProcessingHandshakeMessage( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<ProofSource::Details> details) { const CryptoHandshakeMessage& message = result->client_hello; @@ -435,7 +438,8 @@ } void QuicCryptoServerStream::ProcessClientHello( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<ProofSource::Details> proof_source_details, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) { const CryptoHandshakeMessage& message = result->client_hello; @@ -485,7 +489,7 @@ } void QuicCryptoServerStream::ValidateCallback::Run( - scoped_refptr<Result> result, + QuicReferenceCountedPointer<Result> result, std::unique_ptr<ProofSource::Details> details) { if (parent_ != nullptr) { parent_->FinishProcessingHandshakeMessage(std::move(result),
diff --git a/net/quic/core/quic_crypto_server_stream.h b/net/quic/core/quic_crypto_server_stream.h index ecb0a04..721a276 100644 --- a/net/quic/core/quic_crypto_server_stream.h +++ b/net/quic/core/quic_crypto_server_stream.h
@@ -129,7 +129,8 @@ protected: virtual void ProcessClientHello( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<ProofSource::Details> proof_source_details, std::unique_ptr<ProcessClientHelloResultCallback> done_cb); @@ -148,7 +149,7 @@ void Cancel(); // From ValidateClientHelloResultCallback - void Run(scoped_refptr<Result> result, + void Run(QuicReferenceCountedPointer<Result> result, std::unique_ptr<ProofSource::Details> details) override; private: @@ -179,7 +180,8 @@ // the client hello is complete. Finishes processing of the client // hello message and handles handshake success/failure. void FinishProcessingHandshakeMessage( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<ProofSource::Details> details); class ProcessClientHelloCallback; @@ -215,7 +217,7 @@ // Server's certificate chain and signature of the server config, as provided // by ProofSource::GetProof. - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; // Hash of the last received CHLO message which can be used for generating // server config update messages.
diff --git a/net/quic/core/quic_crypto_server_stream_test.cc b/net/quic/core/quic_crypto_server_stream_test.cc index 90ff14f0..5c43cde 100644 --- a/net/quic/core/quic_crypto_server_stream_test.cc +++ b/net/quic/core/quic_crypto_server_stream_test.cc
@@ -491,7 +491,7 @@ QuicVersion quic_version, StringPiece chlo_hash, const QuicTagVector& connection_options, - scoped_refptr<ProofSource::Chain>* out_chain, + QuicReferenceCountedPointer<ProofSource::Chain>* out_chain, QuicCryptoProof* out_proof) override { return false; }
diff --git a/net/quic/core/quic_crypto_stream.h b/net/quic/core/quic_crypto_stream.h index 81d983b4..05aa23c 100644 --- a/net/quic/core/quic_crypto_stream.h +++ b/net/quic/core/quic_crypto_stream.h
@@ -81,7 +81,8 @@ bool encryption_established_; bool handshake_confirmed_; - scoped_refptr<QuicCryptoNegotiatedParameters> crypto_negotiated_params_; + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> + crypto_negotiated_params_; private: CryptoFramer crypto_framer_;
diff --git a/net/quic/core/quic_headers_stream.cc b/net/quic/core/quic_headers_stream.cc index 0e64661..6fb5860 100644 --- a/net/quic/core/quic_headers_stream.cc +++ b/net/quic/core/quic_headers_stream.cc
@@ -70,7 +70,7 @@ // |extra_bytes| should be initialized to the size of the HTTP/2 // DATA frame header inserted when forced HOL blocking is enabled. ForceHolAckListener( - scoped_refptr<QuicAckListenerInterface> stream_ack_listener, + QuicReferenceCountedPointer<QuicAckListenerInterface> stream_ack_listener, int extra_bytes) : stream_ack_listener_(std::move(stream_ack_listener)), extra_bytes_(extra_bytes) { @@ -91,10 +91,11 @@ stream_ack_listener_->OnPacketRetransmitted(retransmitted_bytes); } - private: + protected: ~ForceHolAckListener() override {} - scoped_refptr<QuicAckListenerInterface> stream_ack_listener_; + private: + QuicReferenceCountedPointer<QuicAckListenerInterface> stream_ack_listener_; int extra_bytes_; DISALLOW_COPY_AND_ASSIGN(ForceHolAckListener); @@ -344,7 +345,7 @@ SpdyHeaderBlock headers, bool fin, SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { SpdyHeadersIR headers_frame(stream_id, std::move(headers)); headers_frame.set_fin(fin); if (session()->perspective() == Perspective::IS_CLIENT) { @@ -381,11 +382,12 @@ QuicStreamId id, StringPiece data, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { SpdyDataIR spdy_data(id, data); spdy_data.set_fin(fin); SpdySerializedFrame frame(spdy_framer_.SerializeFrame(spdy_data)); - scoped_refptr<ForceHolAckListener> ack_listener; + QuicReferenceCountedPointer<ForceHolAckListener> ack_listener; if (ack_notifier_delegate != nullptr) { ack_listener = new ForceHolAckListener(std::move(ack_notifier_delegate), frame.size() - data.length()); @@ -401,7 +403,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { const size_t max_len = kSpdyInitialFrameSizeLimit - SpdyConstants::kDataFrameMinimumSize;
diff --git a/net/quic/core/quic_headers_stream.h b/net/quic/core/quic_headers_stream.h index 7ca6e9d..f517e2d 100644 --- a/net/quic/core/quic_headers_stream.h +++ b/net/quic/core/quic_headers_stream.h
@@ -56,7 +56,7 @@ SpdyHeaderBlock headers, bool fin, SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_listener); + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); // Write |headers| for |promised_stream_id| on |original_stream_id| in a // PUSH_PROMISE frame to peer. @@ -72,7 +72,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // QuicStream implementation void OnDataAvailable() override; @@ -141,11 +142,11 @@ bool OnDataFrameHeader(QuicStreamId stream_id, size_t length, bool fin); bool OnStreamFrameData(QuicStreamId stream_id, const char* data, size_t len); // Helper for |WritevStreamData()|. - void WriteDataFrame( - QuicStreamId stream_id, - base::StringPiece data, - bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + void WriteDataFrame(QuicStreamId stream_id, + base::StringPiece data, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // Returns true if the session is still connected. bool IsConnected();
diff --git a/net/quic/core/quic_headers_stream_test.cc b/net/quic/core/quic_headers_stream_test.cc index f8d9eb6b..2feb739 100644 --- a/net/quic/core/quic_headers_stream_test.cc +++ b/net/quic/core/quic_headers_stream_test.cc
@@ -264,7 +264,8 @@ QuicConsumedData SaveIovAndNotifyAckListener( const QuicIOVector& data, - const scoped_refptr<QuicAckListenerInterface>& ack_listener) { + const QuicReferenceCountedPointer<QuicAckListenerInterface>& + ack_listener) { QuicConsumedData result = SaveIov(data); if (ack_listener) { ack_listener->OnPacketAcked(result.bytes_consumed, @@ -953,7 +954,7 @@ for (bool fin : {true, false}) { for (bool use_ack_listener : {true, false}) { - scoped_refptr<ForceHolAckListener> ack_listener; + QuicReferenceCountedPointer<ForceHolAckListener> ack_listener; if (use_ack_listener) { ack_listener = new ForceHolAckListener(); }
diff --git a/net/quic/core/quic_packet_creator.cc b/net/quic/core/quic_packet_creator.cc index b5a708ac..3798b55 100644 --- a/net/quic/core/quic_packet_creator.cc +++ b/net/quic/core/quic_packet_creator.cc
@@ -353,7 +353,7 @@ QuicStreamOffset iov_offset, QuicStreamOffset stream_offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener, + QuicReferenceCountedPointer<QuicAckListenerInterface> listener, size_t* num_bytes_consumed) { DCHECK(queued_frames_.empty()); // Write out the packet header @@ -465,7 +465,7 @@ } void QuicPacketCreator::AddAckListener( - scoped_refptr<QuicAckListenerInterface> listener, + QuicReferenceCountedPointer<QuicAckListenerInterface> listener, QuicPacketLength length) { DCHECK(!queued_frames_.empty()); packet_.listeners.emplace_back(std::move(listener), length);
diff --git a/net/quic/core/quic_packet_creator.h b/net/quic/core/quic_packet_creator.h index 2cd07cf..b04aa0f1 100644 --- a/net/quic/core/quic_packet_creator.h +++ b/net/quic/core/quic_packet_creator.h
@@ -125,7 +125,7 @@ QuicStreamOffset iov_offset, QuicStreamOffset stream_offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener, + QuicReferenceCountedPointer<QuicAckListenerInterface> listener, size_t* num_bytes_consumed); // Returns true if there are frames pending to be serialized. @@ -160,10 +160,11 @@ // Identical to AddSavedFrame, but allows the frame to be padded. bool AddPaddedSavedFrame(const QuicFrame& frame); - // Adds |listener| to the next serialized packet and notifies the - // std::listener with |length| as the number of acked bytes. - void AddAckListener(scoped_refptr<QuicAckListenerInterface> listener, - QuicPacketLength length); + // Adds |listener| to the next serialized packet and notifies the listener + // with |length| as the number of acked bytes. + void AddAckListener( + QuicReferenceCountedPointer<QuicAckListenerInterface> listener, + QuicPacketLength length); // Creates a version negotiation packet which supports |supported_versions|. std::unique_ptr<QuicEncryptedPacket> SerializeVersionNegotiationPacket(
diff --git a/net/quic/core/quic_packet_generator.cc b/net/quic/core/quic_packet_generator.cc index baabe5f4..a51463ba 100644 --- a/net/quic/core/quic_packet_generator.cc +++ b/net/quic/core/quic_packet_generator.cc
@@ -53,7 +53,7 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> listener) { bool has_handshake = (id == kCryptoStreamId); QUIC_BUG_IF(has_handshake && fin) << "Handshake packets should never send a fin"; @@ -125,7 +125,7 @@ const QuicIOVector& iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> listener) { DCHECK_NE(id, kCryptoStreamId); size_t total_bytes_consumed = 0; while (total_bytes_consumed < iov.total_length && @@ -145,7 +145,7 @@ void QuicPacketGenerator::GenerateMtuDiscoveryPacket( QuicByteCount target_mtu, - scoped_refptr<QuicAckListenerInterface> listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> listener) { // MTU discovery frames must be sent by themselves. if (!packet_creator_.CanSetMaxPacketLength()) { QUIC_BUG << "MTU discovery packets should only be sent when no other "
diff --git a/net/quic/core/quic_packet_generator.h b/net/quic/core/quic_packet_generator.h index ff5c319..d578e48 100644 --- a/net/quic/core/quic_packet_generator.h +++ b/net/quic/core/quic_packet_generator.h
@@ -98,7 +98,7 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener); + QuicReferenceCountedPointer<QuicAckListenerInterface> listener); // Sends as many data only packets as allowed by the send algorithm and the // available iov. @@ -108,12 +108,12 @@ const QuicIOVector& iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> listener); + QuicReferenceCountedPointer<QuicAckListenerInterface> listener); // Generates an MTU discovery packet of specified size. void GenerateMtuDiscoveryPacket( QuicByteCount target_mtu, - scoped_refptr<QuicAckListenerInterface> listener); + QuicReferenceCountedPointer<QuicAckListenerInterface> listener); // Indicates whether batch mode is currently enabled. bool InBatchMode();
diff --git a/net/quic/core/quic_packets.h b/net/quic/core/quic_packets.h index e83e7ac..a923121 100644 --- a/net/quic/core/quic_packets.h +++ b/net/quic/core/quic_packets.h
@@ -15,7 +15,6 @@ #include "base/logging.h" #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "base/strings/string_piece.h" #include "net/base/int128.h" #include "net/base/iovec.h"
diff --git a/net/quic/core/quic_session.cc b/net/quic/core/quic_session.cc index 94be951..047e528 100644 --- a/net/quic/core/quic_session.cc +++ b/net/quic/core/quic_session.cc
@@ -283,7 +283,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { // This check is an attempt to deal with potential memory corruption // in which |id| ends up set to 1 (the crypto stream id). If this happen // it might end up resulting in unencrypted stream data being sent.
diff --git a/net/quic/core/quic_session.h b/net/quic/core/quic_session.h index a471c56..621e8671 100644 --- a/net/quic/core/quic_session.h +++ b/net/quic/core/quic_session.h
@@ -122,7 +122,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // Called by streams when they want to close the stream in both directions. virtual void SendRstStream(QuicStreamId id,
diff --git a/net/quic/core/quic_session_test.cc b/net/quic/core/quic_session_test.cc index fa21afe7..5c5c58bb 100644 --- a/net/quic/core/quic_session_test.cc +++ b/net/quic/core/quic_session_test.cc
@@ -168,7 +168,8 @@ QuicIOVector data, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) override { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) override { QuicConsumedData consumed(data.total_length, fin); if (!writev_consumes_all_data_) { consumed = QuicSession::WritevData(stream, id, data, offset, fin,
diff --git a/net/quic/core/quic_spdy_session.cc b/net/quic/core/quic_spdy_session.cc index ba6a4192..646bd0e8 100644 --- a/net/quic/core/quic_spdy_session.cc +++ b/net/quic/core/quic_spdy_session.cc
@@ -74,7 +74,8 @@ SpdyHeaderBlock headers, bool fin, SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { return headers_stream_->WriteHeaders(id, std::move(headers), fin, priority, std::move(ack_notifier_delegate)); }
diff --git a/net/quic/core/quic_spdy_session.h b/net/quic/core/quic_spdy_session.h index 5eb7fda1..d5963f1 100644 --- a/net/quic/core/quic_spdy_session.h +++ b/net/quic/core/quic_spdy_session.h
@@ -65,7 +65,8 @@ SpdyHeaderBlock headers, bool fin, SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); QuicHeadersStream* headers_stream() { return headers_stream_.get(); }
diff --git a/net/quic/core/quic_spdy_stream.cc b/net/quic/core/quic_spdy_stream.cc index 0bbb982..f44d3fb 100644 --- a/net/quic/core/quic_spdy_stream.cc +++ b/net/quic/core/quic_spdy_stream.cc
@@ -61,7 +61,8 @@ size_t QuicSpdyStream::WriteHeaders( SpdyHeaderBlock header_block, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { size_t bytes_written = spdy_session_->WriteHeaders(id(), std::move(header_block), fin, priority_, std::move(ack_notifier_delegate)); @@ -76,13 +77,15 @@ void QuicSpdyStream::WriteOrBufferBody( const string& data, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { WriteOrBufferData(data, fin, std::move(ack_notifier_delegate)); } size_t QuicSpdyStream::WriteTrailers( SpdyHeaderBlock trailer_block, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { if (fin_sent()) { QUIC_BUG << "Trailers cannot be sent after a FIN."; return 0; @@ -332,7 +335,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { if (spdy_session_->headers_stream() != nullptr && spdy_session_->force_hol_blocking()) { return spdy_session_->headers_stream()->WritevStreamData(
diff --git a/net/quic/core/quic_spdy_stream.h b/net/quic/core/quic_spdy_stream.h index 783f2b1..41a5674 100644 --- a/net/quic/core/quic_spdy_stream.h +++ b/net/quic/core/quic_spdy_stream.h
@@ -105,19 +105,21 @@ virtual size_t WriteHeaders( SpdyHeaderBlock header_block, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // Sends |data| to the peer, or buffers if it can't be sent immediately. - void WriteOrBufferBody( - const std::string& data, - bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + void WriteOrBufferBody(const std::string& data, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // Writes the trailers contained in |trailer_block| to the dedicated // headers stream. Trailers will always have the FIN set. virtual size_t WriteTrailers( SpdyHeaderBlock trailer_block, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // Marks the trailers as consumed. This applies to the case where this object // receives headers and trailers as QuicHeaderLists via calls to @@ -201,7 +203,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) override; + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) override; private: friend class test::QuicSpdyStreamPeer;
diff --git a/net/quic/core/quic_stream.cc b/net/quic/core/quic_stream.cc index 403a1b1c..8a3d4a1 100644 --- a/net/quic/core/quic_stream.cc +++ b/net/quic/core/quic_stream.cc
@@ -43,7 +43,7 @@ QuicStream::PendingData::PendingData( string data_in, - scoped_refptr<QuicAckListenerInterface> ack_listener_in) + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener_in) : data(std::move(data_in)), offset(0), ack_listener(std::move(ack_listener_in)) {} @@ -182,7 +182,7 @@ void QuicStream::WriteOrBufferData( StringPiece data, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { if (data.empty() && !fin) { QUIC_BUG << "data.empty() && !fin"; return; @@ -219,7 +219,7 @@ bool fin = false; while (!queued_data_.empty()) { PendingData* pending_data = &queued_data_.front(); - scoped_refptr<QuicAckListenerInterface> ack_listener = + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener = pending_data->ack_listener; if (queued_data_.size() == 1 && fin_buffered_) { fin = true; @@ -270,7 +270,7 @@ const struct iovec* iov, int iov_count, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_listener) { + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { if (write_side_closed_) { DLOG(ERROR) << ENDPOINT << "Attempt to write when the write side is closed"; return QuicConsumedData(0, false); @@ -351,7 +351,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { return session()->WritevData(this, id(), iov, offset, fin, std::move(ack_notifier_delegate)); }
diff --git a/net/quic/core/quic_stream.h b/net/quic/core/quic_stream.h index 2ee785e..4220ba5 100644 --- a/net/quic/core/quic_stream.h +++ b/net/quic/core/quic_stream.h
@@ -25,7 +25,6 @@ #include <string> #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "base/strings/string_piece.h" #include "net/base/iovec.h" #include "net/quic/core/quic_flow_controller.h" @@ -34,6 +33,7 @@ #include "net/quic/core/quic_stream_sequencer.h" #include "net/quic/core/quic_types.h" #include "net/quic/platform/api/quic_export.h" +#include "net/quic/platform/api/quic_reference_counted.h" namespace net { @@ -184,9 +184,10 @@ // and then buffers any remaining data in queued_data_. // If fin is true: if it is immediately passed on to the session, // write_side_closed() becomes true, otherwise fin_buffered_ becomes true. - void WriteOrBufferData(base::StringPiece data, - bool fin, - scoped_refptr<QuicAckListenerInterface> ack_listener); + void WriteOrBufferData( + base::StringPiece data, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); // Sends as many bytes in the first |count| buffers of |iov| to the connection // as the connection will consume. @@ -197,7 +198,7 @@ const struct iovec* iov, int iov_count, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_listener); + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); // Allows override of the session level writev, for the force HOL // blocking experiment. @@ -205,7 +206,8 @@ QuicIOVector iov, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); // Close the write side of the socket. Further writes will fail. // Can be called by the subclass or internally. @@ -236,8 +238,9 @@ bool read_side_closed() const { return read_side_closed_; } struct PendingData { - PendingData(std::string data_in, - scoped_refptr<QuicAckListenerInterface> ack_listener_in); + PendingData( + std::string data_in, + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener_in); ~PendingData(); // Pending data to be written. @@ -246,7 +249,7 @@ size_t offset; // AckListener that should be notified when the pending data is acked. // Can be nullptr. - scoped_refptr<QuicAckListenerInterface> ack_listener; + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener; }; // Calls MaybeSendBlocked on the stream's flow controller and the connection
diff --git a/net/quic/core/quic_stream_test.cc b/net/quic/core/quic_stream_test.cc index 35de6ce..22b9a96d 100644 --- a/net/quic/core/quic_stream_test.cc +++ b/net/quic/core/quic_stream_test.cc
@@ -143,7 +143,7 @@ QuicIOVector /*iov*/, QuicStreamOffset /*offset*/, bool /*fin*/, - const scoped_refptr< + const QuicReferenceCountedPointer< QuicAckListenerInterface>& /*ack_notifier_delegate*/) { session_->CloseStream(id); return QuicConsumedData(1, false); @@ -387,15 +387,17 @@ // TODO(ianswett): It's not clear this method is still needed now that // ProxyAckNotifierDelegate has been removed. -void SaveAckListener(scoped_refptr<QuicAckListenerInterface>* listener_out, - scoped_refptr<QuicAckListenerInterface> listener) { +void SaveAckListener( + QuicReferenceCountedPointer<QuicAckListenerInterface>* listener_out, + QuicReferenceCountedPointer<QuicAckListenerInterface> listener) { *listener_out = std::move(listener); } TEST_F(QuicStreamTest, WriteOrBufferDataWithQuicAckNotifier) { Initialize(kShouldProcessData); - scoped_refptr<MockAckListener> delegate(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> delegate( + new StrictMock<MockAckListener>); const int kDataSize = 16 * 1024; const string kData(kDataSize, 'a'); @@ -408,7 +410,7 @@ stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); - scoped_refptr<QuicAckListenerInterface> ack_listener; + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener; EXPECT_CALL(*session_, WritevData(_, kTestStreamId, _, _, _, _)) .WillOnce(DoAll( @@ -439,7 +441,8 @@ TEST_F(QuicStreamTest, WriteOrBufferDataAckNotificationBeforeFlush) { Initialize(kShouldProcessData); - scoped_refptr<MockAckListener> ack_listener(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> ack_listener( + new StrictMock<MockAckListener>); const int kDataSize = 16 * 1024; const string kData(kDataSize, 'a'); @@ -450,7 +453,7 @@ stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); - scoped_refptr<QuicAckListenerInterface> proxy_delegate; + QuicReferenceCountedPointer<QuicAckListenerInterface> proxy_delegate; EXPECT_CALL(*session_, WritevData(stream_, kTestStreamId, _, _, _, _)) .WillOnce(DoAll( @@ -470,9 +473,10 @@ TEST_F(QuicStreamTest, WriteAndBufferDataWithAckNotiferNoBuffer) { Initialize(kShouldProcessData); - scoped_refptr<MockAckListener> delegate(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> delegate( + new StrictMock<MockAckListener>); - scoped_refptr<QuicAckListenerInterface> proxy_delegate; + QuicReferenceCountedPointer<QuicAckListenerInterface> proxy_delegate; EXPECT_CALL(*session_, WritevData(stream_, kTestStreamId, _, _, _, _)) .WillOnce(DoAll( @@ -486,9 +490,10 @@ TEST_F(QuicStreamTest, BufferOnWriteAndBufferDataWithAckNotifer) { Initialize(kShouldProcessData); - scoped_refptr<MockAckListener> delegate(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> delegate( + new StrictMock<MockAckListener>); - scoped_refptr<QuicAckListenerInterface> proxy_delegate; + QuicReferenceCountedPointer<QuicAckListenerInterface> proxy_delegate; EXPECT_CALL(*session_, WritevData(stream_, kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(0, false))); @@ -507,9 +512,10 @@ TEST_F(QuicStreamTest, WriteAndBufferDataWithAckNotiferOnlyFinRemains) { Initialize(kShouldProcessData); - scoped_refptr<MockAckListener> delegate(new StrictMock<MockAckListener>); + QuicReferenceCountedPointer<MockAckListener> delegate( + new StrictMock<MockAckListener>); - scoped_refptr<QuicAckListenerInterface> proxy_delegate; + QuicReferenceCountedPointer<QuicAckListenerInterface> proxy_delegate; EXPECT_CALL(*session_, WritevData(stream_, kTestStreamId, _, _, _, _)) .WillOnce(DoAll(
diff --git a/net/quic/platform/api/quic_reference_counted.h b/net/quic/platform/api/quic_reference_counted.h new file mode 100644 index 0000000..296fe48 --- /dev/null +++ b/net/quic/platform/api/quic_reference_counted.h
@@ -0,0 +1,161 @@ +// Copyright (c) 2016 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. + +#ifndef NET_QUIC_PLATFORM_API_QUIC_REFERENCE_COUNTED_H_ +#define NET_QUIC_PLATFORM_API_QUIC_REFERENCE_COUNTED_H_ + +#include "net/quic/platform/impl/quic_reference_counted_impl.h" + +namespace net { + +// Base class for explicitly reference-counted objects in QUIC. +class QUIC_EXPORT_PRIVATE QuicReferenceCounted + : public QuicReferenceCountedImpl { + public: + QuicReferenceCounted() {} + + protected: + ~QuicReferenceCounted() override {} +}; + +// A class representing a reference counted pointer in QUIC. +// +// Construct or initialize QuicReferenceCountedPointer from raw pointer. Here +// raw pointer MUST be a newly created object. Reference count of a newly +// created object is undefined, but that will be 1 after being added to +// QuicReferenceCountedPointer. +// QuicReferenceCountedPointer is used as a local variable. +// QuicReferenceCountedPointer<T> r_ptr(new T()); +// or, equivalently: +// QuicReferenceCountedPointer<T> r_ptr; +// T* p = new T(); +// r_ptr = T; +// +// QuicReferenceCountedPointer is used as a member variable: +// MyClass::MyClass() : r_ptr(new T()) {} +// +// This is WRONG, since *p is not guaranteed to be newly created: +// MyClass::MyClass(T* p) : r_ptr(p) {} +// +// Given an existing QuicReferenceCountedPointer, create a duplicate that has +// its own reference on the object: +// QuicReferenceCountedPointer<T> r_ptr_b(r_ptr_a); +// or, equivalently: +// QuicReferenceCountedPointer<T> r_ptr_b = r_ptr_a; +// +// Given an existing QuicReferenceCountedPointer, create a +// QuicReferenceCountedPointer that adopts the reference: +// QuicReferenceCountedPointer<T> r_ptr_b(std::move(r_ptr_a)); +// or, equivalently: +// QuicReferenceCountedPointer<T> r_ptr_b = std::move(r_ptr_a); + +template <class T> +class QuicReferenceCountedPointer { + public: + QuicReferenceCountedPointer() = default; + + // Constructor from raw pointer |p|. This guarantees the reference count of *p + // is 1. This should only be used when a new object is created, calling this + // on an already existent object is undefined behavior. + explicit QuicReferenceCountedPointer(T* p) : impl_(p) {} + + // Allows implicit conversion from nullptr. + QuicReferenceCountedPointer(std::nullptr_t) : impl_(nullptr) {} // NOLINT + + // Copy and copy conversion constructors. It does not take the reference away + // from |other| and they each end up with their own reference. + template <typename U> + QuicReferenceCountedPointer( // NOLINT + const QuicReferenceCountedPointer<U>& other) + : impl_(other.impl()) {} + QuicReferenceCountedPointer(const QuicReferenceCountedPointer& other) + : impl_(other.impl()) {} + + // Move constructors. After move, It adopts the reference from |other|. + template <typename U> + QuicReferenceCountedPointer(QuicReferenceCountedPointer<U>&& other) // NOLINT + : impl_(std::move(other.impl())) {} + QuicReferenceCountedPointer(QuicReferenceCountedPointer&& other) + : impl_(std::move(other.impl())) {} + + ~QuicReferenceCountedPointer() = default; + + // Copy assignments. + QuicReferenceCountedPointer& operator=( + const QuicReferenceCountedPointer& other) { + impl_ = other.impl(); + return *this; + } + template <typename U> + QuicReferenceCountedPointer<T>& operator=( + const QuicReferenceCountedPointer<U>& other) { + impl_ = other.impl(); + return *this; + } + + // Move assignments. + QuicReferenceCountedPointer& operator=(QuicReferenceCountedPointer&& other) { + impl_ = std::move(other.impl()); + return *this; + } + template <typename U> + QuicReferenceCountedPointer<T>& operator=( + QuicReferenceCountedPointer<U>&& other) { + impl_ = std::move(other.impl()); + return *this; + } + + // Accessors for the referenced object. + // operator* and operator-> will assert() if there is no current object. + T& operator*() const { return *impl_; } + T* operator->() const { return impl_.get(); } + + explicit operator bool() const { return static_cast<bool>(impl_); } + + // Assignment operator on raw pointer. Drops a reference to current pointee, + // if any and replaces it with |p|. This garantee the reference count of *p is + // 1. This should only be used when a new object is created, calling this + // on a already existent object is undefined behavior. + QuicReferenceCountedPointer<T>& operator=(T* p) { + impl_ = p; + return *this; + } + + // Returns the raw pointer with no change in reference. + T* get() const { return impl_.get(); } + + QuicReferenceCountedPointerImpl<T>& impl() { return impl_; } + const QuicReferenceCountedPointerImpl<T>& impl() const { return impl_; } + + // Comparisons against same type. + friend bool operator==(const QuicReferenceCountedPointer& a, + const QuicReferenceCountedPointer& b) { + return a.get() == b.get(); + } + friend bool operator!=(const QuicReferenceCountedPointer& a, + const QuicReferenceCountedPointer& b) { + return a.get() != b.get(); + } + + // Comparisons against nullptr. + friend bool operator==(const QuicReferenceCountedPointer& a, std::nullptr_t) { + return a.get() == nullptr; + } + friend bool operator==(std::nullptr_t, const QuicReferenceCountedPointer& b) { + return nullptr == b.get(); + } + friend bool operator!=(const QuicReferenceCountedPointer& a, std::nullptr_t) { + return a.get() != nullptr; + } + friend bool operator!=(std::nullptr_t, const QuicReferenceCountedPointer& b) { + return nullptr != b.get(); + } + + private: + QuicReferenceCountedPointerImpl<T> impl_; +}; + +} // namespace net + +#endif // NET_QUIC_PLATFORM_API_QUIC_REFERENCE_COUNTED_H_
diff --git a/net/quic/platform/api/quic_reference_counted_test.cc b/net/quic/platform/api/quic_reference_counted_test.cc new file mode 100644 index 0000000..8f46094b --- /dev/null +++ b/net/quic/platform/api/quic_reference_counted_test.cc
@@ -0,0 +1,173 @@ +// Copyright (c) 2016 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. + +#include "net/quic/platform/api/quic_reference_counted.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace net { +namespace test { +namespace { + +class Base : public QuicReferenceCounted { + public: + explicit Base(bool* destroyed) : destroyed_(destroyed) { + *destroyed_ = false; + } + + bool destroyed() const { return *destroyed_; } + + protected: + ~Base() override { *destroyed_ = true; } + + private: + bool* destroyed_; +}; + +class Derived : public Base { + public: + explicit Derived(bool* destroyed) : Base(destroyed) {} + + private: + ~Derived() override {} +}; + +TEST(QuicReferenceCountedTest, DefaultConstructor) { + QuicReferenceCountedPointer<Base> a; + EXPECT_EQ(nullptr, a); + EXPECT_EQ(nullptr, a.get()); + EXPECT_FALSE(a); +} + +TEST(QuicReferenceCountedTest, ConstructFromRawPointer) { + bool destroyed = false; + { + QuicReferenceCountedPointer<Base> a(new Base(&destroyed)); + EXPECT_FALSE(destroyed); + } + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, RawPointerAssignment) { + bool destroyed = false; + { + QuicReferenceCountedPointer<Base> a; + Base* rct = new Base(&destroyed); + a = rct; + EXPECT_FALSE(destroyed); + } + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerCopy) { + bool destroyed = false; + { + QuicReferenceCountedPointer<Base> a(new Base(&destroyed)); + { + QuicReferenceCountedPointer<Base> b(a); + EXPECT_EQ(a, b); + EXPECT_FALSE(destroyed); + } + EXPECT_FALSE(destroyed); + } + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerCopyAssignment) { + bool destroyed = false; + { + QuicReferenceCountedPointer<Base> a(new Base(&destroyed)); + { + QuicReferenceCountedPointer<Base> b = a; + EXPECT_EQ(a, b); + EXPECT_FALSE(destroyed); + } + EXPECT_FALSE(destroyed); + } + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerCopyFromOtherType) { + bool destroyed = false; + { + QuicReferenceCountedPointer<Derived> a(new Derived(&destroyed)); + { + QuicReferenceCountedPointer<Base> b(a); + EXPECT_EQ(a.get(), b.get()); + EXPECT_FALSE(destroyed); + } + EXPECT_FALSE(destroyed); + } + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerCopyAssignmentFromOtherType) { + bool destroyed = false; + { + QuicReferenceCountedPointer<Derived> a(new Derived(&destroyed)); + { + QuicReferenceCountedPointer<Base> b = a; + EXPECT_EQ(a.get(), b.get()); + EXPECT_FALSE(destroyed); + } + EXPECT_FALSE(destroyed); + } + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerMove) { + bool destroyed = false; + QuicReferenceCountedPointer<Base> a(new Derived(&destroyed)); + EXPECT_FALSE(destroyed); + QuicReferenceCountedPointer<Base> b(std::move(a)); + EXPECT_FALSE(destroyed); + EXPECT_NE(nullptr, b); + EXPECT_EQ(nullptr, a); // NOLINT + + b = nullptr; + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerMoveAssignment) { + bool destroyed = false; + QuicReferenceCountedPointer<Base> a(new Derived(&destroyed)); + EXPECT_FALSE(destroyed); + QuicReferenceCountedPointer<Base> b = std::move(a); + EXPECT_FALSE(destroyed); + EXPECT_NE(nullptr, b); + EXPECT_EQ(nullptr, a); // NOLINT + + b = nullptr; + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerMoveFromOtherType) { + bool destroyed = false; + QuicReferenceCountedPointer<Derived> a(new Derived(&destroyed)); + EXPECT_FALSE(destroyed); + QuicReferenceCountedPointer<Base> b(std::move(a)); + EXPECT_FALSE(destroyed); + EXPECT_NE(nullptr, b); + EXPECT_EQ(nullptr, a); // NOLINT + + b = nullptr; + EXPECT_TRUE(destroyed); +} + +TEST(QuicReferenceCountedTest, PointerMoveAssignmentFromOtherType) { + bool destroyed = false; + QuicReferenceCountedPointer<Derived> a(new Derived(&destroyed)); + EXPECT_FALSE(destroyed); + QuicReferenceCountedPointer<Base> b = std::move(a); + EXPECT_FALSE(destroyed); + EXPECT_NE(nullptr, b); + EXPECT_EQ(nullptr, a); // NOLINT + + b = nullptr; + EXPECT_TRUE(destroyed); +} + +} // namespace +} // namespace test +} // namespace net
diff --git a/net/quic/platform/impl/quic_mutex_impl.h b/net/quic/platform/impl/quic_mutex_impl.h index fae020a7..8053514e 100644 --- a/net/quic/platform/impl/quic_mutex_impl.h +++ b/net/quic/platform/impl/quic_mutex_impl.h
@@ -36,6 +36,10 @@ #define GUARDED_BY(x) #endif +#ifndef SHARED_LOCKS_REQUIRED +#define SHARED_LOCKS_REQUIRED(...) +#endif + namespace net { // A class wrapping a non-reentrant mutex.
diff --git a/net/quic/platform/impl/quic_reference_counted_impl.h b/net/quic/platform/impl/quic_reference_counted_impl.h new file mode 100644 index 0000000..0edd3c6 --- /dev/null +++ b/net/quic/platform/impl/quic_reference_counted_impl.h
@@ -0,0 +1,114 @@ +// Copyright (c) 2016 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. + +#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_REFERENCE_COUNTED_IMPL_H_ +#define NET_QUIC_PLATFORM_IMPL_QUIC_REFERENCE_COUNTED_IMPL_H_ + +#include "base/memory/ref_counted.h" +#include "net/quic/platform/api/quic_export.h" + +namespace net { + +class QUIC_EXPORT_PRIVATE QuicReferenceCountedImpl + : public base::RefCountedThreadSafe<QuicReferenceCountedImpl> { + public: + QuicReferenceCountedImpl() {} + + protected: + virtual ~QuicReferenceCountedImpl() {} + + private: + friend class base::RefCountedThreadSafe<QuicReferenceCountedImpl>; +}; + +template <class T> +class QuicReferenceCountedPointerImpl { + public: + QuicReferenceCountedPointerImpl() = default; + + // Constructor from raw pointer |p|. This guarantees the reference count of *p + // is 1. This should be only called when a new object is created, calling this + // on an already existent object does not increase its reference count. + explicit QuicReferenceCountedPointerImpl(T* p) : refptr_(p) {} + + // Allows implicit conversion from nullptr. + QuicReferenceCountedPointerImpl(std::nullptr_t) // NOLINT + : refptr_(nullptr) {} + + // Copy and copy conversion constructors. It does not take the reference away + // from |other| and they each end up with their own reference. + template <typename U> + QuicReferenceCountedPointerImpl( // NOLINT + const QuicReferenceCountedPointerImpl<U>& other) + : refptr_(other.refptr()) {} + QuicReferenceCountedPointerImpl(const QuicReferenceCountedPointerImpl& other) + : refptr_(other.refptr()) {} + + // Move constructors. After move, It adopts the reference from |other|. + template <typename U> + QuicReferenceCountedPointerImpl( // NOLINT + QuicReferenceCountedPointerImpl<U>&& other) + : refptr_(std::move(other.refptr())) {} + QuicReferenceCountedPointerImpl(QuicReferenceCountedPointerImpl&& other) + : refptr_(std::move(other.refptr())) {} + + ~QuicReferenceCountedPointerImpl() = default; + + // Copy assignments. + QuicReferenceCountedPointerImpl& operator=( + const QuicReferenceCountedPointerImpl& other) { + refptr_ = other.refptr(); + return *this; + } + template <typename U> + QuicReferenceCountedPointerImpl<T>& operator=( + const QuicReferenceCountedPointerImpl<U>& other) { + refptr_ = other.refptr(); + return *this; + } + + // Move assignments. + QuicReferenceCountedPointerImpl& operator=( + QuicReferenceCountedPointerImpl&& other) { + refptr_ = std::move(other.refptr()); + return *this; + } + template <typename U> + QuicReferenceCountedPointerImpl<T>& operator=( + QuicReferenceCountedPointerImpl<U>&& other) { + refptr_ = std::move(other.refptr()); + return *this; + } + + explicit operator bool() const { return static_cast<bool>(refptr_); } + + // Assignment operator on raw pointer. Drops a reference to current pointee, + // if any and replaces it with |p|. This garantee the reference count of *p is + // 1. This should only be used when a new object is created, calling this + // on a already existent object does not increase its reference count. + QuicReferenceCountedPointerImpl<T>& operator=(T* p) { + refptr_ = p; + return *this; + } + // Returns the raw pointer with no change in reference. + T* get() const { return refptr_.get(); } + + // Accessors for the referenced object. + // operator* and operator-> will assert() if there is no current object. + T& operator*() const { return *refptr_; } + T* operator->() const { + assert(refptr_ != nullptr); + return refptr_.get(); + } + + scoped_refptr<T>& refptr() { return refptr_; } + const scoped_refptr<T>& refptr() const { return refptr_; } + + private: + scoped_refptr<T> refptr_; +}; + +} // namespace net + +#endif // NET_QUIC_PLATFORM_IMPL_QUIC_REFERENCE_COUNTED_IMPL_H_
diff --git a/net/quic/quartc/quartc_session.cc b/net/quic/quartc/quartc_session.cc index 5f9ca349..e31f72b 100644 --- a/net/quic/quartc/quartc_session.cc +++ b/net/quic/quartc/quartc_session.cc
@@ -28,14 +28,15 @@ ~DummyProofSource() override {} // ProofSource override. - bool GetProof(const net::QuicSocketAddress& server_addr, - const std::string& hostname, - const std::string& server_config, - net::QuicVersion quic_version, - base::StringPiece chlo_hash, - const net::QuicTagVector& connection_options, - scoped_refptr<net::ProofSource::Chain>* out_chain, - net::QuicCryptoProof* proof) override { + bool GetProof( + const net::QuicSocketAddress& server_addr, + const std::string& hostname, + const std::string& server_config, + net::QuicVersion quic_version, + base::StringPiece chlo_hash, + const net::QuicTagVector& connection_options, + net::QuicReferenceCountedPointer<net::ProofSource::Chain>* out_chain, + net::QuicCryptoProof* proof) override { std::vector<std::string> certs; certs.push_back("Dummy cert"); *out_chain = new ProofSource::Chain(certs);
diff --git a/net/quic/quartc/quartc_session_test.cc b/net/quic/quartc/quartc_session_test.cc index a9eb65d..dd8db24 100644 --- a/net/quic/quartc/quartc_session_test.cc +++ b/net/quic/quartc/quartc_session_test.cc
@@ -58,7 +58,7 @@ net::QuicVersion quic_version, base::StringPiece chlo_hash, const net::QuicTagVector& connection_options, - scoped_refptr<net::ProofSource::Chain>* out_certs, + QuicReferenceCountedPointer<net::ProofSource::Chain>* out_certs, net::QuicCryptoProof* proof) override { if (success_) { std::vector<std::string> certs;
diff --git a/net/quic/quartc/quartc_stream_test.cc b/net/quic/quartc/quartc_stream_test.cc index fdafe221..c074be8a 100644 --- a/net/quic/quartc/quartc_stream_test.cc +++ b/net/quic/quartc/quartc_stream_test.cc
@@ -38,8 +38,8 @@ QuicIOVector iovector, QuicStreamOffset offset, bool fin, - scoped_refptr<QuicAckListenerInterface> /*ack_notifier_delegate*/) - override { + QuicReferenceCountedPointer< + QuicAckListenerInterface> /*ack_notifier_delegate*/) override { if (!writable_) { return QuicConsumedData(0, false); }
diff --git a/net/quic/test_tools/crypto_test_utils.cc b/net/quic/test_tools/crypto_test_utils.cc index 0f756f0e..416ea3d 100644 --- a/net/quic/test_tools/crypto_test_utils.cc +++ b/net/quic/test_tools/crypto_test_utils.cc
@@ -274,13 +274,14 @@ // CHLO. class FullChloGenerator { public: - FullChloGenerator(QuicCryptoServerConfig* crypto_config, - QuicSocketAddress server_addr, - QuicSocketAddress client_addr, - const QuicClock* clock, - scoped_refptr<QuicSignedServerConfig> signed_config, - QuicCompressedCertsCache* compressed_certs_cache, - CryptoHandshakeMessage* out) + FullChloGenerator( + QuicCryptoServerConfig* crypto_config, + QuicSocketAddress server_addr, + QuicSocketAddress client_addr, + const QuicClock* clock, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, + QuicCompressedCertsCache* compressed_certs_cache, + CryptoHandshakeMessage* out) : crypto_config_(crypto_config), server_addr_(server_addr), client_addr_(client_addr), @@ -294,7 +295,8 @@ public: explicit ValidateClientHelloCallback(FullChloGenerator* generator) : generator_(generator) {} - void Run(scoped_refptr<ValidateClientHelloResultCallback::Result> result, + void Run(QuicReferenceCountedPointer< + ValidateClientHelloResultCallback::Result> result, std::unique_ptr<ProofSource::Details> /* details */) override { generator_->ValidateClientHelloDone(std::move(result)); } @@ -311,7 +313,8 @@ private: void ValidateClientHelloDone( - scoped_refptr<ValidateClientHelloResultCallback::Result> result) { + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result) { result_ = result; crypto_config_->ProcessClientHello( result_, /*reject_only=*/false, /*connection_id=*/1, server_addr_, @@ -373,12 +376,13 @@ QuicSocketAddress server_addr_; QuicSocketAddress client_addr_; const QuicClock* clock_; - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; QuicCompressedCertsCache* compressed_certs_cache_; CryptoHandshakeMessage* out_; - scoped_refptr<QuicCryptoNegotiatedParameters> params_; - scoped_refptr<ValidateClientHelloResultCallback::Result> result_; + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result_; }; } // namespace @@ -565,7 +569,7 @@ } uint64_t CryptoTestUtils::LeafCertHashForTesting() { - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; QuicSocketAddress server_address; QuicCryptoProof proof; std::unique_ptr<ProofSource> proof_source( @@ -1006,7 +1010,7 @@ QuicSocketAddress client_addr, QuicVersion version, const QuicClock* clock, - scoped_refptr<QuicSignedServerConfig> proof, + QuicReferenceCountedPointer<QuicSignedServerConfig> proof, QuicCompressedCertsCache* compressed_certs_cache, CryptoHandshakeMessage* out) { // Pass a inchoate CHLO.
diff --git a/net/quic/test_tools/crypto_test_utils.h b/net/quic/test_tools/crypto_test_utils.h index cf82a0d8..7189ae1 100644 --- a/net/quic/test_tools/crypto_test_utils.h +++ b/net/quic/test_tools/crypto_test_utils.h
@@ -225,7 +225,7 @@ QuicSocketAddress client_addr, QuicVersion version, const QuicClock* clock, - scoped_refptr<QuicSignedServerConfig> signed_config, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, QuicCompressedCertsCache* compressed_certs_cache, CryptoHandshakeMessage* out);
diff --git a/net/quic/test_tools/crypto_test_utils_test.cc b/net/quic/test_tools/crypto_test_utils_test.cc index b8f662d5..03385567 100644 --- a/net/quic/test_tools/crypto_test_utils_test.cc +++ b/net/quic/test_tools/crypto_test_utils_test.cc
@@ -18,12 +18,13 @@ class ShloVerifier { public: - ShloVerifier(QuicCryptoServerConfig* crypto_config, - QuicSocketAddress server_addr, - QuicSocketAddress client_addr, - const QuicClock* clock, - scoped_refptr<QuicSignedServerConfig> signed_config, - QuicCompressedCertsCache* compressed_certs_cache) + ShloVerifier( + QuicCryptoServerConfig* crypto_config, + QuicSocketAddress server_addr, + QuicSocketAddress client_addr, + const QuicClock* clock, + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, + QuicCompressedCertsCache* compressed_certs_cache) : crypto_config_(crypto_config), server_addr_(server_addr), client_addr_(client_addr), @@ -36,7 +37,8 @@ public: explicit ValidateClientHelloCallback(ShloVerifier* shlo_verifier) : shlo_verifier_(shlo_verifier) {} - void Run(scoped_refptr<ValidateClientHelloResultCallback::Result> result, + void Run(QuicReferenceCountedPointer< + ValidateClientHelloResultCallback::Result> result, std::unique_ptr<ProofSource::Details> /* details */) override { shlo_verifier_->ValidateClientHelloDone(result); } @@ -53,7 +55,8 @@ private: void ValidateClientHelloDone( - const scoped_refptr<ValidateClientHelloResultCallback::Result>& result) { + const QuicReferenceCountedPointer< + ValidateClientHelloResultCallback::Result>& result) { result_ = result; crypto_config_->ProcessClientHello( result_, /*reject_only=*/false, /*connection_id=*/1, server_addr_, @@ -96,11 +99,12 @@ QuicSocketAddress server_addr_; QuicSocketAddress client_addr_; const QuicClock* clock_; - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; QuicCompressedCertsCache* compressed_certs_cache_; - scoped_refptr<QuicCryptoNegotiatedParameters> params_; - scoped_refptr<ValidateClientHelloResultCallback::Result> result_; + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result_; }; TEST(CryptoTestUtilsTest, TestGenerateFullCHLO) { @@ -110,7 +114,7 @@ CryptoTestUtils::ProofSourceForTesting()); QuicSocketAddress server_addr; QuicSocketAddress client_addr(QuicIpAddress::Loopback4(), 1); - scoped_refptr<QuicSignedServerConfig> signed_config( + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config( new QuicSignedServerConfig); QuicCompressedCertsCache compressed_certs_cache( QuicCompressedCertsCache::kQuicCompressedCertsCacheSize);
diff --git a/net/quic/test_tools/fake_proof_source.cc b/net/quic/test_tools/fake_proof_source.cc index 8f64222..8507b87 100644 --- a/net/quic/test_tools/fake_proof_source.cc +++ b/net/quic/test_tools/fake_proof_source.cc
@@ -41,14 +41,15 @@ active_ = true; } -bool FakeProofSource::GetProof(const QuicSocketAddress& server_address, - const string& hostname, - const string& server_config, - QuicVersion quic_version, - StringPiece chlo_hash, - const QuicTagVector& connection_options, - scoped_refptr<ProofSource::Chain>* out_chain, - QuicCryptoProof* out_proof) { +bool FakeProofSource::GetProof( + const QuicSocketAddress& server_address, + const string& hostname, + const string& server_config, + QuicVersion quic_version, + StringPiece chlo_hash, + const QuicTagVector& connection_options, + QuicReferenceCountedPointer<ProofSource::Chain>* out_chain, + QuicCryptoProof* out_proof) { LOG(WARNING) << "Synchronous GetProof called"; return delegate_->GetProof(server_address, hostname, server_config, quic_version, chlo_hash, connection_options, @@ -64,7 +65,7 @@ const QuicTagVector& connection_options, std::unique_ptr<ProofSource::Callback> callback) { if (!active_) { - scoped_refptr<Chain> chain; + QuicReferenceCountedPointer<Chain> chain; QuicCryptoProof proof; const bool ok = GetProof(server_address, hostname, server_config, quic_version, @@ -88,7 +89,7 @@ const Params& params = params_[n]; - scoped_refptr<ProofSource::Chain> chain; + QuicReferenceCountedPointer<ProofSource::Chain> chain; QuicCryptoProof proof; const bool ok = delegate_->GetProof( params.server_address, params.hostname, params.server_config,
diff --git a/net/quic/test_tools/fake_proof_source.h b/net/quic/test_tools/fake_proof_source.h index fb1c3a3a..776466d 100644 --- a/net/quic/test_tools/fake_proof_source.h +++ b/net/quic/test_tools/fake_proof_source.h
@@ -36,7 +36,7 @@ QuicVersion quic_version, base::StringPiece chlo_hash, const QuicTagVector& connection_options, - scoped_refptr<ProofSource::Chain>* out_chain, + QuicReferenceCountedPointer<ProofSource::Chain>* out_chain, QuicCryptoProof* out_proof) override; void GetProof(const QuicSocketAddress& server_address, const std::string& hostname,
diff --git a/net/quic/test_tools/quic_crypto_server_config_peer.cc b/net/quic/test_tools/quic_crypto_server_config_peer.cc index 95a3c1b2..3856b9f8e 100644 --- a/net/quic/test_tools/quic_crypto_server_config_peer.cc +++ b/net/quic/test_tools/quic_crypto_server_config_peer.cc
@@ -20,18 +20,18 @@ return server_config_->proof_source_.get(); } -scoped_refptr<QuicCryptoServerConfig::Config> +QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> QuicCryptoServerConfigPeer::GetPrimaryConfig() { QuicReaderMutexLock locked(&server_config_->configs_lock_); - return scoped_refptr<QuicCryptoServerConfig::Config>( + return QuicReferenceCountedPointer<QuicCryptoServerConfig::Config>( server_config_->primary_config_); } -scoped_refptr<QuicCryptoServerConfig::Config> +QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> QuicCryptoServerConfigPeer::GetConfig(string config_id) { QuicReaderMutexLock locked(&server_config_->configs_lock_); if (config_id == "<primary>") { - return scoped_refptr<QuicCryptoServerConfig::Config>( + return QuicReferenceCountedPointer<QuicCryptoServerConfig::Config>( server_config_->primary_config_); } else { return server_config_->GetConfigWithScid(config_id); @@ -124,8 +124,9 @@ ASSERT_EQ(expected.size(), server_config_->configs_.size()) << ConfigsDebug(); - for (const std::pair<const ServerConfigID, - scoped_refptr<QuicCryptoServerConfig::Config>>& i : + for (const std::pair< + const ServerConfigID, + QuicReferenceCountedPointer<QuicCryptoServerConfig::Config>>& i : server_config_->configs_) { bool found = false; for (std::pair<ServerConfigID, bool>& j : expected) { @@ -152,7 +153,8 @@ string s; for (const auto& i : server_config_->configs_) { - const scoped_refptr<QuicCryptoServerConfig::Config> config = i.second; + const QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> config = + i.second; if (config->is_primary) { s += "(primary) "; } else { @@ -173,7 +175,7 @@ string QuicCryptoServerConfigPeer::CompressChain( QuicCompressedCertsCache* compressed_certs_cache, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const string& client_common_set_hashes, const string& client_cached_cert_hashes, const CommonCertSets* common_sets) {
diff --git a/net/quic/test_tools/quic_crypto_server_config_peer.h b/net/quic/test_tools/quic_crypto_server_config_peer.h index 8c799a0e..1f522d3 100644 --- a/net/quic/test_tools/quic_crypto_server_config_peer.h +++ b/net/quic/test_tools/quic_crypto_server_config_peer.h
@@ -21,10 +21,11 @@ ProofSource* GetProofSource(); // Returns the primary config. - scoped_refptr<QuicCryptoServerConfig::Config> GetPrimaryConfig(); + QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> + GetPrimaryConfig(); // Returns the config associated with |config_id|. - scoped_refptr<QuicCryptoServerConfig::Config> GetConfig( + QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> GetConfig( std::string config_id); // Returns a pointer to the ProofSource object. @@ -82,7 +83,7 @@ static std::string CompressChain( QuicCompressedCertsCache* compressed_certs_cache, - const scoped_refptr<ProofSource::Chain>& chain, + const QuicReferenceCountedPointer<ProofSource::Chain>& chain, const std::string& client_common_set_hashes, const std::string& client_cached_cert_hashes, const CommonCertSets* common_sets);
diff --git a/net/quic/test_tools/quic_stream_peer.cc b/net/quic/test_tools/quic_stream_peer.cc index 8deea1b..8e7db46 100644 --- a/net/quic/test_tools/quic_stream_peer.cc +++ b/net/quic/test_tools/quic_stream_peer.cc
@@ -88,7 +88,8 @@ QuicStream* stream, StringPiece data, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) { stream->WriteOrBufferData(data, fin, std::move(ack_notifier_delegate)); }
diff --git a/net/quic/test_tools/quic_stream_peer.h b/net/quic/test_tools/quic_stream_peer.h index e8aeda5e..0ddb373a 100644 --- a/net/quic/test_tools/quic_stream_peer.h +++ b/net/quic/test_tools/quic_stream_peer.h
@@ -42,7 +42,8 @@ QuicStream* stream, base::StringPiece data, bool fin, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate); static net::QuicStreamSequencer* sequencer(QuicStream* stream);
diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc index 7cc110c..b99c7f1 100644 --- a/net/quic/test_tools/quic_test_utils.cc +++ b/net/quic/test_tools/quic_test_utils.cc
@@ -376,7 +376,8 @@ const QuicIOVector& data, QuicStreamOffset /*offset*/, bool fin, - const scoped_refptr<QuicAckListenerInterface>& /*ack_notifier_delegate*/) { + const QuicReferenceCountedPointer< + QuicAckListenerInterface>& /*ack_notifier_delegate*/) { return QuicConsumedData(data.total_length, fin); }
diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h index 0d1c90ac..2c3d17f 100644 --- a/net/quic/test_tools/quic_test_utils.h +++ b/net/quic/test_tools/quic_test_utils.h
@@ -512,13 +512,14 @@ MOCK_METHOD1(CreateOutgoingDynamicStream, QuicStream*(SpdyPriority priority)); MOCK_METHOD1(ShouldCreateIncomingDynamicStream, bool(QuicStreamId id)); MOCK_METHOD0(ShouldCreateOutgoingDynamicStream, bool()); - MOCK_METHOD6(WritevData, - QuicConsumedData(QuicStream* stream, - QuicStreamId id, - QuicIOVector data, - QuicStreamOffset offset, - bool fin, - scoped_refptr<QuicAckListenerInterface>)); + MOCK_METHOD6( + WritevData, + QuicConsumedData(QuicStream* stream, + QuicStreamId id, + QuicIOVector data, + QuicStreamOffset offset, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface>)); MOCK_METHOD3(SendRstStream, void(QuicStreamId stream_id, @@ -543,7 +544,8 @@ const QuicIOVector& data, QuicStreamOffset offset, bool fin, - const scoped_refptr<QuicAckListenerInterface>& ack_notifier_delegate); + const QuicReferenceCountedPointer<QuicAckListenerInterface>& + ack_notifier_delegate); private: std::unique_ptr<QuicCryptoStream> crypto_stream_; @@ -572,12 +574,13 @@ MOCK_METHOD0(ShouldCreateOutgoingDynamicStream, bool()); MOCK_METHOD6( WritevData, - QuicConsumedData(QuicStream* stream, - QuicStreamId id, - QuicIOVector data, - QuicStreamOffset offset, - bool fin, - scoped_refptr<QuicAckListenerInterface> ack_listener)); + QuicConsumedData( + QuicStream* stream, + QuicStreamId id, + QuicIOVector data, + QuicStreamOffset offset, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener)); MOCK_METHOD3(SendRstStream, void(QuicStreamId stream_id, @@ -609,23 +612,24 @@ const QuicHeaderList& header_list)); // Methods taking non-copyable types like SpdyHeaderBlock by value cannot be // mocked directly. - size_t WriteHeaders( - QuicStreamId id, - SpdyHeaderBlock headers, - bool fin, - SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) override { + size_t WriteHeaders(QuicStreamId id, + SpdyHeaderBlock headers, + bool fin, + SpdyPriority priority, + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) override { write_headers_ = std::move(headers); return WriteHeadersMock(id, write_headers_, fin, priority, ack_notifier_delegate); } - MOCK_METHOD5(WriteHeadersMock, - size_t(QuicStreamId id, - const SpdyHeaderBlock& headers, - bool fin, - SpdyPriority priority, - const scoped_refptr<QuicAckListenerInterface>& - ack_notifier_delegate)); + MOCK_METHOD5( + WriteHeadersMock, + size_t(QuicStreamId id, + const SpdyHeaderBlock& headers, + bool fin, + SpdyPriority priority, + const QuicReferenceCountedPointer<QuicAckListenerInterface>& + ack_notifier_delegate)); MOCK_METHOD1(OnHeadersHeadOfLineBlocking, void(QuicTime::Delta delta)); MOCK_METHOD4( OnStreamFrameData,
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc index 66abfea..40166e2 100644 --- a/net/tools/quic/end_to_end_test.cc +++ b/net/tools/quic/end_to_end_test.cc
@@ -1974,7 +1974,7 @@ client_->SendMessage(headers, "", /*fin=*/false); // The TestAckListener will cause a failure if not notified. - scoped_refptr<TestAckListener> delegate(new TestAckListener(2)); + QuicReferenceCountedPointer<TestAckListener> delegate(new TestAckListener(2)); // Test the AckNotifier's ability to track multiple packets by making the // request body exceed the size of a single packet.
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc index 0de4d382..d5fbaeb 100644 --- a/net/tools/quic/quic_dispatcher_test.cc +++ b/net/tools/quic/quic_dispatcher_test.cc
@@ -1160,7 +1160,7 @@ protected: QuicSocketAddress server_addr_; QuicSocketAddress client_addr_; - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; const QuicClock* clock_; CryptoHandshakeMessage full_chlo_; }; @@ -1649,7 +1649,7 @@ private: QuicCryptoServerConfigPeer crypto_config_peer_; QuicSocketAddress server_addr_; - scoped_refptr<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; const QuicClock* clock_; CryptoHandshakeMessage chlo_; CryptoHandshakeMessage full_chlo_;
diff --git a/net/tools/quic/quic_simple_server_session_test.cc b/net/tools/quic/quic_simple_server_session_test.cc index d857bee9..cc9ff32 100644 --- a/net/tools/quic/quic_simple_server_session_test.cc +++ b/net/tools/quic/quic_simple_server_session_test.cc
@@ -79,12 +79,12 @@ QuicStreamId promised_stream_id, const SpdyHeaderBlock& headers)); - size_t WriteHeaders( - QuicStreamId stream_id, - SpdyHeaderBlock headers, - bool fin, - SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_listener) override { + size_t WriteHeaders(QuicStreamId stream_id, + SpdyHeaderBlock headers, + bool fin, + SpdyPriority priority, + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_listener) override { return WriteHeadersMock(stream_id, headers, fin, priority, ack_listener); } MOCK_METHOD5( @@ -93,7 +93,8 @@ const SpdyHeaderBlock& headers, bool fin, SpdyPriority priority, - const scoped_refptr<QuicAckListenerInterface>& ack_listener)); + const QuicReferenceCountedPointer<QuicAckListenerInterface>& + ack_listener)); }; class MockQuicCryptoServerStream : public QuicCryptoServerStream { @@ -135,11 +136,12 @@ MOCK_METHOD5( SendStreamData, - QuicConsumedData(QuicStreamId id, - QuicIOVector iov, - QuicStreamOffset offset, - bool fin, - scoped_refptr<QuicAckListenerInterface> listern)); + QuicConsumedData( + QuicStreamId id, + QuicIOVector iov, + QuicStreamOffset offset, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface> listern)); }; class QuicSimpleServerSessionPeer {
diff --git a/net/tools/quic/quic_simple_server_stream_test.cc b/net/tools/quic/quic_simple_server_stream_test.cc index 1e25037..14210b7 100644 --- a/net/tools/quic/quic_simple_server_stream_test.cc +++ b/net/tools/quic/quic_simple_server_stream_test.cc
@@ -117,13 +117,14 @@ const string& error_details, ConnectionCloseSource source)); MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); - MOCK_METHOD6(WritevData, - QuicConsumedData(QuicStream* stream, - QuicStreamId id, - QuicIOVector data, - QuicStreamOffset offset, - bool fin, - scoped_refptr<QuicAckListenerInterface>)); + MOCK_METHOD6( + WritevData, + QuicConsumedData(QuicStream* stream, + QuicStreamId id, + QuicIOVector data, + QuicStreamOffset offset, + bool fin, + QuicReferenceCountedPointer<QuicAckListenerInterface>)); MOCK_METHOD4(OnStreamHeaderList, void(QuicStreamId stream_id, bool fin, @@ -133,21 +134,22 @@ void(QuicStreamId stream_id, SpdyPriority priority)); // Methods taking non-copyable types like SpdyHeaderBlock by value cannot be // mocked directly. - size_t WriteHeaders( - QuicStreamId id, - SpdyHeaderBlock headers, - bool fin, - SpdyPriority priority, - scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate) override { - return WriteHeadersMock(id, headers, fin, priority, ack_notifier_delegate); - } - MOCK_METHOD5(WriteHeadersMock, - size_t(QuicStreamId id, - const SpdyHeaderBlock& headers, + size_t WriteHeaders(QuicStreamId id, + SpdyHeaderBlock headers, bool fin, SpdyPriority priority, - const scoped_refptr<QuicAckListenerInterface>& - ack_notifier_delegate)); + QuicReferenceCountedPointer<QuicAckListenerInterface> + ack_notifier_delegate) override { + return WriteHeadersMock(id, headers, fin, priority, ack_notifier_delegate); + } + MOCK_METHOD5( + WriteHeadersMock, + size_t(QuicStreamId id, + const SpdyHeaderBlock& headers, + bool fin, + SpdyPriority priority, + const QuicReferenceCountedPointer<QuicAckListenerInterface>& + ack_notifier_delegate)); MOCK_METHOD3(SendRstStream, void(QuicStreamId stream_id, QuicRstStreamErrorCode error,
diff --git a/net/tools/quic/stateless_rejector.cc b/net/tools/quic/stateless_rejector.cc index e16d2ce..e8d0a02 100644 --- a/net/tools/quic/stateless_rejector.cc +++ b/net/tools/quic/stateless_rejector.cc
@@ -20,7 +20,7 @@ ~ValidateCallback() override {} - void Run(scoped_refptr<Result> result, + void Run(QuicReferenceCountedPointer<Result> result, std::unique_ptr<ProofSource::Details> /* proof_source_details */) override { StatelessRejector* rejector_ptr = rejector_.get(); @@ -120,7 +120,8 @@ }; void StatelessRejector::ProcessClientHello( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<StatelessRejector> rejector, std::unique_ptr<StatelessRejector::ProcessDoneCallback> done_cb) { std::unique_ptr<ProcessClientHelloCallback> cb(
diff --git a/net/tools/quic/stateless_rejector.h b/net/tools/quic/stateless_rejector.h index a3876d7..f177162 100644 --- a/net/tools/quic/stateless_rejector.h +++ b/net/tools/quic/stateless_rejector.h
@@ -79,7 +79,8 @@ friend class ProcessClientHelloCallback; void ProcessClientHello( - scoped_refptr<ValidateClientHelloResultCallback::Result> result, + QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> + result, std::unique_ptr<StatelessRejector> rejector, std::unique_ptr<StatelessRejector::ProcessDoneCallback> done_cb); @@ -107,8 +108,8 @@ CryptoHandshakeMessage chlo_; std::unique_ptr<CryptoHandshakeMessage> reply_; CryptoFramer crypto_framer_; - scoped_refptr<QuicSignedServerConfig> signed_config_; - scoped_refptr<QuicCryptoNegotiatedParameters> params_; + QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; + QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; DISALLOW_COPY_AND_ASSIGN(StatelessRejector); };
diff --git a/net/tools/quic/test_tools/quic_test_client.cc b/net/tools/quic/test_tools/quic_test_client.cc index 035df6bc..29f15113 100644 --- a/net/tools/quic/test_tools/quic_test_client.cc +++ b/net/tools/quic/test_tools/quic_test_client.cc
@@ -292,7 +292,7 @@ const SpdyHeaderBlock* headers, StringPiece body, bool fin, - scoped_refptr<QuicAckListenerInterface> delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate) { if (headers) { QuicClientPushPromiseIndex::TryHandle* handle; QuicAsyncStatus rv = @@ -377,7 +377,7 @@ ssize_t QuicTestClient::SendData( const string& data, bool last_data, - scoped_refptr<QuicAckListenerInterface> delegate) { + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate) { return GetOrCreateStreamAndSendRequest(nullptr, StringPiece(data), last_data, std::move(delegate)); } @@ -677,7 +677,7 @@ base::StringPiece body, bool fin, QuicTestClient* test_client, - scoped_refptr<QuicAckListenerInterface> delegate) + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate) : QuicClient::QuicDataToResend(std::move(headers), body, fin), test_client_(test_client), delegate_(std::move(delegate)) {}
diff --git a/net/tools/quic/test_tools/quic_test_client.h b/net/tools/quic/test_tools/quic_test_client.h index 49991efd..5f24d249 100644 --- a/net/tools/quic/test_tools/quic_test_client.h +++ b/net/tools/quic/test_tools/quic_test_client.h
@@ -113,9 +113,10 @@ // Wraps data in a quic packet and sends it. ssize_t SendData(const std::string& data, bool last_data); // As above, but |delegate| will be notified when |data| is ACKed. - ssize_t SendData(const std::string& data, - bool last_data, - scoped_refptr<QuicAckListenerInterface> delegate); + ssize_t SendData( + const std::string& data, + bool last_data, + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate); // Clears any outstanding state and sends a simple GET of 'uri' to the // server. Returns 0 if the request failed and no bytes were written. @@ -219,7 +220,7 @@ const SpdyHeaderBlock* headers, base::StringPiece body, bool fin, - scoped_refptr<QuicAckListenerInterface> delegate); + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate); QuicRstStreamErrorCode stream_error() { return stream_error_; } QuicErrorCode connection_error(); @@ -276,11 +277,12 @@ private: class TestClientDataToResend : public QuicClient::QuicDataToResend { public: - TestClientDataToResend(std::unique_ptr<SpdyHeaderBlock> headers, - base::StringPiece body, - bool fin, - QuicTestClient* test_client, - scoped_refptr<QuicAckListenerInterface> delegate); + TestClientDataToResend( + std::unique_ptr<SpdyHeaderBlock> headers, + base::StringPiece body, + bool fin, + QuicTestClient* test_client, + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate); ~TestClientDataToResend() override; @@ -288,7 +290,7 @@ protected: QuicTestClient* test_client_; - scoped_refptr<QuicAckListenerInterface> delegate_; + QuicReferenceCountedPointer<QuicAckListenerInterface> delegate_; }; // Given |uri|, populates the fields in |headers| for a simple GET
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 7477a17..59460bd 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -10363,6 +10363,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -10836,6 +10839,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -11325,6 +11331,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -11837,6 +11846,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -12336,6 +12348,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -12786,6 +12801,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -13259,6 +13277,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -13705,6 +13726,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -14235,6 +14259,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -14724,6 +14751,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -15213,6 +15243,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -15820,6 +15853,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -16332,6 +16368,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -16808,6 +16847,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -17332,6 +17374,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [
diff --git a/testing/buildbot/chromium.gpu.json b/testing/buildbot/chromium.gpu.json index 1def634..94b7c06 100644 --- a/testing/buildbot/chromium.gpu.json +++ b/testing/buildbot/chromium.gpu.json
@@ -1964,6 +1964,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -2298,6 +2301,9 @@ "use_xvfb": false }, { + "args": [ + "--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1" + ], "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [
diff --git a/testing/buildbot/gn_isolate_map.pyl b/testing/buildbot/gn_isolate_map.pyl index 8628a95..da15df6d 100644 --- a/testing/buildbot/gn_isolate_map.pyl +++ b/testing/buildbot/gn_isolate_map.pyl
@@ -951,7 +951,7 @@ "video_decode_accelerator_unittest": { "label": "//media/gpu:video_decode_accelerator_unittest", "type": "raw", - "args": ["--test_video_data=../../media/test/data/test-25fps.h264:320:240:250:258:50:175:1"], + "args": [], }, "views_aura_mus_unittests": { "label": "//ui/views/mus:views_aura_mus_unittests",
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 9a36e00a..b3ceae7f 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -1425,6 +1425,75 @@ ] } ], + "PermissionPromptUIAndroid": [ + { + "platforms": [ + "android" + ], + "experiments": [ + { + "name": "ModalGestureEnabled", + "params": { + "require_gesture": "true" + }, + "enable_features": [ + "ModalPermissionPrompts" + ], + "disable_features": [ + "DisplayPersistenceToggleInPermissionPrompts" + ] + }, + { + "name": "ModalNoGestureEnabled", + "params": { + "require_gesture": "false" + }, + "enable_features": [ + "ModalPermissionPrompts" + ], + "disable_features": [ + "DisplayPersistenceToggleInPermissionPrompts" + ] + }, + { + "name": "ModalAndToggleEnabled", + "params": { + "require_gesture": "false" + }, + "enable_features": [ + "DisplayPersistenceToggleInPermissionPrompts", + "ModalPermissionPrompts" + ] + }, + { + "name": "ToggleEnabled", + "enable_features": [ + "DisplayPersistenceToggleInPermissionPrompts" + ], + "disable_features": [ + "ModalPermissionPrompts" + ] + } + ] + } + ], + "PermissionPromptUIViews": [ + { + "platforms": [ + "chromeos", + "linux", + "win" + ], + "experiments": [ + { + "name": "ToggleEnabled", + "enable_features": [ + "DisplayPersistenceToggleInPermissionPrompts" + ] + } + ] + } + ], "PersistentHistograms": [ { "platforms": [
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 b/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 index 0718b2d..5b616c2a 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
@@ -61,6 +61,8 @@ Bug(none) security/ [ Skip ] Bug(none) shadow-dom/ [ Skip ] Bug(none) storage/ [ Skip ] +Bug(none) svg/clip-path/ [ Skip ] +Bug(none) svg/masking/ [ Skip ] Bug(none) tables/ [ Skip ] Bug(none) third_party/ [ Skip ] Bug(none) touchadjustment/ [ Skip ] @@ -411,7 +413,6 @@ Bug(none) compositing/squashing/squashing-inside-perspective.html [ Failure ] Bug(none) compositing/squashing/squashing-sparsity-heuristic.html [ Failure ] Bug(none) compositing/tiled-layers-hidpi.html [ Failure ] -Bug(none) compositing/transitions/scale-transition-no-start.html [ Failure ] Bug(none) compositing/update-paint-phases.html [ Failure ] Bug(none) compositing/video/video-controls-layer-creation.html [ Failure ] Bug(none) compositing/video/video-poster.html [ Crash Failure ] @@ -1206,31 +1207,6 @@ Bug(none) svg/carto.net/selectionlist.svg [ Failure ] Bug(none) svg/carto.net/slider.svg [ Failure ] Bug(none) svg/carto.net/textbox.svg [ Failure ] -Bug(none) svg/clip-path/clip-in-clip.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-child-clipped.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-css-transform-1.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-css-transform-2.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-evenodd-nonzero.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-evenodd.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-nonzero-evenodd.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-nonzero.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-objectBoundingBox.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-on-clipped-use.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-on-g-and-child.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-on-g.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-on-lazy-root.html [ Failure ] -Bug(none) svg/clip-path/clip-path-on-svg-and-child.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-on-svg.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-pixelation.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-shape-ellipse-2.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-transform-1.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-transform-2.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-use-as-child.svg [ Failure ] -Bug(none) svg/clip-path/clip-path-userSpaceOnUse.svg [ Failure ] -Bug(none) svg/clip-path/clipper-placement-issue.svg [ Failure ] -Bug(none) svg/clip-path/deep-nested-clip-in-mask-panning.svg [ Failure ] -Bug(none) svg/clip-path/multiple-nested-clip-paths-crash.html [ Failure ] -Bug(none) svg/clip-path/nested-empty-clip.html [ Failure ] Bug(none) svg/css/text-shadow-multiple.xhtml [ Failure ] Bug(none) svg/custom/absolute-root-position-masking.xhtml [ Failure ] Bug(none) svg/custom/alignment-baseline-modes.svg [ Failure ] @@ -2012,7 +1988,6 @@ crbug.com/637316 svg/W3C-SVG-1.1/text-tselect-01-b.svg [ Failure ] crbug.com/637316 svg/W3C-SVG-1.1/text-tspan-01-b.svg [ Failure ] crbug.com/637316 svg/W3C-SVG-1.1/text-ws-01-t.svg [ Failure ] -crbug.com/637316 svg/clip-path/clip-path-shape-circle-2.svg [ Failure ] crbug.com/637316 svg/css/path-gradient-stroke-shadow.svg [ Failure ] crbug.com/637316 svg/css/rect-gradient-stroke-shadow.svg [ Failure ] crbug.com/637316 svg/css/text-gradient-shadow.svg [ Failure ] @@ -2042,7 +2017,6 @@ crbug.com/637316 svg/custom/rgba-color-outline.svg [ Failure ] crbug.com/637316 svg/custom/rounded-rects.svg [ Failure ] crbug.com/637316 svg/custom/stroke-fallback.svg [ Failure ] -crbug.com/637316 svg/custom/svg-root-with-opacity.html [ Failure ] crbug.com/637316 svg/custom/text-image-opacity.svg [ Failure ] crbug.com/637316 svg/custom/text-linking.svg [ Failure ] crbug.com/637316 svg/custom/text-rotation.svg [ Failure ] @@ -2060,10 +2034,6 @@ Bug(none) fast/box-shadow/transform-fringing.html [ Failure ] Bug(none) svg/animations/animateMotion_changingPath.html [ Failure ] Bug(none) svg/as-object/svg-embedded-in-html-in-iframe.html [ Failure ] -Bug(none) svg/clip-path/clip-in-mask.svg [ Failure ] -Bug(none) svg/clip-path/nested-clip-in-mask-image-based-clipping.svg [ Failure ] -Bug(none) svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg [ Failure ] -Bug(none) svg/clip-path/nested-clip-in-mask-path-based-clipping.svg [ Failure ] Bug(none) svg/custom/mouse-move-on-svg-root-standalone.svg [ Failure ] Bug(none) svg/custom/mouse-move-on-svg-root.xhtml [ Failure ] Bug(none) svg/custom/object-sizing-explicit-height.xhtml [ Failure ] @@ -2161,11 +2131,9 @@ Bug(none) css3/blending/mix-blend-mode-2nd-stacking-context-composited.html [ Failure ] Bug(none) css3/blending/mix-blend-mode-composited-layers.html [ Failure ] Bug(none) css3/blending/mix-blend-mode-composited-reason-children.html [ Failure ] -Bug(none) css3/blending/mix-blend-mode-has-ancestor-clipping-layer.html [ Failure ] Bug(none) css3/blending/mix-blend-mode-isolation-2-stacking-contexts.html [ Failure ] Bug(none) css3/blending/mix-blend-mode-isolation-layer.html [ Failure ] Bug(none) css3/blending/mix-blend-mode-isolation-remove.html [ Failure ] -Bug(none) css3/blending/mix-blend-mode-multiply.html [ Failure ] Bug(none) css3/blending/mix-blend-mode-with-masking.html [ Failure ] Bug(none) css3/blending/svg-blend-color-burn.html [ Failure ] Bug(none) css3/blending/svg-blend-color-dodge.html [ Failure ] @@ -2187,13 +2155,47 @@ Bug(none) css3/blending/svg-blend-soft-light.html [ Failure ] Bug(none) css3/blending/svg-isolation-foreign-no-isolation.html [ Failure ] +Bug(none) svg/custom/circular-clip-path-references-crash.svg [ Failure ] +Bug(none) svg/custom/marker-zero-length-linecaps.svg [ Failure ] +Bug(none) svg/custom/mask-changes.svg [ Failure ] +Bug(none) svg/custom/mask-excessive-malloc.svg [ Failure ] +Bug(none) svg/custom/mask-on-multiple-objects.svg [ Failure ] +Bug(none) svg/custom/non-opaque-filters.svg [ Failure ] +Bug(none) svg/custom/transformedMaskFails.svg [ Failure ] +Bug(none) svg/dynamic-updates/SVGFEBlendElement-dom-in-attr.html [ Failure ] +Bug(none) svg/dynamic-updates/SVGFEBlendElement-dom-in2-attr.html [ Failure ] +Bug(none) svg/dynamic-updates/SVGFEBlendElement-dom-mode-attr.html [ Failure ] +Bug(none) svg/dynamic-updates/SVGFEBlendElement-svgdom-in-prop.html [ Failure ] +Bug(none) svg/dynamic-updates/SVGFEBlendElement-svgdom-in2-prop.html [ Failure ] +Bug(none) svg/dynamic-updates/SVGFEBlendElement-svgdom-mode-prop.html [ Failure ] +Bug(none) svg/filters/feSpecularLight-premultiplied.svg [ Failure ] +Bug(none) svg/foreignObject/filter.html [ Failure ] + Bug(none) fast/forms/select-popup/popup-menu-position.html [ Failure ] -crbug.com/674805 css3/blending/mix-blend-mode-with-squashing-layer.html [ Failure ] +# Text failures due to layerization differences +Bug(none) compositing/will-change/will-change-contents-suppresses-compositing.html [ Failure ] # Failures due to rounding differences +crbug.com/589265 css3/blending/background-blend-mode-tiled-gradient.html [ Failure ] +crbug.com/589265 css3/blending/effect-background-blend-mode-tiled.html [ Failure ] +crbug.com/589265 css3/blending/effect-background-blend-mode.html [ Failure ] crbug.com/589265 css3/blending/mix-blend-mode-isolated-group-1.html [ Failure ] +crbug.com/589265 css3/blending/mix-blend-mode-isolated-group-2.html [ Failure ] crbug.com/589265 css3/blending/mix-blend-mode-isolated-group-3.html [ Failure ] +crbug.com/589265 css3/blending/svg-isolation-nested-svg-no-isolation.html [ Failure ] +crbug.com/589265 fast/css/ZeroOpacityLayers.html [ Failure ] +crbug.com/589265 fast/css/ZeroOpacityLayers2.html [ Failure ] +crbug.com/589265 fast/dynamic/anonymous-block-layer-lost.html [ Failure ] +crbug.com/589265 fast/forms/indeterminate.html [ Failure ] +crbug.com/589265 fast/layers/add-layer-with-nested-stacking.html [ Failure ] +crbug.com/589265 fast/layers/opacity-stacking.html [ Failure ] +crbug.com/589265 svg/custom/small-rect-scale.svg [ Failure ] +crbug.com/589265 svg/filters/filter-on-svg-root-w-layer.html [ Failure ] + +# Interesting one. The expectation contains an artifact due to incorrect +# Skia peephole optimization. +crbug.com/675805 fast/text/complex-text-opacity.html [ Failure ] # Failures due to frame scrollbars not painted crbug.com/589279 css3/blending/background-blend-mode-data-uri-svg-image.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-cell-straddles-page-expected.html b/third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-cell-straddles-page-expected.html new file mode 100644 index 0000000..9a158b4cb --- /dev/null +++ b/third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-cell-straddles-page-expected.html
@@ -0,0 +1,53 @@ +<!DOCTYPE html> +<style> +table { + border-collapse: collapse; +} +td, th { + background-color: #ddd; + border: 1px solid black; +} +.header { + font-weight: bold; + text-align: center +} +</style> +<p>crbug.com/675453: Content of a cell that spans multiple pages should avoid the repeating header.</p> +<div style="columns:3; line-height: 20px; column-fill: auto; height:100px; background-color: yellow;"> + <table> + <tr><td class="header">Col 1</td><td class="header">Col 2</td></tr> + <tr><td>Te</td><td>xt</td></tr> + <tr><td>Te</td><td>xt</td></tr> + <tr><td style="height: 28px; vertical-align: top;">Te</td><td style="vertical-align: top;">xt</td></tr> + <tr><td class="header">Col 1</td><td class="header">Col 2</td></tr> + <tr><td> + <div style="height: 76px; margin-top: -2px;"> + Te<br> + Te<br> + Te<br> + </div> + </td> + <td> + <div style="height: 76px; margin-top: -2px;"> + xt<br> + xt<br> + xt<br> + </div> + </td></tr> + <tr><td class="header">Col 1</td><td class="header">Col 2</td></tr> + <tr><td> + <div style="height: 40px; margin-top: -2px;"> + Te<br> + Te + </div> + </td> + <td> + <div style="height: 40px; margin-top: -2px;"> + xt<br> + xt + </div> + </td></tr> + <tr><td class="header">Ft 1</td><td class="header">Ft 2</td></tr> + </table> +</div> +
diff --git a/third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-cell-straddles-page.html b/third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-cell-straddles-page.html new file mode 100644 index 0000000..a70290a --- /dev/null +++ b/third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-cell-straddles-page.html
@@ -0,0 +1,51 @@ +<!DOCTYPE html> +<style> +table { + border-collapse: collapse; +} +td, th { + background-color: #ddd; + border: 1px solid black; +} +thead, tfoot, tr { + break-inside: avoid; +} +</style> +<p>crbug.com/675453: Content of a cell that spans multiple pages should avoid the repeating header.</p> +<div style="columns:3; line-height: 20px; column-fill: auto; height:100px; background-color: yellow;"> + <table> + <thead> + <tr> + <th>Col 1</th> + <th>Col 2</th> + </tr> + </thead> + <tbody> + <tr><td>Te</td><td>xt</td></tr> + <tr><td>Te</td><td>xt</td></tr> + <tr><td> + Te<br> + Te<br> + Te<br> + Te<br> + Te<br> + Te<br> + </td> + <td> + xt<br> + xt<br> + xt<br> + xt<br> + xt<br> + xt<br> + </td></tr> + </tbody> + <tfoot> + <tr> + <th>Ft 1</th> + <th>Ft 2</th> + </tr> + </tfoot> + </table> +</div> +
diff --git a/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.cpp b/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.cpp index df122f8..a9a93c2 100644 --- a/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.cpp +++ b/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.cpp
@@ -69,6 +69,15 @@ m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules()); } +void CSSGlobalRuleSet::dispose() { + m_features.clear(); + m_siblingRuleSet = nullptr; + m_uncommonAttributeRuleSet = nullptr; + m_watchedSelectorsRuleSet = nullptr; + m_hasFullscreenUAStyle = false; + m_isDirty = true; +} + DEFINE_TRACE(CSSGlobalRuleSet) { visitor->trace(m_features); visitor->trace(m_siblingRuleSet);
diff --git a/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.h b/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.h index 0bc1f8d..0284812 100644 --- a/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.h +++ b/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.h
@@ -28,6 +28,7 @@ public: CSSGlobalRuleSet() {} + void dispose(); void initWatchedSelectorsRuleSet(Document&); void markDirty() { m_isDirty = true; } bool isDirty() const { return m_isDirty; }
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp index 266f2b9..51e43284 100644 --- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp +++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -457,6 +457,7 @@ } void StyleEngine::didDetach() { + m_globalRuleSet.dispose(); clearResolver(); m_viewportResolver = nullptr; m_mediaQueryEvaluator = nullptr;
diff --git a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.h b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.h index 22f99b5b..26dd525 100644 --- a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.h +++ b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.h
@@ -73,7 +73,7 @@ void appendStartMarkup(Node&); bool shouldAnnotate() const; - bool convertBlocksToInlines() const { + bool shouldConvertBlocksToInlines() const { return m_convertBlocksToInlines == ConvertBlocksToInlines::Convert; }
diff --git a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp index 1aa8059..c8f4a8361 100644 --- a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp +++ b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp
@@ -96,7 +96,7 @@ private: bool shouldAnnotate() const; - bool convertBlocksToInlines() const; + bool shouldConvertBlocksToInlines() const; void appendStartMarkup(Node&); void appendEndMarkup(Node&); EditingStyle* createInlineStyle(Element&); @@ -114,8 +114,8 @@ } template <typename Strategy> -bool StyledMarkupTraverser<Strategy>::convertBlocksToInlines() const { - return m_accumulator->convertBlocksToInlines(); +bool StyledMarkupTraverser<Strategy>::shouldConvertBlocksToInlines() const { + return m_accumulator->shouldConvertBlocksToInlines(); } template <typename Strategy> @@ -242,7 +242,7 @@ for (ContainerNode* ancestor = Strategy::parent(*lastClosed); ancestor; ancestor = Strategy::parent(*ancestor)) { if (ancestor == fullySelectedRoot && - !markupAccumulator.convertBlocksToInlines()) { + !markupAccumulator.shouldConvertBlocksToInlines()) { EditingStyle* fullySelectedRootStyle = styleFromMatchedRulesAndInlineDecl(fullySelectedRoot); @@ -424,7 +424,7 @@ return false; if (shouldAnnotate()) return true; - return convertBlocksToInlines() && isEnclosingBlock(&element); + return shouldConvertBlocksToInlines() && isEnclosingBlock(&element); } template <typename Strategy> @@ -457,7 +457,7 @@ if (!node.isElementNode()) return nullptr; EditingStyle* inlineStyle = createInlineStyle(toElement(node)); - if (convertBlocksToInlines() && isEnclosingBlock(&node)) + if (shouldConvertBlocksToInlines() && isEnclosingBlock(&node)) inlineStyle->forceInline(); return inlineStyle; }
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp index 92b46e9..ebe85e16 100644 --- a/third_party/WebKit/Source/core/frame/FrameView.cpp +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -197,7 +197,10 @@ m_needsScrollbarsUpdate(false), m_suppressAdjustViewSize(false), m_allowsLayoutInvalidationAfterLayoutClean(true), - m_mainThreadScrollingReasons(0) { + m_mainThreadScrollingReasons(0), + m_mainThreadScrollingReasonsCounter( + MainThreadScrollingReason::kMainThreadScrollingReasonCount, + 0) { init(); } @@ -4787,6 +4790,9 @@ if (hasBackgroundAttachmentFixedObjects()) reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; + + reasons |= getStyleRelatedMainThreadScrollingReasons(); + ScrollingReasons scrollingReasons = getScrollingReasons(); const bool mayBeScrolledByInput = (scrollingReasons == Scrollable); const bool mayBeScrolledByScript = @@ -4851,4 +4857,27 @@ return result; } +void FrameView::adjustStyleRelatedMainThreadScrollingReasons( + const uint32_t reason, + bool increase) { + int index = MainThreadScrollingReason::getReasonIndex(reason); + DCHECK_GE(index, 0); + m_mainThreadScrollingReasonsCounter[index] += increase ? 1 : -1; + DCHECK_GE(m_mainThreadScrollingReasonsCounter[index], 0); +} + +MainThreadScrollingReasons +FrameView::getStyleRelatedMainThreadScrollingReasons() const { + MainThreadScrollingReasons reasons = + static_cast<MainThreadScrollingReasons>(0); + for (uint32_t reason = 1; + reason < MainThreadScrollingReason::kMainThreadScrollingReasonCount; + ++reason) { + if (m_mainThreadScrollingReasonsCounter[reason] > 0) { + reasons |= 1 << (reason - 1); + } + } + return reasons; +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/frame/FrameView.h b/third_party/WebKit/Source/core/frame/FrameView.h index 497a1c08..4e0f8ed2 100644 --- a/third_party/WebKit/Source/core/frame/FrameView.h +++ b/third_party/WebKit/Source/core/frame/FrameView.h
@@ -805,6 +805,10 @@ // Main thread scrolling reasons for this object only. For all reasons, // see: mainThreadScrollingReasons(). MainThreadScrollingReasons mainThreadScrollingReasonsPerFrame() const; + void adjustStyleRelatedMainThreadScrollingReasons(const uint32_t reason, + bool increase); + MainThreadScrollingReasons getStyleRelatedMainThreadScrollingReasons() const; + bool hasVisibleSlowRepaintViewportConstrainedObjects() const; protected: @@ -1176,6 +1180,11 @@ bool m_isStoringCompositedLayerDebugInfo; MainThreadScrollingReasons m_mainThreadScrollingReasons; + // For recording main thread scrolling reasons + // due to layout object properties. e.g. opacity, transform. + // The size of the vector depends on the number of + // main thread scrolling reasons. + Vector<int> m_mainThreadScrollingReasonsCounter; }; inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) {
diff --git a/third_party/WebKit/Source/core/frame/Location.cpp b/third_party/WebKit/Source/core/frame/Location.cpp index f034f90..10e72e8 100644 --- a/third_party/WebKit/Source/core/frame/Location.cpp +++ b/third_party/WebKit/Source/core/frame/Location.cpp
@@ -240,7 +240,7 @@ if (!m_frame) return; setLocation(url, currentWindow, enteredWindow, &exceptionState, - SetLocation::ReplaceThisFrame); + SetLocationPolicy::ReplaceThisFrame); } void Location::reload(LocalDOMWindow* currentWindow) { @@ -259,7 +259,7 @@ LocalDOMWindow* currentWindow, LocalDOMWindow* enteredWindow, ExceptionState* exceptionState, - SetLocation locationPolicy) { + SetLocationPolicy setLocationPolicy) { DCHECK(m_frame); if (!m_frame || !m_frame->host()) return; @@ -305,7 +305,7 @@ activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); } m_frame->navigate(*currentWindow->document(), completedURL, - locationPolicy == SetLocation::ReplaceThisFrame, + setLocationPolicy == SetLocationPolicy::ReplaceThisFrame, UserGestureStatus::None); }
diff --git a/third_party/WebKit/Source/core/frame/Location.h b/third_party/WebKit/Source/core/frame/Location.h index 2144e3e..bcf777c 100644 --- a/third_party/WebKit/Source/core/frame/Location.h +++ b/third_party/WebKit/Source/core/frame/Location.h
@@ -125,12 +125,12 @@ private: explicit Location(Frame*); - enum class SetLocation { Normal, ReplaceThisFrame }; + enum class SetLocationPolicy { Normal, ReplaceThisFrame }; void setLocation(const String&, LocalDOMWindow* currentWindow, LocalDOMWindow* enteredWindow, ExceptionState* = nullptr, - SetLocation = SetLocation::Normal); + SetLocationPolicy = SetLocationPolicy::Normal); const KURL& url() const;
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h index 0053f26..e451205f 100644 --- a/third_party/WebKit/Source/core/frame/UseCounter.h +++ b/third_party/WebKit/Source/core/frame/UseCounter.h
@@ -1386,6 +1386,27 @@ AppInstalledEventAddListener = 1700, AudioContextGetOutputTimestamp = 1701, V8MediaStreamAudioDestinationNode_Constructor = 1702, + V8AnalyserNode_Constructor = 1703, + V8AudioBuffer_Constructor = 1704, + V8AudioBufferSourceNode_Constructor = 1705, + V8AudioProcessingEvent_Constructor = 1706, + V8BiquadFilterNode_Constructor = 1707, + V8ChannelMergerNode_Constructor = 1708, + V8ChannelSplitterNode_Constructor = 1709, + V8ConstantSourceNode_Constructor = 1710, + V8ConvolverNode_Constructor = 1711, + V8DelayNode_Constructor = 1712, + V8DynamicsCompressorNode_Constructor = 1713, + V8GainNode_Constructor = 1714, + V8IIRFilterNode_Constructor = 1715, + V8MediaElementAudioSourceNode_Constructor = 1716, + V8MediaStreamAudioSourceNode_Constructor = 1717, + V8OfflineAudioCompletionEvent_Constructor = 1718, + V8OscillatorNode_Constructor = 1719, + V8PannerNode_Constructor = 1720, + V8PeriodicWave_Constructor = 1721, + V8StereoPannerNode_Constructor = 1722, + V8WaveShaperNode_Constructor = 1723, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp index d9673fa2..cebc52a8 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -5587,6 +5587,13 @@ LayoutUnit contentLogicalHeight) const { ASSERT(strutToNextPage == pageRemainingLogicalHeightForOffset(offset, AssociateWithLatterPage)); + // If we're a cell in a row that straddles a page then avoid the repeating + // header group if necessary. + if (isTableCell()) { + const LayoutTableCell* cell = toLayoutTableCell(this); + if (!cell->row()->isFirstRowInSectionAfterHeader()) + strutToNextPage += cell->table()->rowOffsetFromRepeatingHeader(); + } LayoutUnit nextPageLogicalTop = offset + strutToNextPage; if (pageLogicalHeightForOffset(nextPageLogicalTop) >= contentLogicalHeight) return strutToNextPage; // Content fits just fine in the next page or
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp b/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp index c814ba3..8f26a99 100644 --- a/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp
@@ -312,4 +312,18 @@ addContentsVisualOverflow(cellVisualOverflowRect); } +bool LayoutTableRow::isFirstRowInSectionAfterHeader() const { + // If there isn't room on the page for at least one content row after the + // header group, then we won't repeat the header on each page. + // https://drafts.csswg.org/css-tables-3/#repeated-headers reads like + // it wants us to drop headers on only the pages that a single row + // won't fit but we avoid the complexity of that reading until it + // is clarified. Tracked by crbug.com/675904 + if (rowIndex()) + return false; + LayoutTableSection* header = table()->header(); + return header && table()->sectionAbove(section()) == header && + header->getPaginationBreakability() != AllowAnyBreaks; +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableRow.h b/third_party/WebKit/Source/core/layout/LayoutTableRow.h index 5307990..74c64d60 100644 --- a/third_party/WebKit/Source/core/layout/LayoutTableRow.h +++ b/third_party/WebKit/Source/core/layout/LayoutTableRow.h
@@ -140,6 +140,8 @@ return false; } + bool isFirstRowInSectionAfterHeader() const; + private: void addOverflowFromCell(const LayoutTableCell*);
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp index 2efec3e..4841772 100644 --- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -2012,14 +2012,9 @@ // fragmentainer, above this row. Otherwise, this row will just go at the top // of the next fragmentainer. - // If there isn't room for at least one content row on a page with a - // header group, then we won't repeat the header on each page. LayoutTableSection* header = table()->header(); - if (!rowObject.rowIndex() && header && - table()->sectionAbove(this) == header && - header->getPaginationBreakability() != AllowAnyBreaks) { + if (rowObject.isFirstRowInSectionAfterHeader()) table()->setRowOffsetFromRepeatingHeader(LayoutUnit()); - } // Border spacing from the previous row has pushed this row just past the top // of the page, so we must reposition it to the top of the page and avoid any // repeating header.
diff --git a/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.cpp b/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.cpp index 0db07cc..a7561a22 100644 --- a/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.cpp +++ b/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.cpp
@@ -242,7 +242,7 @@ EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv)); } -TEST_P(PaintControllerPaintTestForSlimmingPaintV2, CompositingFold) { +TEST_P(PaintControllerPaintTestForSlimmingPaintV2, CompositingNoFold) { setBodyInnerHTML( "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" " <div style='width: 100px; height: 100px; background-color: " @@ -256,28 +256,26 @@ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { EXPECT_DISPLAY_LIST( - rootPaintController().getDisplayItemList(), 6, + rootPaintController().getDisplayItemList(), 8, TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), TestDisplayItem(layoutView(), documentBackgroundType), TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), - // The begin and end compositing display items have been folded into - // this - // one. + TestDisplayItem(div, DisplayItem::kBeginCompositing), TestDisplayItem(subDiv, backgroundType), + TestDisplayItem(div, DisplayItem::kEndCompositing), TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence)); } else { EXPECT_DISPLAY_LIST( - rootPaintController().getDisplayItemList(), 8, + rootPaintController().getDisplayItemList(), 10, TestDisplayItem(layoutView(), DisplayItem::kClipFrameToVisibleContentRect), TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), TestDisplayItem(layoutView(), documentBackgroundType), TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), - // The begin and end compositing display items have been folded into - // this - // one. + TestDisplayItem(div, DisplayItem::kBeginCompositing), TestDisplayItem(subDiv, backgroundType), + TestDisplayItem(div, DisplayItem::kEndCompositing), TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), TestDisplayItem(layoutView(),
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp index 7d0a445..af28b1f 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -106,7 +106,8 @@ m_scrollbarManager(*this), m_scrollCorner(nullptr), m_resizer(nullptr), - m_scrollAnchor(this) + m_scrollAnchor(this), + m_reasons(0) #if DCHECK_IS_ON() , m_hasBeenDisposed(false) @@ -144,6 +145,8 @@ } } + removeStyleRelatedMainThreadScrollingReasons(); + if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) scrollingCoordinator->willDestroyScrollableArea(this); @@ -1721,8 +1724,8 @@ return ScrollableArea::shouldScrollOnMainThread(); } -static bool layerNeedsCompositedScrolling( - PaintLayerScrollableArea::LCDTextMode mode, +bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( + const LCDTextMode mode, const PaintLayer* layer) { if (!layer->scrollsOverflow()) return false; @@ -1743,10 +1746,16 @@ layer->backgroundIsKnownToBeOpaqueInRect( toLayoutBox(layer->layoutObject())->paddingBoxRect()) && !layer->compositesWithTransform() && !layer->compositesWithOpacity(); + if (mode == PaintLayerScrollableArea::ConsiderLCDText && !layer->compositor()->preferCompositingToLCDTextEnabled() && - !backgroundSupportsLCDText) + !backgroundSupportsLCDText) { + if (layer->compositesWithOpacity()) { + addStyleRelatedMainThreadScrollingReasons( + MainThreadScrollingReason::kHasOpacity); + } return false; + } // TODO(schenney) Tests fail if we do not also exclude // layer->layoutObject()->style()->hasBorderDecoration() (missing background @@ -1757,10 +1766,47 @@ layer->layoutObject()->style()->hasBorderRadius()); } +void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons( + const uint32_t reason) { + LocalFrame* frame = box().frame(); + if (!frame) + return; + FrameView* frameView = frame->view(); + if (!frameView) + return; + + frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, true); + m_reasons |= reason; +} + +void PaintLayerScrollableArea::removeStyleRelatedMainThreadScrollingReasons() { + LocalFrame* frame = box().frame(); + if (!frame) + return; + FrameView* frameView = frame->view(); + if (!frameView) + return; + + // Decrese the number of layers that have any main thread + // scrolling reasons stored in FrameView + for (uint32_t i = 0; + i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) { + uint32_t reason = 1 << i; + if (hasMainThreadScrollingReason(reason)) { + m_reasons &= ~reason; + frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, false); + } + } +} + void PaintLayerScrollableArea::updateNeedsCompositedScrolling( LCDTextMode mode) { + // Clear all style related main thread scrolling reasons, if any, + // before calling computeNeedsCompositedScrolling + removeStyleRelatedMainThreadScrollingReasons(); const bool needsCompositedScrolling = - layerNeedsCompositedScrolling(mode, layer()); + computeNeedsCompositedScrolling(mode, layer()); + if (static_cast<bool>(m_needsCompositedScrolling) != needsCompositedScrolling) { m_needsCompositedScrolling = needsCompositedScrolling;
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h index e2bd649..5fdb0e3 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h
@@ -476,6 +476,12 @@ void invalidateStickyConstraintsFor(PaintLayer*, bool needsCompositingUpdate = true); + void removeStyleRelatedMainThreadScrollingReasons(); + void addStyleRelatedMainThreadScrollingReasons(const uint32_t); + bool hasMainThreadScrollingReason(uint32_t reason) const { + return m_reasons & reason; + } + uint64_t id() const; DECLARE_VIRTUAL_TRACE(); @@ -531,6 +537,7 @@ return *m_rareData.get(); } + bool computeNeedsCompositedScrolling(const LCDTextMode, const PaintLayer*); PaintLayer& m_layer; PaintLayer* m_nextTopmostScrollChild; @@ -582,6 +589,9 @@ std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData; + // MainThreadScrollingReason due to the properties of the LayoutObject + uint32_t m_reasons; + #if ENABLE(ASSERT) bool m_hasBeenDisposed; #endif
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp index 92e368d..22eb519 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -289,9 +289,19 @@ TEST_P(PaintPropertyTreeBuilderTest, Perspective) { setBodyInnerHTML( "<style>" - " #perspective { position: absolute; left: 50px; top: 100px;" - " width: 400px; height: 300px; perspective: 100px }" - " #inner { transform: translateZ(0); width: 100px; height: 200px; }" + " #perspective {" + " position: absolute;" + " left: 50px;" + " top: 100px;" + " width: 400px;" + " height: 300px;" + " perspective: 100px;" + " }" + " #inner {" + " transform: translateZ(0);" + " width: 100px;" + " height: 200px;" + " }" "</style>" "<div id='perspective'>" " <div id='inner'></div>" @@ -344,7 +354,7 @@ "<style> body { margin: 0 } </style>" "<div id='transform' style='margin-left: 50px; margin-top: 100px;" " width: 400px; height: 300px;" - " transform: translate3D(123px, 456px, 789px)'>" + " transform: translate3d(123px, 456px, 789px)'>" "</div>"); Element* transform = document().getElementById("transform"); @@ -377,7 +387,7 @@ transform->setAttribute( HTMLNames::styleAttr, "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " - "transform: translate3D(123px, 456px, 789px)"); + "transform: translate3d(123px, 456px, 789px)"); document().view()->updateAllLifecyclePhases(); EXPECT_EQ( TransformationMatrix().translate3d(123, 456, 789), @@ -393,7 +403,7 @@ " 100% { transform: translate(2em, 2em) } " "} " "</style>" - "<div id='transform' " + "<div id='transform'" " style='animation-name: test; animation-duration: 1s'>" "</div>"); @@ -479,12 +489,12 @@ TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) { setBodyInnerHTML( "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" - " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height: " - "60px;'>" - " <div id='grandChildWithoutOpacity' style='width: 20px; height: " - "30px'>" - " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width: " - "10px; height: 15px'/>" + " <div id='childWithOpacity'" + " style='opacity: 0.5; width: 50px; height: 60px;'>" + " <div id='grandChildWithoutOpacity'" + " style='width: 20px; height: 30px'>" + " <div id='greatGrandChildWithOpacity'" + " style='opacity: 0.2; width: 10px; height: 15px'></div>" " </div>" " </div>" "</div>"); @@ -526,12 +536,26 @@ TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) { setBodyInnerHTML( - "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; " - "height: 200px'>" - " <div id='childWithTransform' style='transform: translate3d(10px, " - "10px, 0px); width: 50px; height: 60px;'>" - " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; " - "height: 30px'/>" + "<style>" + " #nodeWithOpacity {" + " opacity: 0.6;" + " width: 100px;" + " height: 200px;" + " }" + " #childWithTransform {" + " transform: translate3d(10px, 10px, 0px);" + " width: 50px;" + " height: 60px;" + " }" + " #grandChildWithOpacity {" + " opacity: 0.4;" + " width: 20px;" + " height: 30px;" + " }" + "</style>" + "<div id='nodeWithOpacity'>" + " <div id='childWithTransform'>" + " <div id='grandChildWithOpacity'></div>" " </div>" "</div>"); @@ -542,7 +566,7 @@ EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); - CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 60), nodeWithOpacity, + CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithOpacity, document().view()->layoutView()); LayoutObject* childWithTransform = @@ -569,12 +593,12 @@ TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) { setBodyInnerHTML( - "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: " - "200px'>" - " <div id='childWithStackingContext' style='position:absolute; width: " - "50px; height: 60px;'>" - " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; " - "height: 30px'/>" + "<div id='nodeWithOpacity'" + " style='opacity: 0.6; width: 100px; height: 200px'>" + " <div id='childWithStackingContext'" + " style='position:absolute; width: 50px; height: 60px;'>" + " <div id='grandChildWithOpacity'" + " style='opacity: 0.4; width: 20px; height: 30px'></div>" " </div>" "</div>"); @@ -790,17 +814,20 @@ " body {" " margin: 0px;" " }" - " svg {" + " #svgWithViewBox {" " transform: translate3d(1px, 2px, 3px);" " position: absolute;" + " width: 100px;" + " height: 100px;" " }" - " rect {" + " #rect {" " transform: translate(100px, 100px);" + " width: 100px;" + " height: 100px;" " }" "</style>" - "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 " - "100 100'>" - " <rect id='rect' width='100px' height='100px' />" + "<svg id='svgWithViewBox' viewBox='50 50 100 100'>" + " <rect id='rect' />" "</svg>"); LayoutObject& svgWithViewBox = @@ -824,9 +851,16 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) { setBodyInnerHTML( - "<style>body { margin: 0px; } </style>" - "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; " - "height: 100px;' />"); + "<style>" + " body { margin: 0px; }" + " #svg {" + " margin-left: 50px;" + " margin-top: 25px;" + " width: 100px;" + " height: 100px;" + " }" + "</style>" + "<svg id='svg' />"); LayoutObject& svg = *document().getElementById("svg")->layoutObject(); const ObjectPaintProperties* svgProperties = svg.paintProperties(); @@ -842,8 +876,12 @@ setBodyInnerHTML( "<style>" " body { margin: 0px; }" - " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, " - "7px); border: 11px solid green; }" + " svg {" + " margin-left: 2px;" + " margin-top: 3px;" + " transform: translate(5px, 7px);" + " border: 11px solid green;" + " }" "</style>" "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" " <rect id='rect' transform='translate(17 19)' />" @@ -875,8 +913,8 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) { setBodyInnerHTML( "<style>body { margin: 0px; } </style>" - "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' " - "style='transform: translate(11px, 11px);'>" + "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50'" + " style='transform: translate(11px, 11px);'>" " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" " <rect id='rect' transform='translate(13 13)' />" " </svg>" @@ -910,12 +948,12 @@ TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) { setBodyInnerHTML( "<style> body { margin: 0px; } </style>" - "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, " - "3px);'>" + "<svg id='svgWithTransform'" + " style='transform: translate3d(1px, 2px, 3px);'>" " <foreignObject>" " <body>" - " <div id='divWithTransform' style='transform: translate3d(3px, " - "4px, 5px);'></div>" + " <div id='divWithTransform'" + " style='transform: translate3d(3px, 4px, 5px);'></div>" " </body>" " </foreignObject>" "</svg>"); @@ -946,8 +984,8 @@ " <g id='container' transform='translate(20 30)'>" " <foreignObject>" " <body>" - " <div id='fixed' style='position: fixed; left: 200px; top: " - "150px;'></div>" + " <div id='fixed'" + " style='position: fixed; left: 200px; top: 150px;'></div>" " </body>" " </foreignObject>" " </g>" @@ -989,8 +1027,8 @@ " padding: 0;" " }" "</style>" - "<input id='button' type='button' style='width:345px; height:123px' " - "value='some text'/>"); + "<input id='button' type='button'" + " style='width:345px; height:123px' value='some text'/>"); LayoutObject& button = *document().getElementById("button")->layoutObject(); const ObjectPaintProperties* buttonProperties = button.paintProperties(); @@ -1043,22 +1081,19 @@ // The border radius clip is the area enclosed by inner border edge, including // the scrollbars. As the border-radius is specified in outer radius, the // inner radius is calculated by: - // inner radius = max(outer radius - border width, 0) + // inner radius = max(outer radius - border width, 0) // In the case that two adjacent borders have different width, the inner // radius of the corner may transition from one value to the other. i.e. being // an ellipse. + // The following is border box(610, 500) - border outset(110, 100). + FloatRect borderBoxMinusBorderOutset(60, 45, 500, 400); EXPECT_EQ( FloatRoundedRect( - FloatRect(60, 45, 500, - 400), // = border box(610, 500) - border outset(110, 100) - FloatSize(0, - 0), // (top left) = max((12, 12) - (60, 45), (0, 0)) - FloatSize(0, - 0), // (top right) = max((34, 34) - (50, 45), (0, 0)) - FloatSize(18, - 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0)) - FloatSize(6, - 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0)) + borderBoxMinusBorderOutset, + FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0)) + FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0)) + FloatSize(18, 23), // (bot left) = max((78, 78) - (60, 55), (0, 0)) + FloatSize(6, 1)), // (bot right) = max((56, 56) - (50, 55), (0, 0)) borderRadiusClip->clipRect()); EXPECT_EQ(frameContentClip(), borderRadiusClip->parent()); CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 610, 500), &div, @@ -1067,14 +1102,25 @@ TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) { setBodyInnerHTML( - "<style>body { margin: 0; }</style>" - "<div id='divWithTransform' style='transform: translate3d(1px, 2px, " - "3px);'>" + "<style>" + " body { margin: 0; }" + " #divWithTransform {" + " transform: translate3d(1px, 2px, 3px);" + " }" + "</style>" + "<div id='divWithTransform'>" " <iframe style='border: 7px solid black'></iframe>" "</div>"); setChildFrameHTML( - "<style>body { margin: 0; }</style><div id='transform' style='transform: " - "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); + "<style>" + " body { margin: 0; }" + " #innerDivWithTransform {" + " transform: translate3d(4px, 5px, 6px);" + " width: 100px;" + " height: 200px;" + " }" + "</style>" + "<div id='innerDivWithTransform'></div>"); FrameView* frameView = document().view(); frameView->updateAllLifecyclePhases(); @@ -1089,7 +1135,7 @@ frameView->layoutView()); LayoutObject* innerDivWithTransform = - childDocument().getElementById("transform")->layoutObject(); + childDocument().getElementById("innerDivWithTransform")->layoutObject(); const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithTransform->paintProperties(); auto* innerDivTransform = innerDivWithTransformProperties->transform(); @@ -1118,16 +1164,30 @@ TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) { setBodyInnerHTML( - "<style>body { margin: 0; }</style>" - "<div id='divWithTransform' style='transform: translate3d(1px, 2px, " - "3px);'>" - " <iframe style='transform: translate3d(4px, 5px, 6px); " - "border: 42px solid; margin: 7px;'></iframe>" + "<style>" + " body { margin: 0; }" + " #divWithTransform {" + " transform: translate3d(1px, 2px, 3px);" + " }" + " iframe {" + " transform: translate3d(4px, 5px, 6px);" + " border: 42px solid;" + " margin: 7px;" + " }" + "</style>" + "<div id='divWithTransform'>" + " <iframe></iframe>" "</div>"); setChildFrameHTML( - "<style>body { margin: 31px; }</style><div " - "id='transform' style='transform: translate3d(7px, 8px, " - "9px); width: 100px; height: 200px'></div>"); + "<style>" + " body { margin: 31px; }" + " #transform {" + " transform: translate3d(7px, 8px, 9px);" + " width: 100px;" + " height: 200px;" + " }" + "</style>" + "<div id='transform'></div>"); FrameView* frameView = document().view(); frameView->updateAllLifecyclePhases(); @@ -1185,8 +1245,8 @@ setBodyInnerHTML( "<style>body { margin: 0; }</style>" "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" - " <div id='child' style='position:relative; width:100px; height: " - "200px;'></div>" + " <div id='child'" + " style='position:relative; width:100px; height: 200px;'></div>" " <div style='height:10000px;'></div>" "</div>"); FrameView* frameView = document().view(); @@ -1220,15 +1280,26 @@ // scrolled by it). setBodyInnerHTML( - "<style>body { margin: 0; }</style>" - "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" - " <div id='child' style='position:absolute; left:0; top:0; width: " - "100px; height: 200px'></div>" - " <div style='height:10000px;'></div>" + "<style>" + " body { margin: 0; }" + " #scroller {" + " overflow:scroll;" + " opacity:0.5;" + " }" + " #child {" + " position:absolute;" + " left:0;" + " top:0;" + " width: 100px;" + " height: 200px;" + " }" + "</style>" + "<div id='scroller'>" + " <div id='child'></div>" + " <div id='forceScroll' style='height:10000px;'></div>" "</div>"); - LayoutObject& scroller = - *document().getElementById("scroller")->layoutObject(); + auto& scroller = *document().getElementById("scroller")->layoutObject(); const ObjectPaintProperties* scrollerProperties = scroller.paintProperties(); LayoutObject& child = *document().getElementById("child")->layoutObject(); const ObjectPaintProperties* childProperties = child.paintProperties(); @@ -1378,7 +1449,7 @@ LayoutRect absoluteClipRect = localClipRect; absoluteClipRect.move(123, 456); - LayoutObject* clip = document().getElementById("clip")->layoutObject(); + auto* clip = document().getElementById("clip")->layoutObject(); const ObjectPaintProperties* clipProperties = clip->paintProperties(); EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); // No scroll translation because the document does not scroll (not enough @@ -1393,8 +1464,7 @@ // doesn't apply css clip on the object itself. LayoutUnit::max()); - LayoutObject* absolute = - document().getElementById("absolute")->layoutObject(); + auto* absolute = document().getElementById("absolute")->layoutObject(); const ObjectPaintProperties* absPosProperties = absolute->paintProperties(); EXPECT_EQ( clipProperties->cssClip(), @@ -1494,10 +1564,17 @@ TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { setBodyInnerHTML( + "<style>" + " #spanner {" + " column-span: all;" + " opacity: 0.5;" + " width: 100px;" + " height: 100px;" + " }" + "</style>" "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" " <div style='position: relative; top: 100px; left: 100px'>" - " <div id='spanner' style='column-span: all; opacity: 0.5; width: " - "100px; height: 100px;'></div>" + " <div id='spanner'></div>" " </div>" "</div>"); @@ -1514,10 +1591,21 @@ "<style>" " * { margin: 0; }" " div { position: absolute; }" + " #a {" + " width: 70px;" + " height: 70px;" + " left: 0.1px;" + " top: 0.3px;" + " }" + " #b {" + " width: 40px;" + " height: 40px;" + " left: 0.5px;" + " top: 11.1px;" + " }" "</style>" - "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'>" - " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: " - "11.1px;'></div>" + "<div id='a'>" + " <div id='b'></div>" "</div>"); FrameView* frameView = document().view(); @@ -1543,12 +1631,27 @@ "<style>" " * { margin: 0; }" " div { position: relative; }" + " #a {" + " width: 70px;" + " height: 70px;" + " left: 0.3px;" + " top: 0.3px;" + " }" + " #b {" + " width: 40px;" + " height: 40px;" + " transform: translateZ(0);" + " }" + " #c {" + " width: 40px;" + " height: 40px;" + " left: 0.1px;" + " top: 0.1px;" + " }" "</style>" - "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'>" - " <div id='b' style='width: 40px; height: 40px; transform: " - "translateZ(0);'>" - " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: " - "0.1px;'></div>" + "<div id='a'>" + " <div id='b'>" + " <div id='c'></div>" " </div>" "</div>"); FrameView* frameView = document().view(); @@ -1567,8 +1670,7 @@ CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b, frameView->layoutView()); - // c should be painted starting at subpixelAccumulation + (0.1,0.1) = - // (0.4,0.4). + // c's painted should start at subpixelAccumulation + (0.1,0.1) = (0.4,0.4). LayoutObject* c = document().getElementById("c")->layoutObject(); LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1)); @@ -1587,12 +1689,27 @@ "<style>" " * { margin: 0; }" " div { position: relative; }" + " #a {" + " width: 70px;" + " height: 70px;" + " left: 0.7px;" + " top: 0.7px;" + " }" + " #b {" + " width: 40px;" + " height: 40px;" + " transform: translateZ(0);" + " }" + " #c {" + " width: 40px;" + " height: 40px;" + " left: 0.7px;" + " top: 0.7px;" + " }" "</style>" - "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'>" - " <div id='b' style='width: 40px; height: 40px; transform: " - "translateZ(0);'>" - " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: " - "0.7px;'></div>" + "<div id='a'>" + " <div id='b'>" + " <div id='c'></div>" " </div>" "</div>"); FrameView* frameView = document().view(); @@ -1613,8 +1730,7 @@ LayoutUnit(40), LayoutUnit(40)), b, frameView->layoutView()); - // c should be painted starting at subpixelAccumulation + (0.7,0.7) = - // (0.4,0.4). + // c's painting should start at subpixelAccumulation + (0.7,0.7) = (0.4,0.4). LayoutObject* c = document().getElementById("c")->layoutObject(); LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); @@ -1635,14 +1751,33 @@ "<style>" " * { margin: 0; }" " div { position: relative; }" + " #a {" + " width: 70px;" + " height: 70px;" + " left: 0.7px;" + " top: 0.7px;" + " }" + " #b {" + " width: 40px;" + " height: 40px;" + " transform: translate3d(5px, 7px, 0);" + " }" + " #c {" + " width: 40px;" + " height: 40px;" + " transform: translate3d(11px, 13px, 0);" + " }" + " #d {" + " width: 40px;" + " height: 40px;" + " left: 0.7px;" + " top: 0.7px;" + " }" "</style>" - "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'>" - " <div id='b' style='width: 40px; height: 40px; transform: " - "translate3d(5px, 7px, 0);'>" - " <div id='c' style='width: 40px; height: 40px; transform: " - "translate3d(11px, 13px, 0);'>" - " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: " - "0.7px;'></div>" + "<div id='a'>" + " <div id='b'>" + " <div id='c'>" + " <div id='d'></div>" " </div>" " </div>" "</div>"); @@ -1699,14 +1834,34 @@ setBodyInnerHTML( "<style>" " * { margin: 0; }" + " #a {" + " width: 70px;" + " height: 70px;" + " left: 0.7px;" + " position: relative;" + " }" + " #b {" + " width: 40px;" + " height: 40px;" + " transform: translateZ(0);" + " position: relative;" + " }" + " #fixed {" + " width: 40px;" + " height: 40px;" + " position: fixed;" + " }" + " #d {" + " width: 40px;" + " height: 40px;" + " left: 0.7px;" + " position: relative;" + " }" "</style>" - "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: " - "relative;'>" - " <div id='b' style='width: 40px; height: 40px; transform: " - "translateZ(0); position: relative;'>" - " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'>" - " <div id='d' style='width: 40px; height: 40px; left: 0.7px; " - "position: relative;'></div>" + "<div id='a'>" + " <div id='b'>" + " <div id='fixed'>" + " <div id='d'></div>" " </div>" " </div>" "</div>"); @@ -1753,8 +1908,14 @@ TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) { setBodyInnerHTML( - "<svg id='svg' style='position: relative; left: 0.1px; transform: " - "matrix(1, 0, 0, 1, 0, 0);'>" + "<style>" + " #svg {" + " position: relative;" + " left: 0.1px;" + " transform: matrix(1, 0, 0, 1, 0, 0);" + " }" + "</style>" + "<svg id='svg'>" " <rect id='rect' transform='translate(1, 1)'/>" "</svg>"); @@ -1786,7 +1947,7 @@ TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) { setBodyInnerHTML( "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>" - " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1,1)'>" + " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1, 1)'>" " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>" " </div>" " </foreignObject>" @@ -1830,10 +1991,10 @@ TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) { setBodyInnerHTML( "<div style='transform-style: preserve-3d'>" - " <div id='a' style='transform: translateZ(0); width: 30px; height: " - "40px'></div>" - " <div id='b' style='transform: translateZ(0); width: 20px; height: " - "10px'></div>" + " <div id='a'" + " style='transform: translateZ(0); width: 30px; height: 40px'></div>" + " <div id='b'" + " style='transform: translateZ(0); width: 20px; height: 10px'></div>" "</div>"); FrameView* frameView = document().view(); @@ -1854,11 +2015,21 @@ TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) { setBodyInnerHTML( + "<style>" + " #a {" + " transform: translateZ(0);" + " width: 30px;" + " height: 40px;" + " }" + " #b {" + " transform: translateZ(0);" + " width: 10px;" + " height: 20px;" + " }" + "</style>" "<div style='transform-style: preserve-3d'>" - " <div id='a' style='transform: translateZ(0); width: 30px; height: " - "40px'>" - " <div id='b' style='transform: translateZ(0); width: 10px; height: " - "20px'></div>" + " <div id='a'>" + " <div id='b'></div>" " </div>" "</div>"); FrameView* frameView = document().view(); @@ -1882,12 +2053,12 @@ TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts) { setBodyInnerHTML( "<div style='transform-style: preserve-3d'>" - " <div id='a' style='transform: translateZ(0); width: 50px; height: " - "60px'>" - " <div style='transform-style: preserve-3d; width: 30px; height: " - "40px'>" - " <div id='b' style='transform: translateZ(0); width: 10px; height: " - "20px'>" + " <div id='a'" + " style='transform: translateZ(0); width: 50px; height: 60px'>" + " <div" + " style='transform-style: preserve-3d; width: 30px; height: 40px'>" + " <div id='b'" + " style='transform: translateZ(0); width: 10px; height: 20px'>" " </div>" " </div>" "</div>"); @@ -1938,10 +2109,21 @@ TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren) { setBodyInnerHTML( - "<div id='a' style='transform: translateZ(0); transform-style: flat; " - "width: 30px; height: 40px'>" - " <div id='b' style='transform: translateZ(0); width: 10px; height: " - "10px'></div>" + "<style>" + " #a {" + " transform: translateZ(0);" + " transform-style: flat;" + " width: 30px;" + " height: 40px;" + " }" + " #b {" + " transform: translateZ(0);" + " width: 10px;" + " height: 10px;" + " }" + "</style>" + "<div id='a'>" + " <div id='b'></div>" "</div>"); FrameView* frameView = document().view(); @@ -1963,10 +2145,21 @@ TEST_P(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildren) { setBodyInnerHTML( - "<div id='a' style='transform: translateZ(0); transform-style: " - "preserve-3d; width: 30px; height: 40px'>" - " <div id='b' style='transform: translateZ(0); width: 10px; height: " - "10px'></div>" + "<style>" + " #a {" + " transform: translateZ(0);" + " transform-style: preserve-3d;" + " width: 30px;" + " height: 40px;" + " }" + " #b {" + " transform: translateZ(0);" + " width: 10px;" + " height: 10px;" + " }" + "</style>" + "<div id='a'>" + " <div id='b'></div>" "</div>"); FrameView* frameView = document().view(); @@ -1990,9 +2183,10 @@ // ones that combine with it preserve 3D. Otherwise, the perspective doesn't // do anything. setBodyInnerHTML( - "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" - " <div id='b' style='transform: translateZ(0); width: 10px; height: " - "20px'></div>" + "<div id='a'" + " style='perspective: 800px; width: 30px; height: 40px'>" + " <div id='b'" + " style='transform: translateZ(0); width: 10px; height: 20px'></div>" "</div>"); FrameView* frameView = document().view(); @@ -2016,9 +2210,10 @@ // ones that combine with it preserve 3D. Otherwise, the perspective doesn't // do anything. setBodyInnerHTML( - "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" - " <div id='b' style='transform: translateZ(0); width: 10px; height: " - "20px'></div>" + "<div id='a'" + " style='perspective: 800px; width: 30px; height: 40px'>" + " <div id='b'" + " style='transform: translateZ(0); width: 10px; height: 20px'></div>" "</div>"); FrameView* frameView = document().view(); @@ -2040,11 +2235,11 @@ setBodyInnerHTML( "<style>body { margin: 0 }</style>" "<div id='a' style='transform: translate(33px, 44px); width: 50px; " - "height: 60px'>" + " height: 60px'>" " <div id='b' style='transform: translate(55px, 66px); width: 30px; " - "height: 40px'>" + " height: 40px'>" " <div id='c' style='transform: translate(77px, 88px); width: 10px; " - "height: 20px'>C<div>" + " height: 20px'>C<div>" " </div>" "</div>"); FrameView* frameView = document().view(); @@ -2155,9 +2350,10 @@ // containing block that is not one of the painting ancestors. setBodyInnerHTML( "<style>body { margin: 20px 30px; }</style>" - "<div id='clipper' style='overflow:hidden; width:400px; height:300px;'>" - " <div id='child' style='position:relative; width:500px; height: " - "600px;'></div>" + "<div id='clipper'" + " style='overflow: hidden; width: 400px; height: 300px;'>" + " <div id='child'" + " style='position: relative; width: 500px; height: 600px;'></div>" "</div>"); LayoutBoxModelObject* clipper = toLayoutBoxModelObject( @@ -2197,9 +2393,10 @@ TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) { setBodyInnerHTML( "<style>body { margin: 20px 30px; }</style>" - "<div id='clipper' style='contain:paint; width:300px; height:200px;'>" - " <div id='child' style='position:relative; width:400px; height: " - "500px;'></div>" + "<div id='clipper'" + " style='contain: paint; width: 300px; height: 200px;'>" + " <div id='child'" + " style='position: relative; width: 400px; height: 500px;'></div>" "</div>"); LayoutBoxModelObject* clipper = toLayoutBoxModelObject( @@ -2243,8 +2440,8 @@ setBodyInnerHTML( "<style>body { margin: 20px 30px; }</style>" "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>" - " <div id='child' style='position:relative; width:500px; height: " - "600px;'></div>" + " <div id='child'" + " style='position:relative; width:500px; height: 600px;'></div>" " <div style='width: 200px; height: 10000px'></div>" "</div>" "<div id='forceScroll' style='height: 4000px;'></div>"); @@ -2672,8 +2869,7 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGRootClip) { setBodyInnerHTML( - "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' " - "height='100px'>" + "<svg id='svg' width='100px' height='100px'>" " <rect width='200' height='200' fill='red' />" "</svg>");
diff --git a/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp index edc04ae0..1bf13cc 100644 --- a/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp
@@ -317,7 +317,7 @@ bool SVGSVGElement::checkIntersectionOrEnclosure( const SVGElement& element, const FloatRect& rect, - CheckIntersectionOrEnclosure mode) const { + GeometryMatchingMode mode) const { LayoutObject* layoutObject = element.layoutObject(); ASSERT(!layoutObject || layoutObject->style()); if (!layoutObject || @@ -351,7 +351,7 @@ StaticNodeList* SVGSVGElement::collectIntersectionOrEnclosureList( const FloatRect& rect, SVGElement* referenceElement, - CheckIntersectionOrEnclosure mode) const { + GeometryMatchingMode mode) const { HeapVector<Member<Node>> nodes; const SVGElement* root = this;
diff --git a/third_party/WebKit/Source/core/svg/SVGSVGElement.h b/third_party/WebKit/Source/core/svg/SVGSVGElement.h index 24c3b36..54378e7 100644 --- a/third_party/WebKit/Source/core/svg/SVGSVGElement.h +++ b/third_party/WebKit/Source/core/svg/SVGSVGElement.h
@@ -143,15 +143,15 @@ void finishParsingChildren() override; - enum CheckIntersectionOrEnclosure { CheckIntersection, CheckEnclosure }; + enum GeometryMatchingMode { CheckIntersection, CheckEnclosure }; bool checkIntersectionOrEnclosure(const SVGElement&, const FloatRect&, - CheckIntersectionOrEnclosure) const; + GeometryMatchingMode) const; StaticNodeList* collectIntersectionOrEnclosureList( const FloatRect&, SVGElement*, - CheckIntersectionOrEnclosure) const; + GeometryMatchingMode) const; Member<SVGAnimatedLength> m_x; Member<SVGAnimatedLength> m_y;
diff --git a/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.cpp b/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.cpp index ead66d8..28503bb 100644 --- a/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.cpp +++ b/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.cpp
@@ -862,8 +862,8 @@ } SMILInterval SVGSMILElement::resolveInterval( - ResolveInterval resolveIntervalType) const { - bool first = resolveIntervalType == FirstInterval; + IntervalSelector intervalSelector) const { + bool first = intervalSelector == FirstInterval; // See the pseudocode in http://www.w3.org/TR/SMIL3/smil-timing.html#q90. SMILTime beginAfter = first ? -std::numeric_limits<double>::infinity() : m_interval.end;
diff --git a/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h b/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h index 2db1707b..ac3a12e 100644 --- a/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h +++ b/third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h
@@ -166,9 +166,9 @@ SMILTime minimumTime, bool equalsMinimumOK) const; - enum ResolveInterval { FirstInterval, NextInterval }; + enum IntervalSelector { FirstInterval, NextInterval }; - SMILInterval resolveInterval(ResolveInterval) const; + SMILInterval resolveInterval(IntervalSelector) const; void resolveFirstInterval(); bool resolveNextInterval(); SMILTime resolveActiveEnd(SMILTime resolvedBegin, SMILTime resolvedEnd) const;
diff --git a/third_party/WebKit/Source/devtools/front_end/components/ShortcutsScreen.js b/third_party/WebKit/Source/devtools/front_end/components/ShortcutsScreen.js index a63b17d..eaf42c9 100644 --- a/third_party/WebKit/Source/devtools/front_end/components/ShortcutsScreen.js +++ b/third_party/WebKit/Source/devtools/front_end/components/ShortcutsScreen.js
@@ -158,11 +158,9 @@ section.addAlternateKeys( UI.shortcutRegistry.shortcutDescriptorsForAction('main.reload'), Common.UIString('Record page reload')); section.addAlternateKeys( - UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'), - Common.UIString('Save timeline data')); + UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'), Common.UIString('Save profile')); section.addAlternateKeys( - UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'), - Common.UIString('Load timeline data')); + UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'), Common.UIString('Load profile')); section.addRelatedKeys( UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-previous-frame') .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-next-frame')),
diff --git a/third_party/WebKit/Source/devtools/front_end/main/Main.js b/third_party/WebKit/Source/devtools/front_end/main/Main.js index bc8eee7..c8fe3c8e 100644 --- a/third_party/WebKit/Source/devtools/front_end/main/Main.js +++ b/third_party/WebKit/Source/devtools/front_end/main/Main.js
@@ -113,8 +113,6 @@ Runtime.experiments.register('sourceDiff', 'Source diff'); Runtime.experiments.register('terminalInDrawer', 'Terminal in drawer', true); Runtime.experiments.register('timelineInvalidationTracking', 'Timeline invalidation tracking', true); - Runtime.experiments.register('timelineLandingPage', 'Timeline landing page'); - Runtime.experiments.register('timelineRecordingPerspectives', 'Timeline recording perspectives UI'); Runtime.experiments.register('timelineTracingJSProfile', 'Timeline tracing based JS profiler', true); Runtime.experiments.register('timelineV8RuntimeCallStats', 'V8 Runtime Call Stats on Timeline', true); Runtime.experiments.register('timelinePerFrameTrack', 'Show track per frame on Timeline', true); @@ -130,8 +128,7 @@ Runtime.experiments.enableForTest('cssTrackerPanel'); } - Runtime.experiments.setDefaultExperiments( - ['timelineLandingPage', 'timelineRecordingPerspectives', 'persistenceValidation']); + Runtime.experiments.setDefaultExperiments(['persistenceValidation']); } /**
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js index 49aa0d8..3f46bef 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js
@@ -7,7 +7,6 @@ super(true); this.registerRequiredCSS('timeline/timelineLandingPage.css'); this.contentElement.classList.add('timeline-landing-page', 'fill'); - const perspectives = Timeline.TimelinePanel.Perspectives; const config = Timeline.TimelineLandingPage.RecordingConfig; this._tabbedPane = new UI.TabbedPane(); this._tabbedPane.setTabSlider(true); @@ -22,7 +21,7 @@ tab.appendDescription(Common.UIString( 'The basic profile collects network, JavaScript and browser activity as you interact with the page.')); tab.appendOption(config.screenshots, true); - this._tabbedPane.appendTab(perspectives.Responsiveness, Common.UIString('Basic'), tab); + this._tabbedPane.appendTab('basic', Common.UIString('Basic'), tab); tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); tab.appendDescription(Common.UIString( @@ -32,7 +31,7 @@ tab.appendOption(config.screenshots, true); tab.appendOption(config.javascript, true); tab.appendOption(config.paints, false); - this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Advanced'), tab); + this._tabbedPane.appendTab('advanced', Common.UIString('Advanced'), tab); this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._tabSelected, this); this._tabbedPane.show(this.contentElement); @@ -42,8 +41,8 @@ */ function learnMore() { return UI.createExternalLink( - 'https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/', - Common.UIString('Learn more')); + 'https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/', + Common.UIString('Learn more')); } } @@ -67,15 +66,15 @@ screenshots: { id: 'screenshots', title: Common.UIString('Screenshots'), - description: - Common.UIString('Collect page screenshots, so you can observe how the page was evolving during recording.'), + description: Common.UIString( + 'Collect page screenshots, so you can observe how the page was evolving during recording (moderate performance overhead).'), setting: 'timelineCaptureFilmStrip' }, paints: { id: 'paints', title: Common.UIString('Paints'), description: Common.UIString( - 'Capture graphics layer positions and rasterization draw calls (moderate performance overhead).'), + 'Capture graphics layer positions and rasterization draw calls (significant performance overhead).'), setting: 'timelineCaptureLayersAndPictures' } }; @@ -87,9 +86,9 @@ this._enabledOptions = new Set([Timeline.TimelineLandingPage.RecordingConfig.javascript.id]); this._descriptionDiv = this.contentElement.createChild('div', 'timeline-perspective-description'); this._actionButtonDiv = this.contentElement.createChild('div'); - this._actionButtonDiv.appendChild(createTextButton(Common.UIString('Record Page Load'), - this._recordPageLoad.bind(this))); - this._actionButtonDiv.appendChild(createTextButton(Common.UIString('Record'), this._record.bind(this))); + this._actionButtonDiv.appendChild(createTextButton(Common.UIString('Start profiling'), this._record.bind(this))); + this._actionButtonDiv.appendChild( + createTextButton(Common.UIString('Profile page load'), this._recordPageLoad.bind(this))); } /**
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js index 9ecd32a1..0ebe7ea 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
@@ -134,7 +134,7 @@ this._detailsSplitWidget.show(this._timelinePane.element); this._detailsSplitWidget.hideSidebar(); SDK.targetManager.addEventListener(SDK.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChanged, this); - this._showRecordingHelpMessage(); + this._showLandingPage(); /** @type {!SDK.TracingModel.Event}|undefined */ this._selectedSearchResult; @@ -286,130 +286,24 @@ _recreateToolbarItems() { this._panelToolbar.removeToolbarItems(); - const perspectiveSetting = - Common.settings.createSetting('timelinePerspective', Timeline.TimelinePanel.Perspectives.Load); - // Record - if (Runtime.experiments.isEnabled('timelineLandingPage')) { - const newButton = new UI.ToolbarButton(Common.UIString('New recording'), 'largeicon-add', Common.UIString('New')); - newButton.addEventListener(UI.ToolbarButton.Events.Click, this._clear, this); - this._panelToolbar.appendToolbarItem(newButton); - this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButtonForId('main.reload')); - this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._toggleRecordAction)); - } else if ( - Runtime.experiments.isEnabled('timelineRecordingPerspectives') && - perspectiveSetting.get() === Timeline.TimelinePanel.Perspectives.Load) { - const reloadButton = new UI.ToolbarButton(Common.UIString('Record & Reload'), 'largeicon-refresh'); - reloadButton.addEventListener(UI.ToolbarButton.Events.Click, () => SDK.targetManager.reloadPage()); - this._panelToolbar.appendToolbarItem(reloadButton); - } else { - this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._toggleRecordAction)); - } - - // Clear - if (!Runtime.experiments.isEnabled('timelineLandingPage')) { - const clearButton = new UI.ToolbarButton(Common.UIString('Clear recording'), 'largeicon-clear'); - clearButton.addEventListener(UI.ToolbarButton.Events.Click, this._clear, this); - this._panelToolbar.appendToolbarItem(clearButton); - } + const newButton = new UI.ToolbarButton(Common.UIString('New recording'), 'largeicon-add', Common.UIString('New')); + newButton.addEventListener(UI.ToolbarButton.Events.Click, this._clear, this); + this._panelToolbar.appendToolbarItem(newButton); + this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._toggleRecordAction)); + this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButtonForId('main.reload')); this._panelToolbar.appendSeparator(); - // Combo - if (!Runtime.experiments.isEnabled('timelineLandingPage') && - Runtime.experiments.isEnabled('timelineRecordingPerspectives')) { - /** - * @this {!Timeline.TimelinePanel} - */ - function onPerspectiveChanged() { - perspectiveSetting.set(perspectiveCombobox.selectElement().value); - this._recreateToolbarItems(); - } - - /** - * @param {string} id - * @param {string} title - */ - function addPerspectiveOption(id, title) { - var option = perspectiveCombobox.createOption(title, '', id); - perspectiveCombobox.addOption(option); - if (id === perspectiveSetting.get()) - perspectiveCombobox.select(option); - } - - var perspectiveCombobox = new UI.ToolbarComboBox(onPerspectiveChanged.bind(this)); - addPerspectiveOption(Timeline.TimelinePanel.Perspectives.Load, Common.UIString('Page Load')); - addPerspectiveOption(Timeline.TimelinePanel.Perspectives.Responsiveness, Common.UIString('Responsiveness')); - addPerspectiveOption(Timeline.TimelinePanel.Perspectives.JavaScript, Common.UIString('JavaScript')); - addPerspectiveOption(Timeline.TimelinePanel.Perspectives.Custom, Common.UIString('Custom')); - this._panelToolbar.appendToolbarItem(perspectiveCombobox); - - this._bulkUpdate = true; - - switch (perspectiveSetting.get()) { - case Timeline.TimelinePanel.Perspectives.Load: - this._captureNetworkSetting.set(true); - this._captureJSProfileSetting.set(true); - this._captureMemorySetting.set(false); - this._captureLayersAndPicturesSetting.set(false); - this._captureFilmStripSetting.set(true); - break; - case Timeline.TimelinePanel.Perspectives.Responsiveness: - this._captureNetworkSetting.set(true); - this._captureJSProfileSetting.set(true); - this._captureMemorySetting.set(false); - this._captureLayersAndPicturesSetting.set(false); - this._captureFilmStripSetting.set(false); - break; - case Timeline.TimelinePanel.Perspectives.JavaScript: - this._captureNetworkSetting.set(false); - this._captureJSProfileSetting.set(true); - this._captureMemorySetting.set(false); - this._captureLayersAndPicturesSetting.set(false); - this._captureFilmStripSetting.set(false); - this._detailsView.selectTab(Timeline.TimelinePanel.DetailsTab.BottomUp, false); - break; - } - - this._bulkUpdate = false; - this._onModeChanged(); - } - // Checkboxes - if (Runtime.experiments.isEnabled('timelineLandingPage')) { - if (!this._model.isEmpty()) { + if (!this._model.isEmpty()) { + this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( + Common.UIString('Memory'), this._showMemorySetting, Common.UIString('Show memory timeline.'))); + if (this._filmStripModel.frames().length) { + this._showScreenshotsSetting.set(true); this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( - Common.UIString('Memory'), this._showMemorySetting, Common.UIString('Show memory timeline.'))); - if (this._filmStripModel.frames().length) { - this._showScreenshotsSetting.set(true); - this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( - Common.UIString('Screenshots'), this._showScreenshotsSetting, - Common.UIString('Show captured screenshots.'))); - } - } - } else { - const screenshotCheckbox = this._createSettingCheckbox( - Common.UIString('Screenshots'), this._captureFilmStripSetting, - Common.UIString('Capture screenshots while recording. (Has small performance overhead)')); - - if (!Runtime.experiments.isEnabled('timelineRecordingPerspectives') || - perspectiveSetting.get() === Timeline.TimelinePanel.Perspectives.Custom) { - this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( - Common.UIString('Network'), this._captureNetworkSetting, - Common.UIString('Show network requests information'))); - this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( - Common.UIString('JS Profile'), this._captureJSProfileSetting, - Common.UIString('Capture JavaScript stacks with sampling profiler. (Has small performance overhead)'))); - this._panelToolbar.appendToolbarItem(screenshotCheckbox); - this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( - Common.UIString('Memory'), this._captureMemorySetting, - Common.UIString('Capture memory information on every timeline event.'))); - this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( - Common.UIString('Paint'), this._captureLayersAndPicturesSetting, - Common.UIString( - 'Capture graphics layer positions and rasterization draw calls. (Has large performance overhead)'))); - } else { - this._panelToolbar.appendToolbarItem(screenshotCheckbox); + Common.UIString('Screenshots'), this._showScreenshotsSetting, + Common.UIString('Show captured screenshots.'))); } } @@ -512,7 +406,7 @@ return true; var now = new Date(); - var fileName = 'TimelineRawData-' + now.toISO8601Compact() + '.json'; + var fileName = 'Profile-' + now.toISO8601Compact() + '.json'; var stream = new Bindings.FileOutputStream(); /** @@ -564,13 +458,8 @@ } _onModeChanged() { - if (this._bulkUpdate) - return; - const showMemory = Runtime.experiments.isEnabled('timelineLandingPage') ? this._showMemorySetting.get() : - this._captureMemorySetting.get(); - const showScreenshots = Runtime.experiments.isEnabled('timelineLandingPage') ? - this._showScreenshotsSetting.get() && this._filmStripModel.frames().length : - this._captureFilmStripSetting.get(); + const showMemory = this._showMemorySetting.get(); + const showScreenshots = this._showScreenshotsSetting.get() && this._filmStripModel.frames().length; // Set up overview controls. this._overviewControls = []; this._overviewControls.push(new Timeline.TimelineEventOverviewResponsiveness(this._model, this._frameModel)); @@ -596,8 +485,7 @@ this._addModeView( new Timeline.MemoryCountersGraph(this, this._model, [Timeline.TimelineUIUtils.visibleEventsFilter()])); } - if (Runtime.experiments.isEnabled('timelineLandingPage')) - this._flameChart.enableNetworkPane(true); + this._flameChart.enableNetworkPane(true); this.doResize(); this.select(null); @@ -656,7 +544,7 @@ if (userInitiated) Host.userMetrics.actionTaken(Host.UserMetrics.Action.TimelineStarted); this._setUIControlsEnabled(false); - this._hideRecordingHelpMessage(); + this._hideLandingPage(); } _stopRecording() { @@ -692,7 +580,7 @@ } _clear() { - this._showRecordingHelpMessage(); + this._showLandingPage(); this._detailsSplitWidget.hideSidebar(); this._sessionGeneration = null; this._recordingStartTime = 0; @@ -725,10 +613,10 @@ this._reset(); this._setState(Timeline.TimelinePanel.State.Recording); this._showRecordingStarted(); - this._statusPane.updateStatus(Common.UIString('Recording\u2026')); + this._statusPane.updateStatus(Common.UIString('Profiling\u2026')); this._statusPane.updateProgressBar(Common.UIString('Buffer usage'), 0); this._statusPane.startTimer(); - this._hideRecordingHelpMessage(); + this._hideLandingPage(); } /** @@ -762,55 +650,6 @@ return this._sessionGeneration; } - _showRecordingHelpMessage() { - if (Runtime.experiments.isEnabled('timelineLandingPage')) { - this._showLandingPage(); - return; - } - - /** - * @param {string} tagName - * @param {string} contents - * @return {!Element} - */ - function encloseWithTag(tagName, contents) { - var e = createElement(tagName); - e.textContent = contents; - return e; - } - - var recordNode = - encloseWithTag('b', UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.toggle-recording')[0].name); - var reloadNode = encloseWithTag('b', UI.shortcutRegistry.shortcutDescriptorsForAction('main.reload')[0].name); - var navigateNode = encloseWithTag('b', Common.UIString('WASD (ZQSD)')); - var hintText = createElementWithClass('div'); - hintText.appendChild( - UI.formatLocalized('To capture a new timeline, click the record toolbar button or hit %s.', [recordNode])); - hintText.createChild('br'); - hintText.appendChild( - UI.formatLocalized('To evaluate page load performance, hit %s to record the reload.', [reloadNode])); - hintText.createChild('p'); - hintText.appendChild( - UI.formatLocalized('After recording, select an area of interest in the overview by dragging.', [])); - hintText.createChild('br'); - hintText.appendChild( - UI.formatLocalized('Then, zoom and pan the timeline with the mousewheel and %s keys.', [navigateNode])); - this._hideRecordingHelpMessage(); - this._helpMessageElement = - this._searchableView.element.createChild('div', 'full-widget-dimmed-banner timeline-status-pane'); - this._helpMessageElement.appendChild(hintText); - } - - _hideRecordingHelpMessage() { - if (Runtime.experiments.isEnabled('timelineLandingPage')) { - this._hideLandingPage(); - return; - } - if (this._helpMessageElement) - this._helpMessageElement.remove(); - delete this._helpMessageElement; - } - _showLandingPage() { if (this._landingPage) return; @@ -831,13 +670,13 @@ * @override */ loadingStarted() { - this._hideRecordingHelpMessage(); + this._hideLandingPage(); if (this._statusPane) this._statusPane.hide(); this._statusPane = new Timeline.TimelinePanel.StatusPane(false, this._cancelLoading.bind(this)); this._statusPane.showPane(this._statusPaneContainer); - this._statusPane.updateStatus(Common.UIString('Loading timeline\u2026')); + this._statusPane.updateStatus(Common.UIString('Loading profile\u2026')); // FIXME: make loading from backend cancelable as well. if (!this._loader) this._statusPane.finish(); @@ -870,7 +709,7 @@ } if (this._statusPane) - this._statusPane.updateStatus(Common.UIString('Processing timeline\u2026')); + this._statusPane.updateStatus(Common.UIString('Processing profile\u2026')); this._model.setEvents(this._tracingModel, loadedFromFile); this._frameModel.reset(); this._frameModel.addTraceEvents( @@ -906,7 +745,7 @@ return; this._statusPane = new Timeline.TimelinePanel.StatusPane(true, this._stopRecording.bind(this)); this._statusPane.showPane(this._statusPaneContainer); - this._statusPane.updateStatus(Common.UIString('Initializing recording\u2026')); + this._statusPane.updateStatus(Common.UIString('Initializing profiler\u2026')); } _cancelLoading() { @@ -1353,16 +1192,6 @@ /** * @enum {string} */ -Timeline.TimelinePanel.Perspectives = { - Load: 'Load', - Responsiveness: 'Responsiveness', - JavaScript: 'JavaScript', - Custom: 'Custom' -}; - -/** - * @enum {string} - */ Timeline.TimelinePanel.DetailsTab = { Details: 'Details', Events: 'Events',
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/module.json b/third_party/WebKit/Source/devtools/front_end/timeline/module.json index 698db2cc..1f16c0d4 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/module.json +++ b/third_party/WebKit/Source/devtools/front_end/timeline/module.json
@@ -60,7 +60,7 @@ "actionId": "timeline.save-to-file", "contextTypes": ["Timeline.TimelinePanel"], "className": "Timeline.TimelinePanel.ActionDelegate", - "title": "Save Timeline data\u2026", + "title": "Save profile\u2026", "bindings": [ { "platform": "windows,linux", @@ -79,7 +79,7 @@ "contextTypes": ["Timeline.TimelinePanel"], "order": "10", "className": "Timeline.TimelinePanel.ActionDelegate", - "title": "Load Timeline data\u2026", + "title": "Load profile\u2026", "bindings": [ { "platform": "windows,linux",
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp b/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp index 411db19..e20faa99 100644 --- a/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp +++ b/third_party/WebKit/Source/modules/filesystem/FileWriter.cpp
@@ -63,8 +63,7 @@ FileWriter::~FileWriter() { ASSERT(!m_recursionDepth); - if (m_readyState == kWriting) - contextDestroyed(); + DCHECK(!writer()); } const AtomicString& FileWriter::interfaceName() const { @@ -74,10 +73,11 @@ void FileWriter::contextDestroyed() { // Make sure we've actually got something to stop, and haven't already called // abort(). - if (!writer() || m_readyState != kWriting) - return; - doOperation(OperationAbort); - m_readyState = kDone; + if (writer() && m_readyState == kWriting) { + doOperation(OperationAbort); + m_readyState = kDone; + } + resetWriter(); } bool FileWriter::hasPendingActivity() const { @@ -306,6 +306,10 @@ m_error = FileError::createDOMException(errorCode); } +void FileWriter::dispose() { + contextDestroyed(); +} + DEFINE_TRACE(FileWriter) { visitor->trace(m_error); visitor->trace(m_blobBeingWritten);
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriter.h b/third_party/WebKit/Source/modules/filesystem/FileWriter.h index c23ec686..a32982d 100644 --- a/third_party/WebKit/Source/modules/filesystem/FileWriter.h +++ b/third_party/WebKit/Source/modules/filesystem/FileWriter.h
@@ -53,6 +53,7 @@ public WebFileWriterClient { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(FileWriter); + USING_PRE_FINALIZER(FileWriter, dispose); public: static FileWriter* create(ExecutionContext*); @@ -113,6 +114,8 @@ void setError(FileError::ErrorCode, ExceptionState&); + void dispose(); + Member<DOMException> m_error; ReadyState m_readyState; Operation m_operationInProgress;
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriterBase.cpp b/third_party/WebKit/Source/modules/filesystem/FileWriterBase.cpp index 0addf762..8d40c2d 100644 --- a/third_party/WebKit/Source/modules/filesystem/FileWriterBase.cpp +++ b/third_party/WebKit/Source/modules/filesystem/FileWriterBase.cpp
@@ -60,4 +60,14 @@ m_position = position; } +void FileWriterBase::resetWriter() { + m_writer = nullptr; +} + +void FileWriterBase::dispose() { + // Need to explicitly destroy m_writer in pre-finalizer, because otherwise it + // may attempt to call methods on the FileWriter before we are finalized. + resetWriter(); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/modules/filesystem/FileWriterBase.h b/third_party/WebKit/Source/modules/filesystem/FileWriterBase.h index e93dea2..6e9949f 100644 --- a/third_party/WebKit/Source/modules/filesystem/FileWriterBase.h +++ b/third_party/WebKit/Source/modules/filesystem/FileWriterBase.h
@@ -39,6 +39,8 @@ class WebFileWriter; class FileWriterBase : public GarbageCollectedMixin { + USING_PRE_FINALIZER(FileWriterBase, dispose); + public: virtual ~FileWriterBase(); void initialize(std::unique_ptr<WebFileWriter>, long long length); @@ -59,7 +61,11 @@ void seekInternal(long long position); + void resetWriter(); + private: + void dispose(); + std::unique_ptr<WebFileWriter> m_writer; long long m_position; long long m_length;
diff --git a/third_party/WebKit/Source/modules/payments/PaymentAppManager.cpp b/third_party/WebKit/Source/modules/payments/PaymentAppManager.cpp index d7ec888..651476f4 100644 --- a/third_party/WebKit/Source/modules/payments/PaymentAppManager.cpp +++ b/third_party/WebKit/Source/modules/payments/PaymentAppManager.cpp
@@ -101,7 +101,6 @@ ScriptPromise promise = resolver->promise(); m_manager->SetManifest( - m_registration->scope(), payments::mojom::blink::PaymentAppManifest::From(manifest), convertToBaseCallback(WTF::bind(&PaymentAppManager::onSetManifest, wrapPersistent(this), @@ -120,10 +119,9 @@ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); - m_manager->GetManifest(m_registration->scope(), - convertToBaseCallback(WTF::bind( - &PaymentAppManager::onGetManifest, - wrapPersistent(this), wrapPersistent(resolver)))); + m_manager->GetManifest(convertToBaseCallback( + WTF::bind(&PaymentAppManager::onGetManifest, wrapPersistent(this), + wrapPersistent(resolver)))); return promise; } @@ -140,6 +138,8 @@ m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind( &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this)))); + + m_manager->Init(m_registration->scope()); } void PaymentAppManager::onSetManifest(
diff --git a/third_party/WebKit/Source/modules/peerconnection/RTCConfiguration.idl b/third_party/WebKit/Source/modules/peerconnection/RTCConfiguration.idl index 5269333..bbe1b573 100644 --- a/third_party/WebKit/Source/modules/peerconnection/RTCConfiguration.idl +++ b/third_party/WebKit/Source/modules/peerconnection/RTCConfiguration.idl
@@ -38,8 +38,7 @@ // https://crbug.com/659131 RTCIceTransportPolicy iceTransports; RTCBundlePolicy bundlePolicy = "balanced"; - // TODO(foolip): |rtcpMuxPolicy| default should be "require". - RTCRtcpMuxPolicy rtcpMuxPolicy; + RTCRtcpMuxPolicy rtcpMuxPolicy = "require"; // TODO(foolip): DOMString peerIdentity; sequence<RTCCertificate> certificates; // TODO(foolip): unsigned short iceCandidatePoolSize = 0;
diff --git a/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp index d14a526..7645e41 100644 --- a/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp +++ b/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
@@ -229,10 +229,8 @@ WebRTCConfiguration parseConfiguration(ExecutionContext* context, const RTCConfiguration& configuration, - ExceptionState& exceptionState, - RtcpMuxPolicy* selectedRtcpMuxPolicy) { + ExceptionState& exceptionState) { DCHECK(context); - DCHECK(selectedRtcpMuxPolicy); WebRTCIceTransportPolicy iceTransportPolicy = WebRTCIceTransportPolicy::kAll; if (configuration.hasIceTransportPolicy()) { @@ -261,20 +259,13 @@ DCHECK_EQ(bundlePolicyString, "balanced"); } - // For the histogram value of "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". - *selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; - WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; - if (configuration.hasRtcpMuxPolicy()) { - String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); - if (rtcpMuxPolicyString == "require") { - *selectedRtcpMuxPolicy = RtcpMuxPolicyRequire; - rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; - } else { - DCHECK_EQ(rtcpMuxPolicyString, "negotiate"); - *selectedRtcpMuxPolicy = RtcpMuxPolicyNegotiate; - } + WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; + String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); + if (rtcpMuxPolicyString == "negotiate") { + rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; + } else { + DCHECK_EQ(rtcpMuxPolicyString, "require"); } - WebRTCConfiguration webConfiguration; webConfiguration.iceTransportPolicy = iceTransportPolicy; webConfiguration.bundlePolicy = bundlePolicy; @@ -441,11 +432,8 @@ UseCounter::count(context, UseCounter::RTCPeerConnectionConstructorCompliant); - // Record the RtcpMuxPolicy for histogram - // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". - RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; - WebRTCConfiguration configuration = parseConfiguration( - context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); + WebRTCConfiguration configuration = + parseConfiguration(context, rtcConfiguration, exceptionState); if (exceptionState.hadException()) return 0; @@ -477,9 +465,6 @@ if (exceptionState.hadException()) return 0; - peerConnection->m_peerHandler->logSelectedRtcpMuxPolicy( - selectedRtcpMuxPolicy); - return peerConnection; } @@ -811,9 +796,8 @@ if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) return; - RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; - WebRTCConfiguration configuration = parseConfiguration( - context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); + WebRTCConfiguration configuration = + parseConfiguration(context, rtcConfiguration, exceptionState); if (exceptionState.hadException()) return;
diff --git a/third_party/WebKit/Source/modules/webaudio/AnalyserNode.idl b/third_party/WebKit/Source/modules/webaudio/AnalyserNode.idl index a656728..49a80ad 100644 --- a/third_party/WebKit/Source/modules/webaudio/AnalyserNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/AnalyserNode.idl
@@ -27,6 +27,7 @@ [ Constructor(BaseAudioContext context, optional AnalyserOptions options), RaisesException=Constructor, + Measure ] interface AnalyserNode : AudioNode { [RaisesException=Setter] attribute unsigned long fftSize;
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBuffer.idl b/third_party/WebKit/Source/modules/webaudio/AudioBuffer.idl index da798df..a7914fa0 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioBuffer.idl +++ b/third_party/WebKit/Source/modules/webaudio/AudioBuffer.idl
@@ -30,6 +30,7 @@ [ Constructor(BaseAudioContext context, AudioBufferOptions options), RaisesException=Constructor, + Measure ] interface AudioBuffer { readonly attribute long length; // in sample-frames readonly attribute double duration; // in seconds
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.idl b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.idl index bc199b8..b2454cb3 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.idl
@@ -29,6 +29,7 @@ Constructor(BaseAudioContext context, optional AudioBufferSourceOptions options), RaisesException=Constructor, ActiveScriptWrappable, + Measure ] interface AudioBufferSourceNode : AudioSourceNode { [RaisesException=Setter] attribute AudioBuffer buffer;
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h index 65a6743a..1aa09a970 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h +++ b/third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h
@@ -66,6 +66,9 @@ virtual void startRendering() = 0; virtual void stopRendering() = 0; + // Returns the rendering callback buffer size. + virtual size_t callbackBufferSize() const = 0; + protected: // LocalAudioInputProvider allows us to expose an AudioSourceProvider for // local/live audio input. If there is local/live audio input, we call set() @@ -112,6 +115,7 @@ AudioDestinationHandler& audioDestinationHandler() const; unsigned long maxChannelCount() const; + size_t callbackBufferSize() const { return handler().callbackBufferSize(); } protected: AudioDestinationNode(BaseAudioContext&);
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioNode.h b/third_party/WebKit/Source/modules/webaudio/AudioNode.h index 71adc2d..37df1767 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioNode.h +++ b/third_party/WebKit/Source/modules/webaudio/AudioNode.h
@@ -229,6 +229,11 @@ void updateChannelCountMode(); void updateChannelInterpretation(); + // Default callbackBufferSize should be the render quantum size + virtual size_t callbackBufferSize() const { + return AudioUtilities::kRenderQuantumFrames; + } + protected: // Inputs and outputs must be created before the AudioHandler is // initialized.
diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h index 74164a74..0212fc84 100644 --- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h +++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h
@@ -141,6 +141,11 @@ return m_destinationNode ? m_destinationNode->handler().sampleRate() : 0; } + size_t callbackBufferSize() const { + return m_destinationNode ? m_destinationNode->handler().callbackBufferSize() + : 0; + } + String state() const; AudioContextState contextState() const { return m_contextState; } void throwExceptionForClosedState(ExceptionState&);
diff --git a/third_party/WebKit/Source/modules/webaudio/BiquadFilterNode.idl b/third_party/WebKit/Source/modules/webaudio/BiquadFilterNode.idl index 8e86237..90f76ee 100644 --- a/third_party/WebKit/Source/modules/webaudio/BiquadFilterNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/BiquadFilterNode.idl
@@ -38,6 +38,7 @@ [ Constructor(BaseAudioContext context, optional BiquadFilterOptions options), RaisesException=Constructor, + Measure ] interface BiquadFilterNode : AudioNode { attribute BiquadFilterType type;
diff --git a/third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.idl b/third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.idl index 429128a..7573a9f 100644 --- a/third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.idl
@@ -30,6 +30,7 @@ [ Constructor(BaseAudioContext context, optional ChannelMergerOptions options), RaisesException=Constructor, + Measure ] interface ChannelMergerNode : AudioNode { };
diff --git a/third_party/WebKit/Source/modules/webaudio/ChannelSplitterNode.idl b/third_party/WebKit/Source/modules/webaudio/ChannelSplitterNode.idl index 90fc2ecd..c651a69 100644 --- a/third_party/WebKit/Source/modules/webaudio/ChannelSplitterNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/ChannelSplitterNode.idl
@@ -27,6 +27,7 @@ [ Constructor(BaseAudioContext context, optional ChannelSplitterOptions options), RaisesException=Constructor, + Measure ] interface ChannelSplitterNode : AudioNode { };
diff --git a/third_party/WebKit/Source/modules/webaudio/ConstantSourceNode.idl b/third_party/WebKit/Source/modules/webaudio/ConstantSourceNode.idl index 3773817..e99a9ccc 100644 --- a/third_party/WebKit/Source/modules/webaudio/ConstantSourceNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/ConstantSourceNode.idl
@@ -7,6 +7,7 @@ Constructor(BaseAudioContext context, optional ConstantSourceOptions options), RaisesException=Constructor, ActiveScriptWrappable, + Measure ] interface ConstantSourceNode : AudioSourceNode { readonly attribute AudioParam offset;
diff --git a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.idl b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.idl index 3a3c0b1..53559c56 100644 --- a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.idl
@@ -28,6 +28,7 @@ [ Constructor(BaseAudioContext context, optional ConvolverOptions options), RaisesException=Constructor, + Measure ] interface ConvolverNode : AudioNode { [RaisesException=Setter] attribute AudioBuffer? buffer;
diff --git a/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.cpp b/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.cpp index f6f9c48..d1b7bee0 100644 --- a/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.cpp +++ b/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.cpp
@@ -103,6 +103,10 @@ return AudioDestination::maxChannelCount(); } +size_t DefaultAudioDestinationHandler::callbackBufferSize() const { + return m_destination->callbackBufferSize(); +} + void DefaultAudioDestinationHandler::setChannelCount( unsigned long channelCount, ExceptionState& exceptionState) {
diff --git a/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.h b/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.h index d96b3eb..b5fd732 100644 --- a/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.h +++ b/third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.h
@@ -50,6 +50,8 @@ void startRendering() override; void stopRendering() override; unsigned long maxChannelCount() const override; + // Returns the rendering callback buffer size. + size_t callbackBufferSize() const override; private: explicit DefaultAudioDestinationHandler(AudioNode&); @@ -64,6 +66,8 @@ public: static DefaultAudioDestinationNode* create(BaseAudioContext*); + size_t callbackBufferSize() const { return handler().callbackBufferSize(); }; + private: explicit DefaultAudioDestinationNode(BaseAudioContext&); };
diff --git a/third_party/WebKit/Source/modules/webaudio/DelayNode.idl b/third_party/WebKit/Source/modules/webaudio/DelayNode.idl index 9167a99..cc9d24c 100644 --- a/third_party/WebKit/Source/modules/webaudio/DelayNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/DelayNode.idl
@@ -27,6 +27,7 @@ [ Constructor(BaseAudioContext context, optional DelayOptions options), RaisesException=Constructor, + Measure ] interface DelayNode : AudioNode { readonly attribute AudioParam delayTime;
diff --git a/third_party/WebKit/Source/modules/webaudio/DynamicsCompressorNode.idl b/third_party/WebKit/Source/modules/webaudio/DynamicsCompressorNode.idl index 25a813cc..1aee7117 100644 --- a/third_party/WebKit/Source/modules/webaudio/DynamicsCompressorNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/DynamicsCompressorNode.idl
@@ -27,6 +27,7 @@ [ Constructor(BaseAudioContext context, optional DynamicsCompressorOptions options), RaisesException=Constructor, + Measure ] interface DynamicsCompressorNode : AudioNode { readonly attribute AudioParam threshold; // in Decibels
diff --git a/third_party/WebKit/Source/modules/webaudio/GainNode.idl b/third_party/WebKit/Source/modules/webaudio/GainNode.idl index 5de1b8d..74eb6c1 100644 --- a/third_party/WebKit/Source/modules/webaudio/GainNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/GainNode.idl
@@ -27,6 +27,7 @@ [ Constructor(BaseAudioContext context, optional GainOptions options), RaisesException=Constructor, + Measure ] interface GainNode : AudioNode { // FIXME: eventually it will be interesting to remove the readonly restriction, but need to properly deal with thread safety here.
diff --git a/third_party/WebKit/Source/modules/webaudio/IIRFilterNode.idl b/third_party/WebKit/Source/modules/webaudio/IIRFilterNode.idl index 8da52013c..1780a79 100644 --- a/third_party/WebKit/Source/modules/webaudio/IIRFilterNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/IIRFilterNode.idl
@@ -6,6 +6,7 @@ [ Constructor(BaseAudioContext context, IIRFilterOptions options), RaisesException=Constructor, + Measure ] interface IIRFilterNode : AudioNode { [RaisesException] void getFrequencyResponse(Float32Array frequencyHz,
diff --git a/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.idl b/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.idl index 267059a0e..2cb9691 100644 --- a/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.idl
@@ -28,6 +28,7 @@ // TODO(rtoy): This should be AudioContext, not BaseAudioContext. Constructor(BaseAudioContext context, MediaElementAudioSourceOptions options), RaisesException=Constructor, + Measure ] interface MediaElementAudioSourceNode : AudioSourceNode { readonly attribute HTMLMediaElement mediaElement;
diff --git a/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.idl b/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.idl index d056e1ab..aff009f 100644 --- a/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.idl
@@ -27,6 +27,7 @@ [ Constructor(BaseAudioContext context, MediaStreamAudioSourceOptions options), RaisesException=Constructor, + Measure ] interface MediaStreamAudioSourceNode : AudioSourceNode { [ImplementedAs=getMediaStream] readonly attribute MediaStream mediaStream;
diff --git a/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.cpp b/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.cpp index 2b343435..c39d0d2 100644 --- a/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.cpp +++ b/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.cpp
@@ -133,6 +133,11 @@ ASSERT_NOT_REACHED(); } +size_t OfflineAudioDestinationHandler::callbackBufferSize() const { + // The callback buffer size has no meaning for an offline context. + NOTREACHED(); + return 0; +} WebThread* OfflineAudioDestinationHandler::offlineRenderThread() { DCHECK(m_renderThread);
diff --git a/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h b/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h index 30eb3f9..64cbbb3 100644 --- a/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h +++ b/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h
@@ -59,6 +59,10 @@ void stopRendering() override; unsigned long maxChannelCount() const override; + // Returns the rendering callback buffer size. This should never be + // called. + size_t callbackBufferSize() const override; + float sampleRate() const override { return m_renderTarget->sampleRate(); } size_t renderQuantumFrames() const {
diff --git a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.idl b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.idl index 40e648e..117e4ddb 100644 --- a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.idl
@@ -37,6 +37,7 @@ Constructor(BaseAudioContext context, optional OscillatorOptions options), RaisesException=Constructor, ActiveScriptWrappable, + Measure ] interface OscillatorNode : AudioSourceNode {
diff --git a/third_party/WebKit/Source/modules/webaudio/PannerNode.idl b/third_party/WebKit/Source/modules/webaudio/PannerNode.idl index 00f3ae1..e182b198 100644 --- a/third_party/WebKit/Source/modules/webaudio/PannerNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/PannerNode.idl
@@ -38,6 +38,7 @@ [ Constructor(BaseAudioContext context, optional PannerOptions options), RaisesException=Constructor, + Measure ] interface PannerNode : AudioNode { // Default model for stereo is equalpower. attribute PanningModelType panningModel;
diff --git a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.idl b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.idl index dc81ed4d..9ae8e25 100644 --- a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.idl +++ b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.idl
@@ -28,6 +28,7 @@ [ Constructor(BaseAudioContext context, optional PeriodicWaveOptions options), RaisesException=Constructor, + Measure ] interface PeriodicWave { };
diff --git a/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp b/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp index d6cf6f5..316d0522 100644 --- a/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp +++ b/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
@@ -343,14 +343,13 @@ numberOfOutputChannels)); } -static size_t chooseBufferSize() { +static size_t chooseBufferSize(size_t callbackBufferSize) { // Choose a buffer size based on the audio hardware buffer size. Arbitarily // make it a power of two that is 4 times greater than the hardware buffer // size. // FIXME: What is the best way to choose this? - size_t hardwareBufferSize = Platform::current()->audioHardwareBufferSize(); size_t bufferSize = - 1 << static_cast<unsigned>(log2(4 * hardwareBufferSize) + 0.5); + 1 << static_cast<unsigned>(log2(4 * callbackBufferSize) + 0.5); if (bufferSize < 256) return 256; @@ -432,7 +431,14 @@ // Check for valid buffer size. switch (bufferSize) { case 0: - bufferSize = chooseBufferSize(); + // Choose an appropriate size. For an AudioContext, we need to + // choose an appropriate size based on the callback buffer size. + // For OfflineAudioContext, there's no callback buffer size, so + // just use the minimum valid buffer size. + bufferSize = + context.hasRealtimeConstraint() + ? chooseBufferSize(context.destination()->callbackBufferSize()) + : 256; break; case 256: case 512:
diff --git a/third_party/WebKit/Source/modules/webaudio/StereoPannerNode.idl b/third_party/WebKit/Source/modules/webaudio/StereoPannerNode.idl index 68b1e6c..355fb12d 100644 --- a/third_party/WebKit/Source/modules/webaudio/StereoPannerNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/StereoPannerNode.idl
@@ -6,6 +6,7 @@ [ Constructor(BaseAudioContext context, optional StereoPannerOptions options), RaisesException=Constructor, + Measure ] interface StereoPannerNode : AudioNode {
diff --git a/third_party/WebKit/Source/modules/webaudio/WaveShaperNode.idl b/third_party/WebKit/Source/modules/webaudio/WaveShaperNode.idl index 723a942..6289d54 100644 --- a/third_party/WebKit/Source/modules/webaudio/WaveShaperNode.idl +++ b/third_party/WebKit/Source/modules/webaudio/WaveShaperNode.idl
@@ -33,6 +33,7 @@ [ Constructor(BaseAudioContext context, optional WaveShaperOptions options), RaisesException=Constructor, + Measure ] interface WaveShaperNode : AudioNode { [RaisesException=Setter] attribute Float32Array? curve;
diff --git a/third_party/WebKit/Source/platform/audio/AudioDestination.h b/third_party/WebKit/Source/platform/audio/AudioDestination.h index a62c38a..e986b82 100644 --- a/third_party/WebKit/Source/platform/audio/AudioDestination.h +++ b/third_party/WebKit/Source/platform/audio/AudioDestination.h
@@ -92,6 +92,8 @@ static float hardwareSampleRate(); + size_t callbackBufferSize() const { return m_callbackBufferSize; } + // maxChannelCount() returns the total number of output channels of the audio // hardware. A value of 0 indicates that the number of channels cannot be // configured and that only stereo (2-channel) destinations can be created.
diff --git a/third_party/WebKit/Source/platform/graphics/paint/CompositingRecorder.cpp b/third_party/WebKit/Source/platform/graphics/paint/CompositingRecorder.cpp index 7930f26..2a2d3a86 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/CompositingRecorder.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/CompositingRecorder.cpp
@@ -52,8 +52,8 @@ const DisplayItem* lastDisplayItem = paintController.lastDisplayItem(0); const DisplayItem* secondToLastDisplayItem = paintController.lastDisplayItem(1); - if (lastDisplayItem && secondToLastDisplayItem && - lastDisplayItem->drawsContent() && + if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && lastDisplayItem && + secondToLastDisplayItem && lastDisplayItem->drawsContent() && secondToLastDisplayItem->getType() == DisplayItem::kBeginCompositing) { FloatRect cullRect( ((DrawingDisplayItem*)lastDisplayItem)->picture()->cullRect());
diff --git a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h index 0b9e0e9..159c0feb 100644 --- a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h +++ b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h
@@ -87,9 +87,6 @@ TestingPlatformMockScheduler(); ~TestingPlatformMockScheduler() override; - void runSingleTask(); - void runAllTasks(); - // WebScheduler implementation: WebTaskRunner* loadingTaskRunner() override { return nullptr; } WebTaskRunner* timerTaskRunner() override { return nullptr; }
diff --git a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp index 5356075b..5a51b96 100644 --- a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp +++ b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp
@@ -1029,4 +1029,51 @@ MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); } +TEST_F(ScrollingCoordinatorTest, StyleRelatedMainThreadScrollingReason) { + registerMockedHttpURLLoad("two_transparent_scrollable_area.html"); + navigateTo(m_baseURL + "two_transparent_scrollable_area.html"); + webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); + forceFullCompositingUpdate(); + + FrameView* frameView = frame()->view(); + ASSERT_TRUE(frameView); + ASSERT_TRUE(frameView->mainThreadScrollingReasons() & + MainThreadScrollingReason::kHasOpacity); + + // Remove opacity from one of the scrollers. + // Still need to scroll on main thread. + Document* document = frame()->document(); + Element* container = document->getElementById("scroller1"); + DCHECK(container); + + container->removeAttribute("class"); + forceFullCompositingUpdate(); + + ASSERT_TRUE(frameView->mainThreadScrollingReasons() & + MainThreadScrollingReason::kHasOpacity); + + // Remove opacity from the other scroller would lead to + // scroll on impl. + container = document->getElementById("scroller2"); + DCHECK(container); + + container->removeAttribute("class"); + forceFullCompositingUpdate(); + + ASSERT_FALSE(frameView->mainThreadScrollingReasons() & + MainThreadScrollingReason::kHasOpacity); + + // Add opacity would again lead to scroll on main thread + container->setAttribute("class", "transparent", ASSERT_NO_EXCEPTION); + forceFullCompositingUpdate(); + + ASSERT_TRUE(frameView->mainThreadScrollingReasons() & + MainThreadScrollingReason::kHasOpacity); + + webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); + forceFullCompositingUpdate(); + + ASSERT_FALSE(frameView->mainThreadScrollingReasons()); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/web/tests/data/two_transparent_scrollable_area.html b/third_party/WebKit/Source/web/tests/data/two_transparent_scrollable_area.html new file mode 100644 index 0000000..1bfbde4 --- /dev/null +++ b/third_party/WebKit/Source/web/tests/data/two_transparent_scrollable_area.html
@@ -0,0 +1,29 @@ +<!DOCTYPE html> + +<style> +.transparent { + opacity: 0.5; +} + +.content { + height: 500px; +} + +div { + overflow: scroll; + width: 200px; + height: 300px; + background: green; +} + +body { + height: 2000px; +} +</style> + +<div id="scroller1" class="transparent"> + <div class="content"></div> +</div> +<div id="scroller2" class="transparent"> + <div class="content"></div> +</div>
diff --git a/third_party/WebKit/Source/wtf/CPU.h b/third_party/WebKit/Source/wtf/CPU.h index fa2ce906..daedf8e 100644 --- a/third_party/WebKit/Source/wtf/CPU.h +++ b/third_party/WebKit/Source/wtf/CPU.h
@@ -137,7 +137,8 @@ #define WTF_CPU_ARM_NEON 1 #endif -#if CPU(ARM_NEON) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0)) +#if CPU(ARM_NEON) && \ + (COMPILER(CLANG) || !COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0)) // All NEON intrinsics usage can be disabled by this macro. #define HAVE_ARM_NEON_INTRINSICS 1 #endif
diff --git a/third_party/WebKit/public/platform/WebRTCConfiguration.h b/third_party/WebKit/public/platform/WebRTCConfiguration.h index de7c3d7a..cd64fb8 100644 --- a/third_party/WebKit/public/platform/WebRTCConfiguration.h +++ b/third_party/WebKit/public/platform/WebRTCConfiguration.h
@@ -58,7 +58,7 @@ WebVector<WebRTCIceServer> iceServers; WebRTCIceTransportPolicy iceTransportPolicy = WebRTCIceTransportPolicy::kAll; WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::kBalanced; - WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; + WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; WebVector<std::unique_ptr<WebRTCCertificate>> certificates; };
diff --git a/third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h b/third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h index 2842025d..285bcb6b 100644 --- a/third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h +++ b/third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h
@@ -51,15 +51,6 @@ struct WebRTCConfiguration; struct WebRTCDataChannelInit; -// Used to back histogram value of -// "WebRTC.PeerConnection.SelectedRtcpMuxPolicy", so treat as append-only. -enum RtcpMuxPolicy { - RtcpMuxPolicyRequire, - RtcpMuxPolicyNegotiate, - RtcpMuxPolicyDefault, - RtcpMuxPolicyMax -}; - class WebRTCPeerConnectionHandler { public: virtual ~WebRTCPeerConnectionHandler() {} @@ -82,7 +73,6 @@ virtual WebRTCSessionDescription localDescription() = 0; virtual WebRTCSessionDescription remoteDescription() = 0; virtual bool setConfiguration(const WebRTCConfiguration&) = 0; - virtual void logSelectedRtcpMuxPolicy(RtcpMuxPolicy) = 0; // DEPRECATED virtual bool addICECandidate(const WebRTCICECandidate&) { return false; }
diff --git a/third_party/libdrm/BUILD.gn b/third_party/libdrm/BUILD.gn new file mode 100644 index 0000000..8e2b518 --- /dev/null +++ b/third_party/libdrm/BUILD.gn
@@ -0,0 +1,54 @@ +# Copyright 2016 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. +import("//build/config/linux/pkg_config.gni") + +assert(is_linux) + +declare_args() { + # Controls whether the build should use the version of libdrm + # library shipped with the system. In release builds of Chrome OS we + # use the system version, but when building on dev workstations we + # bundle it because Ubuntu doesn't ship a usable version. + use_system_libdrm = true +} + +if (!use_system_libdrm) { + config("libdrm_config") { + include_dirs = [ + "src", + "src/include", + "src/include/drm", + ] + if (is_clang) { + cflags = [ "-Wno-enum-conversion" ] + } + } + + static_library("libdrm") { + sources = [ + "src/xf86drm.c", + "src/xf86drmHash.c", + "src/xf86drmMode.c", + "src/xf86drmRandom.c", + ] + + include_dirs = [ + "src", + "src/include", + ] + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + + public_configs = [ ":libdrm_config" ] + } +} + +if (use_system_libdrm) { + pkg_config("libdrm_config") { + packages = [ "libdrm" ] + } + group("libdrm") { + public_configs = [ ":libdrm_config" ] + } +}
diff --git a/third_party/libdrm/OWNERS b/third_party/libdrm/OWNERS new file mode 100644 index 0000000..3690db3 --- /dev/null +++ b/third_party/libdrm/OWNERS
@@ -0,0 +1,2 @@ +dcastagna@chromium.org +reveman@chromium.org \ No newline at end of file
diff --git a/third_party/libdrm/README.chromium b/third_party/libdrm/README.chromium new file mode 100644 index 0000000..678d4bee --- /dev/null +++ b/third_party/libdrm/README.chromium
@@ -0,0 +1,13 @@ +Name: libdrm +Short Name: libdrm +URL: https://chromium.googlesource.com/chromiumos/third_party/libdrm +Version: 2.4.70 +License: MIT, GPL +License File: NOT_SHIPPED +Security Critical: yes + +Description: +Userspace interface to kernel DRM services. + +Local Modifications: +None
diff --git a/third_party/minigbm/BUILD.gn b/third_party/minigbm/BUILD.gn index d96d51f..f0eb520 100644 --- a/third_party/minigbm/BUILD.gn +++ b/third_party/minigbm/BUILD.gn
@@ -19,10 +19,6 @@ include_dirs = [ "src" ] } - pkg_config("libdrm") { - packages = [ "libdrm" ] - } - shared_library("minigbm") { sources = [ "src/amdgpu.c", @@ -45,11 +41,11 @@ ] configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - ":libdrm", - "//build/config/compiler:no_chromium_code", - ] + configs += [ "//build/config/compiler:no_chromium_code" ] + deps = [ + "//third_party/libdrm", + ] public_configs = [ ":minigbm_config" ] # Clients need this to pick up the shared library correctly.
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp b/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp index d60d73f9..d263a8cc 100644 --- a/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp +++ b/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp
@@ -23,19 +23,20 @@ protected: // Overridden from PluginASTAction: - virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( - CompilerInstance& instance, - llvm::StringRef ref) { + std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance& instance, + llvm::StringRef ref) override { return llvm::make_unique<BlinkGCPluginConsumer>(instance, options_); } - virtual bool ParseArgs(const CompilerInstance&, - const std::vector<std::string>& args) { + bool ParseArgs(const CompilerInstance&, + const std::vector<std::string>& args) override { for (const auto& arg : args) { if (arg == "dump-graph") { options_.dump_graph = true; } else if (arg == "warn-unneeded-finalizer") { options_.warn_unneeded_finalizer = true; + } else if (arg == "use-chromium-style-naming") { + options_.use_chromium_style_naming = true; } else { llvm::errs() << "Unknown blink-gc-plugin argument: " << arg << "\n"; return false;
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp index f33cd39..c3e277a 100644 --- a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp +++ b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp
@@ -75,6 +75,9 @@ // Ignore GC implementation files. options_.ignored_directories.push_back("/heap/"); + + if (!options_.use_chromium_style_naming) + Config::UseLegacyNames(); } void BlinkGCPluginConsumer::HandleTranslationUnit(ASTContext& context) {
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPluginOptions.h b/tools/clang/blink_gc_plugin/BlinkGCPluginOptions.h index b941f08..baaa2ff 100644 --- a/tools/clang/blink_gc_plugin/BlinkGCPluginOptions.h +++ b/tools/clang/blink_gc_plugin/BlinkGCPluginOptions.h
@@ -10,11 +10,10 @@ #include <vector> struct BlinkGCPluginOptions { - BlinkGCPluginOptions() - : dump_graph(false), - warn_unneeded_finalizer(false) {} - bool dump_graph; - bool warn_unneeded_finalizer; + bool dump_graph = false; + bool warn_unneeded_finalizer = false; + // TODO(https://crbug.com/675879): Clean up after the Blink rename. + bool use_chromium_style_naming = false; std::set<std::string> ignored_classes; std::set<std::string> checked_namespaces; std::vector<std::string> ignored_directories;
diff --git a/tools/clang/blink_gc_plugin/CMakeLists.txt b/tools/clang/blink_gc_plugin/CMakeLists.txt index 009807b..66549ed 100644 --- a/tools/clang/blink_gc_plugin/CMakeLists.txt +++ b/tools/clang/blink_gc_plugin/CMakeLists.txt
@@ -30,6 +30,11 @@ endforeach() set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources}) + # TODO(https://crbug.com/675879): Clean up after the Blink rename. + cr_add_test(blink_gc_plugin_legacy_test + python tests/legacy_naming/test.py + ${CMAKE_BINARY_DIR}/bin/clang + ) cr_add_test(blink_gc_plugin_test python tests/test.py ${CMAKE_BINARY_DIR}/bin/clang @@ -40,6 +45,12 @@ cr_install(TARGETS "lib${LIBRARYNAME}" LIBRARY DESTINATION lib) + # TODO(https://crbug.com/675879): Clean up after the Blink rename. + cr_add_test(blink_gc_plugin_legacy_test + python tests/legacy_naming/test.py + ${CMAKE_BINARY_DIR}/bin/clang + $<TARGET_FILE:lib${LIBRARYNAME}> + ) cr_add_test(blink_gc_plugin_test python tests/test.py ${CMAKE_BINARY_DIR}/bin/clang
diff --git a/tools/clang/blink_gc_plugin/Config.cpp b/tools/clang/blink_gc_plugin/Config.cpp index 0a6d5b7..bb32ad44 100644 --- a/tools/clang/blink_gc_plugin/Config.cpp +++ b/tools/clang/blink_gc_plugin/Config.cpp
@@ -10,6 +10,51 @@ using namespace clang; +// Legacy names to be removed after Blink rename: +namespace legacy { +const char kCreateName[] = "create"; +const char kTraceName[] = "trace"; +const char kTraceImplName[] = "traceImpl"; +const char kFinalizeName[] = "finalizeGarbageCollectedObject"; +const char kTraceAfterDispatchName[] = "traceAfterDispatch"; +const char kTraceAfterDispatchImplName[] = "traceAfterDispatchImpl"; +const char kRegisterWeakMembersName[] = "registerWeakMembers"; +const char kAdjustAndMarkName[] = "adjustAndMark"; +const char kIsHeapObjectAliveName[] = "isHeapObjectAlive"; +} // namespace legacy + +const char kNewOperatorName[] = "operator new"; +const char* kCreateName = "Create"; +const char* kTraceName = "Trace"; +const char* kTraceImplName = "TraceImpl"; +const char* kFinalizeName = "FinalizeGarbageCollectedObject"; +const char* kTraceAfterDispatchName = "TraceAfterDispatch"; +const char* kTraceAfterDispatchImplName = "TraceAfterDispatchImpl"; +const char* kRegisterWeakMembersName = "RegisterWeakMembers"; +const char kHeapAllocatorName[] = "HeapAllocator"; +const char kTraceIfNeededName[] = "TraceIfNeeded"; +const char kVisitorDispatcherName[] = "VisitorDispatcher"; +const char kVisitorVarName[] = "visitor"; +const char* kAdjustAndMarkName = "AdjustAndMark"; +const char* kIsHeapObjectAliveName = "IsHeapObjectAlive"; +const char kIsEagerlyFinalizedName[] = "IsEagerlyFinalizedMarker"; +const char kConstIteratorName[] = "const_iterator"; +const char kIteratorName[] = "iterator"; +const char kConstReverseIteratorName[] = "const_reverse_iterator"; +const char kReverseIteratorName[] = "reverse_iterator"; + +void Config::UseLegacyNames() { + kCreateName = legacy::kCreateName; + kTraceName = legacy::kTraceName; + kTraceImplName = legacy::kTraceImplName; + kFinalizeName = legacy::kFinalizeName; + kTraceAfterDispatchName = legacy::kTraceAfterDispatchName; + kTraceAfterDispatchImplName = legacy::kTraceAfterDispatchImplName; + kRegisterWeakMembersName = legacy::kRegisterWeakMembersName; + kAdjustAndMarkName = legacy::kAdjustAndMarkName; + kIsHeapObjectAliveName = legacy::kIsHeapObjectAliveName; +} + bool Config::IsTemplateInstantiation(CXXRecordDecl* record) { ClassTemplateSpecializationDecl* spec = dyn_cast<clang::ClassTemplateSpecializationDecl>(record);
diff --git a/tools/clang/blink_gc_plugin/Config.h b/tools/clang/blink_gc_plugin/Config.h index 7defe2a..2ab933f 100644 --- a/tools/clang/blink_gc_plugin/Config.h +++ b/tools/clang/blink_gc_plugin/Config.h
@@ -17,28 +17,30 @@ #include "clang/AST/AST.h" #include "clang/AST/Attr.h" -const char kNewOperatorName[] = "operator new"; -const char kCreateName[] = "create"; -const char kTraceName[] = "trace"; -const char kTraceImplName[] = "traceImpl"; -const char kFinalizeName[] = "finalizeGarbageCollectedObject"; -const char kTraceAfterDispatchName[] = "traceAfterDispatch"; -const char kTraceAfterDispatchImplName[] = "traceAfterDispatchImpl"; -const char kRegisterWeakMembersName[] = "registerWeakMembers"; -const char kHeapAllocatorName[] = "HeapAllocator"; -const char kTraceIfNeededName[] = "TraceIfNeeded"; -const char kVisitorDispatcherName[] = "VisitorDispatcher"; -const char kVisitorVarName[] = "visitor"; -const char kAdjustAndMarkName[] = "adjustAndMark"; -const char kIsHeapObjectAliveName[] = "isHeapObjectAlive"; -const char kIsEagerlyFinalizedName[] = "IsEagerlyFinalizedMarker"; -const char kConstIteratorName[] = "const_iterator"; -const char kIteratorName[] = "iterator"; -const char kConstReverseIteratorName[] = "const_reverse_iterator"; -const char kReverseIteratorName[] = "reverse_iterator"; +extern const char kNewOperatorName[]; +extern const char* kCreateName; +extern const char* kTraceName; +extern const char* kTraceImplName; +extern const char* kFinalizeName; +extern const char* kTraceAfterDispatchName; +extern const char* kTraceAfterDispatchImplName; +extern const char* kRegisterWeakMembersName; +extern const char kHeapAllocatorName[]; +extern const char kTraceIfNeededName[]; +extern const char kVisitorDispatcherName[]; +extern const char kVisitorVarName[]; +extern const char* kAdjustAndMarkName; +extern const char* kIsHeapObjectAliveName; +extern const char kIsEagerlyFinalizedName[]; +extern const char kConstIteratorName[]; +extern const char kIteratorName[]; +extern const char kConstReverseIteratorName[]; +extern const char kReverseIteratorName[]; class Config { public: + static void UseLegacyNames(); + static bool IsMember(const std::string& name) { return name == "Member"; }
diff --git a/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.cpp index cd38ec9..66219f1 100644 --- a/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.cpp +++ b/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.cpp
@@ -6,13 +6,13 @@ namespace blink { -void PartDerived::trace(Visitor* visitor) +void PartDerived::Trace(Visitor* visitor) { } -void HeapDerived::trace(Visitor* visitor) +void HeapDerived::Trace(Visitor* visitor) { - visitor->trace(m_part); + visitor->Trace(m_part); }
diff --git a/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.h index fbd26d73..a276bd5 100644 --- a/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.h +++ b/tools/clang/blink_gc_plugin/tests/base_class_must_define_virtual_trace.h
@@ -11,23 +11,23 @@ class PartBase { DISALLOW_NEW(); - // Missing virtual trace. + // Missing virtual Trace. }; class PartDerived : public PartBase { DISALLOW_NEW(); public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class HeapBase : public GarbageCollected<HeapBase> { - // Missing virtual trace. + // Missing virtual Trace. }; class HeapDerived : public HeapBase { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: PartDerived m_part; };
diff --git a/tools/clang/blink_gc_plugin/tests/base_requires_tracing.cpp b/tools/clang/blink_gc_plugin/tests/base_requires_tracing.cpp index 87559a85..474be518 100644 --- a/tools/clang/blink_gc_plugin/tests/base_requires_tracing.cpp +++ b/tools/clang/blink_gc_plugin/tests/base_requires_tracing.cpp
@@ -6,16 +6,16 @@ namespace blink { -void A::trace(Visitor* visitor) { } +void A::Trace(Visitor* visitor) { } -void C::trace(Visitor* visitor) { - visitor->trace(m_a); +void C::Trace(Visitor* visitor) { + visitor->Trace(m_a); // Missing B::trace(visitor) } -void D::trace(Visitor* visitor) { - visitor->trace(m_a); - C::trace(visitor); +void D::Trace(Visitor* visitor) { + visitor->Trace(m_a); + C::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/base_requires_tracing.h b/tools/clang/blink_gc_plugin/tests/base_requires_tracing.h index 0205a08..c10d07f5 100644 --- a/tools/clang/blink_gc_plugin/tests/base_requires_tracing.h +++ b/tools/clang/blink_gc_plugin/tests/base_requires_tracing.h
@@ -11,23 +11,23 @@ class A : public GarbageCollected<A> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class B : public A { - // Does not need trace + // Does not need Trace }; class C : public B { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<A> m_a; }; class D : public C { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<A> m_a; };
diff --git a/tools/clang/blink_gc_plugin/tests/base_requires_tracing.txt b/tools/clang/blink_gc_plugin/tests/base_requires_tracing.txt index ee525b9d..581f0daf 100644 --- a/tools/clang/blink_gc_plugin/tests/base_requires_tracing.txt +++ b/tools/clang/blink_gc_plugin/tests/base_requires_tracing.txt
@@ -1,4 +1,4 @@ base_requires_tracing.cpp:11:1: warning: [blink-gc] Base class 'B' of derived class 'C' requires tracing. -void C::trace(Visitor* visitor) { +void C::Trace(Visitor* visitor) { ^ 1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.cpp b/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.cpp index 9c51eca..364099d 100644 --- a/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.cpp
@@ -6,7 +6,7 @@ namespace blink { -void DoesNotNeedFinalizer::trace(Visitor* visitor) +void DoesNotNeedFinalizer::Trace(Visitor* visitor) { } @@ -14,7 +14,7 @@ { } -void DoesNotNeedFinalizer2::trace(Visitor* visitor) +void DoesNotNeedFinalizer2::Trace(Visitor* visitor) { }
diff --git a/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.h b/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.h index c6530f30..7ef11029 100644 --- a/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.h +++ b/tools/clang/blink_gc_plugin/tests/class_does_not_require_finalization.h
@@ -12,20 +12,20 @@ class DoesNeedFinalizer : public GarbageCollectedFinalized<DoesNeedFinalizer> { public: ~DoesNeedFinalizer() { ; } - void trace(Visitor*); + void Trace(Visitor*); }; class DoesNotNeedFinalizer : public GarbageCollectedFinalized<DoesNotNeedFinalizer> { public: - void trace(Visitor*); + void Trace(Visitor*); }; class DoesNotNeedFinalizer2 : public GarbageCollectedFinalized<DoesNotNeedFinalizer2> { public: ~DoesNotNeedFinalizer2(); - void trace(Visitor*); + void Trace(Visitor*); }; class HasEmptyDtor { @@ -39,7 +39,7 @@ : public GarbageCollectedFinalized<DoesNeedFinalizer2>, public HasEmptyDtor { public: - void trace(Visitor*); + void Trace(Visitor*); }; }
diff --git a/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.cpp b/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.cpp index 5bb87c9..cd3903af 100644 --- a/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.cpp
@@ -6,17 +6,17 @@ namespace blink { -void Base::trace(Visitor* visitor) { } +void Base::Trace(Visitor* visitor) { } -void Mixin1::trace(Visitor* visitor) { } +void Mixin1::Trace(Visitor* visitor) { } -void Mixin2::trace(Visitor* visitor) { } +void Mixin2::Trace(Visitor* visitor) { } -// Missing: void Derived1::trace(Visitor* visitor); +// Missing: void Derived1::Trace(Visitor* visitor); -void Derived2::trace(Visitor* visitor) { - Base::trace(visitor); - Mixin1::trace(visitor); +void Derived2::Trace(Visitor* visitor) { + Base::Trace(visitor); + Mixin1::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.h b/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.h index 133f006..6c3a0aa 100644 --- a/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.h +++ b/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.h
@@ -11,27 +11,27 @@ class Base : public GarbageCollected<Base> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class Mixin1 : public GarbageCollectedMixin { public: - void trace(Visitor*); + void Trace(Visitor*); }; class Mixin2 : public GarbageCollectedMixin { public: - void trace(Visitor*); + void Trace(Visitor*); }; class Derived1 : public Base, public Mixin1 { USING_GARBAGE_COLLECTED_MIXIN(Derived1); - // Requires trace method. + // Requires Trace method. }; class Derived2 : public Base, public Mixin1, public Mixin2 { USING_GARBAGE_COLLECTED_MIXIN(Derived2); - void trace(Visitor*) override; + void Trace(Visitor*) override; }; }
diff --git a/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.txt b/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.txt index 33ae5f5..658af72 100644 --- a/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.txt +++ b/tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.txt
@@ -9,6 +9,6 @@ class Derived1 : public Base, public Mixin1 { ^ class_multiple_trace_bases.cpp:17:1: warning: [blink-gc] Base class 'Mixin2' of derived class 'Derived2' requires tracing. -void Derived2::trace(Visitor* visitor) { +void Derived2::Trace(Visitor* visitor) { ^ 2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/class_overrides_new.h b/tools/clang/blink_gc_plugin/tests/class_overrides_new.h index 3e80e37..0135d48 100644 --- a/tools/clang/blink_gc_plugin/tests/class_overrides_new.h +++ b/tools/clang/blink_gc_plugin/tests/class_overrides_new.h
@@ -12,7 +12,7 @@ class HeapObject : public GarbageCollected<HeapObject> { WTF_MAKE_FAST_ALLOCATED; public: - void trace(Visitor*) { } + void Trace(Visitor*) { } }; }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.cpp b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.cpp index 8d47634..6eeb01e 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.cpp
@@ -6,14 +6,14 @@ namespace blink { -void NeedsFinalizer::trace(Visitor* visitor) +void NeedsFinalizer::Trace(Visitor* visitor) { - A::trace(visitor); + A::Trace(visitor); } -void DoesNotNeedFinalizer::trace(Visitor* visitor) +void DoesNotNeedFinalizer::Trace(Visitor* visitor) { - A::trace(visitor); + A::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.h b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.h index 239c2cf1..13a74dd 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.h +++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_base.h
@@ -11,7 +11,7 @@ class A : public GarbageCollected<A> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; class B { @@ -22,13 +22,13 @@ // Second base class needs finalization. class NeedsFinalizer : public A, public B { public: - void trace(Visitor*); + void Trace(Visitor*); }; // Base does not need finalization. class DoesNotNeedFinalizer : public A { public: - void trace(Visitor*); + void Trace(Visitor*); }; }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.cpp b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.cpp index eb23ab03..7b8ac0a 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.cpp
@@ -6,29 +6,29 @@ namespace blink { -void NeedsFinalizer::trace(Visitor* visitor) +void NeedsFinalizer::Trace(Visitor* visitor) { - visitor->trace(m_as); - A::trace(visitor); + visitor->Trace(m_as); + A::Trace(visitor); } -void AlsoNeedsFinalizer::trace(Visitor* visitor) +void AlsoNeedsFinalizer::Trace(Visitor* visitor) { - visitor->trace(m_bs); - A::trace(visitor); + visitor->Trace(m_bs); + A::Trace(visitor); } -void DoesNotNeedFinalizer::trace(Visitor* visitor) +void DoesNotNeedFinalizer::Trace(Visitor* visitor) { - visitor->trace(m_bs); - A::trace(visitor); + visitor->Trace(m_bs); + A::Trace(visitor); } -void AlsoDoesNotNeedFinalizer::trace(Visitor* visitor) +void AlsoDoesNotNeedFinalizer::Trace(Visitor* visitor) { - visitor->trace(m_as); - visitor->trace(m_cs); - A::trace(visitor); + visitor->Trace(m_as); + visitor->Trace(m_cs); + A::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h index 9596127..a585f3f 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h +++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_field.h
@@ -11,20 +11,20 @@ class A : public GarbageCollected<A> { public: - virtual void trace(Visitor*) { } + virtual void Trace(Visitor*) { } }; // Has a non-trivial dtor (user-declared). class B { public: ~B() { } - void trace(Visitor*) { }; + void Trace(Visitor*) { }; }; // Has a trivial dtor. class C { public: - void trace(Visitor*) { }; + void Trace(Visitor*) { }; }; } // blink namespace @@ -43,7 +43,7 @@ // Off-heap vectors always need to be finalized. class NeedsFinalizer : public A { public: - void trace(Visitor*); + void Trace(Visitor*); private: Vector<Member<A> > m_as; }; @@ -52,7 +52,7 @@ // need to be finalized. class AlsoNeedsFinalizer : public A { public: - void trace(Visitor*); + void Trace(Visitor*); private: HeapVector<B, 10> m_bs; }; @@ -60,7 +60,7 @@ // On-heap vectors with no inlined objects never need to be finalized. class DoesNotNeedFinalizer : public A { public: - void trace(Visitor*); + void Trace(Visitor*); private: HeapVector<B> m_bs; }; @@ -69,7 +69,7 @@ // don't need to be finalized. class AlsoDoesNotNeedFinalizer : public A { public: - void trace(Visitor*); + void Trace(Visitor*); private: HeapVector<Member<A>, 10> m_as; HeapVector<C, 10> m_cs;
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.cpp b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.cpp index 782810e..0ebca9a8 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.cpp
@@ -6,32 +6,32 @@ namespace blink { -void MixinFinalizable::trace(Visitor* visitor) +void MixinFinalizable::Trace(Visitor* visitor) { - visitor->trace(m_onHeap); + visitor->Trace(m_onHeap); } -void MixinNotFinalizable::trace(Visitor* visitor) +void MixinNotFinalizable::Trace(Visitor* visitor) { - visitor->trace(m_onHeap); + visitor->Trace(m_onHeap); } -void NeedsFinalizer::trace(Visitor* visitor) +void NeedsFinalizer::Trace(Visitor* visitor) { - visitor->trace(m_obj); - MixinFinalizable::trace(visitor); + visitor->Trace(m_obj); + MixinFinalizable::Trace(visitor); } -void HasFinalizer::trace(Visitor* visitor) +void HasFinalizer::Trace(Visitor* visitor) { - visitor->trace(m_obj); - MixinFinalizable::trace(visitor); + visitor->Trace(m_obj); + MixinFinalizable::Trace(visitor); } -void NeedsNoFinalization::trace(Visitor* visitor) +void NeedsNoFinalization::Trace(Visitor* visitor) { - visitor->trace(m_obj); - MixinNotFinalizable::trace(visitor); + visitor->Trace(m_obj); + MixinNotFinalizable::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.h b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.h index 10befbd..6dd49b7 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.h +++ b/tools/clang/blink_gc_plugin/tests/class_requires_finalization_mixin.h
@@ -14,7 +14,7 @@ class MixinFinalizable : public GarbageCollectedMixin { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: RefPtr<OffHeap> m_offHeap; // Requires finalization Member<OnHeap> m_onHeap; @@ -22,7 +22,7 @@ class MixinNotFinalizable : public GarbageCollectedMixin { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<OnHeap> m_onHeap; }; @@ -32,7 +32,7 @@ , public MixinFinalizable { USING_GARBAGE_COLLECTED_MIXIN(NeedsFinalizer); public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<OnHeap> m_obj; }; @@ -41,7 +41,7 @@ public MixinFinalizable { USING_GARBAGE_COLLECTED_MIXIN(HasFinalizer); public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<OnHeap> m_obj; }; @@ -51,7 +51,7 @@ , public MixinNotFinalizable { USING_GARBAGE_COLLECTED_MIXIN(NeedsNoFinalization); public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<OnHeap> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.cpp b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.cpp index f18fdf6d..e17dae01 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.cpp
@@ -6,14 +6,14 @@ namespace blink { -void Mixin2::trace(Visitor* visitor) +void Mixin2::Trace(Visitor* visitor) { - Mixin::trace(visitor); + Mixin::Trace(visitor); } -void Mixin3::trace(Visitor* visitor) +void Mixin3::Trace(Visitor* visitor) { - Mixin::trace(visitor); + Mixin::Trace(visitor); } } // namespace blink
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.h b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.h index 4a442b72..5c8985e 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.h +++ b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method.h
@@ -24,7 +24,7 @@ class Mixin : public GarbageCollectedMixin { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; Member<Mixin> m_self; }; @@ -34,7 +34,7 @@ class Mixin2 : public Mixin { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; }; class HeapObjectMixin2 @@ -44,14 +44,14 @@ class Mixin3 : public Mixin { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; }; class HeapObjectMixin3 : public GarbageCollected<HeapObjectMixin3>, public Mixin { USING_GARBAGE_COLLECTED_MIXIN(HeapObjectMixin2); public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; }; }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.cpp b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.cpp index 7051fb2..7c9405a 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.cpp +++ b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.cpp
@@ -6,10 +6,10 @@ namespace blink { -// Does not need a trace method. +// Does not need a Trace method. class NoTrace : public TemplatedObject<PartObjectA> { }; -// Needs a trace method. +// Needs a Trace method. class NeedsTrace : public TemplatedObject<PartObjectB> { }; }
diff --git a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.h b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.h index 70cab61..82011e1 100644 --- a/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.h +++ b/tools/clang/blink_gc_plugin/tests/class_requires_trace_method_tmpl.h
@@ -18,7 +18,7 @@ class PartObjectB { DISALLOW_NEW(); public: - void trace(Visitor* visitor) { visitor->trace(m_obj); } + void Trace(Visitor* visitor) { visitor->Trace(m_obj); } private: Member<HeapObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/crash_on_invalid.h b/tools/clang/blink_gc_plugin/tests/crash_on_invalid.h index a77d097..c6ce1ee 100644 --- a/tools/clang/blink_gc_plugin/tests/crash_on_invalid.h +++ b/tools/clang/blink_gc_plugin/tests/crash_on_invalid.h
@@ -18,7 +18,7 @@ public ScriptWrappable { public: virtual const WrapperTypeInfo *wrapperTypeInfo() const {} - void trace(Visitor *); + void Trace(Visitor *); }; }
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_ptrs.cpp b/tools/clang/blink_gc_plugin/tests/cycle_ptrs.cpp index f3b39892..631f7c4 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_ptrs.cpp +++ b/tools/clang/blink_gc_plugin/tests/cycle_ptrs.cpp
@@ -6,12 +6,12 @@ namespace blink { -void A::trace(Visitor* visitor) { - visitor->trace(m_b); +void A::Trace(Visitor* visitor) { + visitor->Trace(m_b); } -void B::trace(Visitor* visitor) { - visitor->trace(m_a); +void B::Trace(Visitor* visitor) { + visitor->Trace(m_a); } }
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_ptrs.h b/tools/clang/blink_gc_plugin/tests/cycle_ptrs.h index 8c07a06..cb404ef 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_ptrs.h +++ b/tools/clang/blink_gc_plugin/tests/cycle_ptrs.h
@@ -21,14 +21,14 @@ class A : public GarbageCollected<A> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: Member<B> m_b; }; class B : public GarbageCollectedFinalized<B> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: Member<A> m_a; RefPtr<C> m_c;
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_sub.cpp b/tools/clang/blink_gc_plugin/tests/cycle_sub.cpp index dfe835a..fde6188b 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_sub.cpp +++ b/tools/clang/blink_gc_plugin/tests/cycle_sub.cpp
@@ -6,9 +6,9 @@ namespace blink { -void B::trace(Visitor* visitor) { - visitor->trace(m_c); - A::trace(visitor); +void B::Trace(Visitor* visitor) { + visitor->Trace(m_c); + A::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_sub.h b/tools/clang/blink_gc_plugin/tests/cycle_sub.h index a007061..e1a011b 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_sub.h +++ b/tools/clang/blink_gc_plugin/tests/cycle_sub.h
@@ -16,12 +16,12 @@ class A : public GarbageCollectedFinalized<A> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; class B : public A { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: RefPtr<C> m_c; };
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_super.cpp b/tools/clang/blink_gc_plugin/tests/cycle_super.cpp index d9ecd79..43394f6 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_super.cpp +++ b/tools/clang/blink_gc_plugin/tests/cycle_super.cpp
@@ -6,16 +6,16 @@ namespace blink { -void A::trace(Visitor* visitor) { - visitor->trace(m_d); +void A::Trace(Visitor* visitor) { + visitor->Trace(m_d); } -void B::trace(Visitor* visitor) { - A::trace(visitor); +void B::Trace(Visitor* visitor) { + A::Trace(visitor); } -void C::trace(Visitor* visitor) { - B::trace(visitor); +void C::Trace(Visitor* visitor) { + B::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_super.h b/tools/clang/blink_gc_plugin/tests/cycle_super.h index 13b05c12..aecb14b 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_super.h +++ b/tools/clang/blink_gc_plugin/tests/cycle_super.h
@@ -16,19 +16,19 @@ class A : public GarbageCollectedFinalized<A> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: RefPtr<D> m_d; }; class B : public A { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class C : public B { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class D : public RefCounted<C> {
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_super_neg.cpp b/tools/clang/blink_gc_plugin/tests/cycle_super_neg.cpp index 33dec59..77ae04c 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_super_neg.cpp +++ b/tools/clang/blink_gc_plugin/tests/cycle_super_neg.cpp
@@ -6,13 +6,13 @@ namespace blink { -void B::trace(Visitor* visitor) { - A::trace(visitor); +void B::Trace(Visitor* visitor) { + A::Trace(visitor); } -void D::trace(Visitor* visitor) { - visitor->trace(m_c); - A::trace(visitor); +void D::Trace(Visitor* visitor) { + visitor->Trace(m_c); + A::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_super_neg.h b/tools/clang/blink_gc_plugin/tests/cycle_super_neg.h index 6f99eff..e80cc63 100644 --- a/tools/clang/blink_gc_plugin/tests/cycle_super_neg.h +++ b/tools/clang/blink_gc_plugin/tests/cycle_super_neg.h
@@ -19,12 +19,12 @@ class A : public GarbageCollectedFinalized<A> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; class B : public A { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class C : public RefCounted<C> { @@ -34,7 +34,7 @@ class D : public A { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: RefPtr<C> m_c; };
diff --git a/tools/clang/blink_gc_plugin/tests/delayed_parsing.cpp b/tools/clang/blink_gc_plugin/tests/delayed_parsing.cpp index 149d95e..ca55043 100644 --- a/tools/clang/blink_gc_plugin/tests/delayed_parsing.cpp +++ b/tools/clang/blink_gc_plugin/tests/delayed_parsing.cpp
@@ -7,14 +7,14 @@ namespace blink { struct HeapObject : public GarbageCollected<HeapObject> { - void trace(Visitor*) { } + void Trace(Visitor*) { } }; template<typename T> class TemplateBase : public GarbageCollected<TemplateBase<T> > { public: - void trace(Visitor* visitor) { visitor->trace(m_obj); } + void Trace(Visitor* visitor) { visitor->Trace(m_obj); } private: Member<HeapObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.cpp b/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.cpp index b6bbfd2..3cc8b94 100644 --- a/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.cpp +++ b/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.cpp
@@ -20,16 +20,16 @@ m_objs[0]; } -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { - visitor->trace(m_obj); - visitor->trace(m_objs); - visitor->trace(m_part); + visitor->Trace(m_obj); + visitor->Trace(m_objs); + visitor->Trace(m_part); } -void PartOther::trace(Visitor* visitor) +void PartOther::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } }
diff --git a/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.h b/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.h index 4c72156..074582fc 100644 --- a/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.h +++ b/tools/clang/blink_gc_plugin/tests/destructor_access_finalized_field.h
@@ -19,7 +19,7 @@ class PartOther { ALLOW_ONLY_INLINE_ALLOCATION(); public: - void trace(Visitor*); + void Trace(Visitor*); HeapObject* obj() { return m_obj; } @@ -30,7 +30,7 @@ class HeapObject : public GarbageCollectedFinalized<HeapObject> { public: ~HeapObject(); - void trace(Visitor*); + void Trace(Visitor*); bool foo() { return true; } void bar(HeapObject*) { } private:
diff --git a/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.cpp b/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.cpp index 07409cc3..8dc672d 100644 --- a/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.cpp +++ b/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.cpp
@@ -12,9 +12,9 @@ m_obj->foo(); } -void HeapObjectEagerFinalized::trace(Visitor* visitor) +void HeapObjectEagerFinalized::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } HeapObjectEagerFinalizedAlso::~HeapObjectEagerFinalizedAlso() @@ -27,11 +27,11 @@ m_heapVector[0]->foo(); } -void HeapObjectEagerFinalizedAlso::trace(Visitor* visitor) +void HeapObjectEagerFinalizedAlso::Trace(Visitor* visitor) { - visitor->trace(m_heapObject); - visitor->trace(m_heapObjectFinalized); - visitor->trace(m_heapVector); + visitor->Trace(m_heapObject); + visitor->Trace(m_heapObjectFinalized); + visitor->Trace(m_heapVector); } } // namespace blink
diff --git a/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.h b/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.h index 77a29de..7a6d1a0 100644 --- a/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.h +++ b/tools/clang/blink_gc_plugin/tests/destructor_eagerly_finalized.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*) { } + void Trace(Visitor*) { } void foo() { } }; @@ -20,7 +20,7 @@ public: EAGERLY_FINALIZED(); ~HeapObjectEagerFinalized(); - void trace(Visitor*); + void Trace(Visitor*); void foo() { } @@ -34,7 +34,7 @@ public: EAGERLY_FINALIZED(); ~HeapObjectEagerFinalizedAlso(); - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_heapObject;
diff --git a/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.cpp b/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.cpp index 8efc41d..b1143d3 100644 --- a/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.cpp
@@ -12,9 +12,9 @@ (void)this; } -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } }
diff --git a/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.h b/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.h index f3fa506a..86180e7b 100644 --- a/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.h +++ b/tools/clang/blink_gc_plugin/tests/destructor_in_nonfinalized_class.h
@@ -12,7 +12,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: ~HeapObject(); - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.cpp b/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.cpp index b831077..15df8814 100644 --- a/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.cpp +++ b/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.cpp
@@ -6,18 +6,18 @@ namespace blink { -void PartObject::trace(Visitor* visitor) { - visitor->trace(m_obj1); - visitor->trace(m_obj2); - visitor->trace(m_obj3); - visitor->trace(m_obj4); +void PartObject::Trace(Visitor* visitor) { + visitor->Trace(m_obj1); + visitor->Trace(m_obj2); + visitor->Trace(m_obj3); + visitor->Trace(m_obj4); } -void HeapObject::trace(Visitor* visitor) { - visitor->trace(m_obj1); - visitor->trace(m_obj2); - visitor->trace(m_obj3); - visitor->trace(m_obj4); +void HeapObject::Trace(Visitor* visitor) { + visitor->Trace(m_obj1); + visitor->Trace(m_obj2); + visitor->Trace(m_obj3); + visitor->Trace(m_obj4); } }
diff --git a/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.h b/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.h index f4d91dd2..294629e 100644 --- a/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.h +++ b/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.h
@@ -19,7 +19,7 @@ operator T*() const { return 0; } T* operator->() { return 0; } - void trace(Visitor* visitor) + void Trace(Visitor* visitor) { } }; @@ -32,7 +32,7 @@ class PartObject { DISALLOW_NEW(); public: - void trace(Visitor*); + void Trace(Visitor*); private: OwnPtr<HeapObject> m_obj1; RefPtr<HeapObject> m_obj2; @@ -45,7 +45,7 @@ class HeapObject : public GarbageCollectedFinalized<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: PartObject m_part; OwnPtr<HeapObject> m_obj1;
diff --git a/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.txt b/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.txt index 61dc6a2..5486505 100644 --- a/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.txt +++ b/tools/clang/blink_gc_plugin/tests/fields_illegal_tracing.txt
@@ -39,7 +39,7 @@ HeapLinkedHashSet<Member<HeapObject>>::const_iterator m_iterator6; ^ fields_illegal_tracing.cpp:9:1: warning: [blink-gc] Class 'PartObject' has untraced or not traceable fields. -void PartObject::trace(Visitor* visitor) { +void PartObject::Trace(Visitor* visitor) { ^ ./fields_illegal_tracing.h:37:5: note: [blink-gc] Untraceable field 'm_obj1' declared here: OwnPtr<HeapObject> m_obj1; @@ -51,7 +51,7 @@ std::unique_ptr<HeapObject> m_obj4; ^ fields_illegal_tracing.cpp:16:1: warning: [blink-gc] Class 'HeapObject' has untraced or not traceable fields. -void HeapObject::trace(Visitor* visitor) { +void HeapObject::Trace(Visitor* visitor) { ^ ./fields_illegal_tracing.h:51:5: note: [blink-gc] Untraceable field 'm_obj1' declared here: OwnPtr<HeapObject> m_obj1;
diff --git a/tools/clang/blink_gc_plugin/tests/fields_require_tracing.cpp b/tools/clang/blink_gc_plugin/tests/fields_require_tracing.cpp index 880ce1e..5028768 100644 --- a/tools/clang/blink_gc_plugin/tests/fields_require_tracing.cpp +++ b/tools/clang/blink_gc_plugin/tests/fields_require_tracing.cpp
@@ -6,21 +6,21 @@ namespace blink { -void PartObject::trace(Visitor* visitor) { - m_obj1->trace(visitor); // Don't allow direct tracing. - visitor->trace(m_obj2); - // Missing visitor->trace(m_obj3); - visitor->trace(m_parts); +void PartObject::Trace(Visitor* visitor) { + m_obj1->Trace(visitor); // Don't allow direct tracing. + visitor->Trace(m_obj2); + // Missing visitor->Trace(m_obj3); + visitor->Trace(m_parts); } -void PartBObject::trace(Visitor* visitor) { - // Missing visitor->trace(m_set); - visitor->trace(m_vector); +void PartBObject::Trace(Visitor* visitor) { + // Missing visitor->Trace(m_set); + visitor->Trace(m_vector); } -void HeapObject::trace(Visitor* visitor) { - // Missing visitor->trace(m_part); - visitor->trace(m_obj); +void HeapObject::Trace(Visitor* visitor) { + // Missing visitor->Trace(m_part); + visitor->Trace(m_obj); } }
diff --git a/tools/clang/blink_gc_plugin/tests/fields_require_tracing.h b/tools/clang/blink_gc_plugin/tests/fields_require_tracing.h index 1819411..c8159a9 100644 --- a/tools/clang/blink_gc_plugin/tests/fields_require_tracing.h +++ b/tools/clang/blink_gc_plugin/tests/fields_require_tracing.h
@@ -15,7 +15,7 @@ class PartBObject { DISALLOW_NEW(); public: - void trace(Visitor*); + void Trace(Visitor*); private: HeapHashSet<PartBObject> m_set; HeapVector<PartBObject> m_vector; @@ -24,7 +24,7 @@ class PartObject { DISALLOW_NEW(); public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj1; Member<HeapObject> m_obj2; @@ -35,7 +35,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: PartObject m_part; Member<HeapObject> m_obj;
diff --git a/tools/clang/blink_gc_plugin/tests/fields_require_tracing.txt b/tools/clang/blink_gc_plugin/tests/fields_require_tracing.txt index 39d49f3..75ca60c5 100644 --- a/tools/clang/blink_gc_plugin/tests/fields_require_tracing.txt +++ b/tools/clang/blink_gc_plugin/tests/fields_require_tracing.txt
@@ -1,5 +1,5 @@ fields_require_tracing.cpp:9:1: warning: [blink-gc] Class 'PartObject' has untraced fields that require tracing. -void PartObject::trace(Visitor* visitor) { +void PartObject::Trace(Visitor* visitor) { ^ ./fields_require_tracing.h:29:5: note: [blink-gc] Untraced field 'm_obj1' declared here: Member<HeapObject> m_obj1; @@ -8,13 +8,13 @@ Member<HeapObject> m_obj3; ^ fields_require_tracing.cpp:16:1: warning: [blink-gc] Class 'PartBObject' has untraced fields that require tracing. -void PartBObject::trace(Visitor* visitor) { +void PartBObject::Trace(Visitor* visitor) { ^ ./fields_require_tracing.h:20:5: note: [blink-gc] Untraced field 'm_set' declared here: HeapHashSet<PartBObject> m_set; ^ fields_require_tracing.cpp:21:1: warning: [blink-gc] Class 'HeapObject' has untraced fields that require tracing. -void HeapObject::trace(Visitor* visitor) { +void HeapObject::Trace(Visitor* visitor) { ^ ./fields_require_tracing.h:40:5: note: [blink-gc] Untraced field 'm_part' declared here: PartObject m_part;
diff --git a/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.cpp b/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.cpp index 91244d1..14166a78 100644 --- a/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.cpp +++ b/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.cpp
@@ -8,26 +8,26 @@ static B* toB(A* a) { return static_cast<B*>(a); } -void A::trace(Visitor* visitor) +void A::Trace(Visitor* visitor) { switch (m_type) { case TB: - toB(this)->traceAfterDispatch(visitor); + toB(this)->TraceAfterDispatch(visitor); break; case TC: - static_cast<C*>(this)->traceAfterDispatch(visitor); + static_cast<C*>(this)->TraceAfterDispatch(visitor); break; case TD: - static_cast<D*>(this)->traceAfterDispatch(visitor); + static_cast<D*>(this)->TraceAfterDispatch(visitor); break; } } -void A::traceAfterDispatch(Visitor* visitor) +void A::TraceAfterDispatch(Visitor* visitor) { } -void A::finalizeGarbageCollectedObject() +void A::FinalizeGarbageCollectedObject() { switch (m_type) { case TB: @@ -42,22 +42,22 @@ } } -void B::traceAfterDispatch(Visitor* visitor) +void B::TraceAfterDispatch(Visitor* visitor) { - visitor->trace(m_a); - A::traceAfterDispatch(visitor); + visitor->Trace(m_a); + A::TraceAfterDispatch(visitor); } -void C::traceAfterDispatch(Visitor* visitor) +void C::TraceAfterDispatch(Visitor* visitor) { - visitor->trace(m_a); - A::traceAfterDispatch(visitor); + visitor->Trace(m_a); + A::TraceAfterDispatch(visitor); } -void D::traceAfterDispatch(Visitor* visitor) +void D::TraceAfterDispatch(Visitor* visitor) { - visitor->trace(m_a); - Abstract::traceAfterDispatch(visitor); + visitor->Trace(m_a); + Abstract::TraceAfterDispatch(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.h b/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.h index acd16ec..485e5cf 100644 --- a/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.h +++ b/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.h
@@ -11,30 +11,30 @@ class NeedsFinalize : public GarbageCollectedFinalized<NeedsFinalize> { public: - void trace(Visitor*); - void traceAfterDispatch(Visitor*); - // Needs a finalizeGarbageCollectedObject method. + void Trace(Visitor*); + void TraceAfterDispatch(Visitor*); + // Needs a FinalizeGarbageCollectedObject method. }; class NeedsDispatch : public GarbageCollectedFinalized<NeedsDispatch> { public: - void trace(Visitor*); - // Needs a traceAfterDispatch method. - void finalizeGarbageCollectedObject() { }; + void Trace(Visitor*); + // Needs a TraceAfterDispatch method. + void FinalizeGarbageCollectedObject() { }; }; class NeedsFinalizedBase : public GarbageCollected<NeedsFinalizedBase> { public: - void trace(Visitor*) { }; - void traceAfterDispatch(Visitor*) { }; - void finalizeGarbageCollectedObject() { }; + void Trace(Visitor*) { }; + void TraceAfterDispatch(Visitor*) { }; + void FinalizeGarbageCollectedObject() { }; }; class A : GarbageCollectedFinalized<A> { public: - void trace(Visitor*); - void traceAfterDispatch(Visitor*); - void finalizeGarbageCollectedObject(); + void Trace(Visitor*); + void TraceAfterDispatch(Visitor*); + void FinalizeGarbageCollectedObject(); protected: enum Type { TB, TC, TD }; A(Type type) : m_type(type) { } @@ -46,7 +46,7 @@ public: B() : A(TB) { } ~B() { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); private: Member<A> m_a; }; @@ -54,7 +54,7 @@ class C : public A { public: C() : A(TC) { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); private: Member<A> m_a; }; @@ -68,7 +68,7 @@ class D : public Abstract { public: D() : Abstract(TD) { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); private: Member<A> m_a; };
diff --git a/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.txt b/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.txt index 8a652a4..0a4122b 100644 --- a/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.txt +++ b/tools/clang/blink_gc_plugin/tests/finalize_after_dispatch.txt
@@ -9,9 +9,9 @@ class NeedsFinalizedBase : public GarbageCollected<NeedsFinalizedBase> { ^ ./finalize_after_dispatch.h:30:5: note: [blink-gc] User-declared finalizer declared here: - void finalizeGarbageCollectedObject() { }; + void FinalizeGarbageCollectedObject() { }; ^ finalize_after_dispatch.cpp:30:1: warning: [blink-gc] Missing dispatch to class 'D' in manual finalize dispatch. -void A::finalizeGarbageCollectedObject() +void A::FinalizeGarbageCollectedObject() ^ 4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.cpp b/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.cpp index e8f42f2..683461e 100644 --- a/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.cpp +++ b/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.cpp
@@ -6,15 +6,15 @@ namespace blink { -void Mixin::trace(Visitor* visitor) +void Mixin::Trace(Visitor* visitor) { - // Missing: visitor->trace(m_self); + // Missing: visitor->Trace(m_self); } -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { - visitor->trace(m_mix); - // Missing: Mixin::trace(visitor); + visitor->Trace(m_mix); + // Missing: Mixin::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.h b/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.h index 3c6f8686..3136f31 100644 --- a/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.h +++ b/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.h
@@ -11,7 +11,7 @@ class Mixin : public GarbageCollectedMixin { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<Mixin> m_self; }; @@ -19,7 +19,7 @@ class HeapObject : public GarbageCollected<HeapObject>, public Mixin { USING_GARBAGE_COLLECTED_MIXIN(HeapObject); public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<Mixin> m_mix; };
diff --git a/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.txt b/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.txt index 4051a6a0..a14074f8 100644 --- a/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.txt +++ b/tools/clang/blink_gc_plugin/tests/garbage_collected_mixin.txt
@@ -1,10 +1,10 @@ garbage_collected_mixin.cpp:9:1: warning: [blink-gc] Class 'Mixin' has untraced fields that require tracing. -void Mixin::trace(Visitor* visitor) +void Mixin::Trace(Visitor* visitor) ^ ./garbage_collected_mixin.h:16:5: note: [blink-gc] Untraced field 'm_self' declared here: Member<Mixin> m_self; ^ garbage_collected_mixin.cpp:14:1: warning: [blink-gc] Base class 'Mixin' of derived class 'HeapObject' requires tracing. -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) ^ 2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/heap/stubs.h b/tools/clang/blink_gc_plugin/tests/heap/stubs.h index f8fde06..b674048 100644 --- a/tools/clang/blink_gc_plugin/tests/heap/stubs.h +++ b/tools/clang/blink_gc_plugin/tests/heap/stubs.h
@@ -190,8 +190,8 @@ #define USING_GARBAGE_COLLECTED_MIXIN(type) \ public: \ - virtual void adjustAndMark(Visitor*) const override { } \ - virtual bool isHeapObjectAlive(Visitor*) const override { return 0; } + virtual void AdjustAndMark(Visitor*) const override { } \ + virtual bool IsHeapObjectAlive(Visitor*) const override { return 0; } #define EAGERLY_FINALIZED() typedef int IsEagerlyFinalizedMarker @@ -280,13 +280,13 @@ class VisitorHelper { public: template<typename T> - void trace(const T&); + void Trace(const T&); }; class Visitor : public VisitorHelper<Visitor> { public: template<typename T, void (T::*method)(Visitor*)> - void registerWeakMembers(const T* obj); + void RegisterWeakMembers(const T* obj); }; class InlinedGlobalMarkingVisitor @@ -295,19 +295,19 @@ InlinedGlobalMarkingVisitor* operator->() { return this; } template<typename T, void (T::*method)(Visitor*)> - void registerWeakMembers(const T* obj); + void RegisterWeakMembers(const T* obj); }; class GarbageCollectedMixin { public: - virtual void adjustAndMark(Visitor*) const = 0; - virtual bool isHeapObjectAlive(Visitor*) const = 0; - virtual void trace(Visitor*) { } + virtual void AdjustAndMark(Visitor*) const = 0; + virtual bool IsHeapObjectAlive(Visitor*) const = 0; + virtual void Trace(Visitor*) { } }; template<typename T> struct TraceIfNeeded { - static void trace(Visitor*, T*); + static void Trace(Visitor*, T*); }; }
diff --git a/tools/clang/blink_gc_plugin/tests/ignore_class.cpp b/tools/clang/blink_gc_plugin/tests/ignore_class.cpp index c539eb6..26b0ab1b 100644 --- a/tools/clang/blink_gc_plugin/tests/ignore_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/ignore_class.cpp
@@ -6,14 +6,14 @@ namespace blink { -void B::trace(Visitor* visitor) +void B::Trace(Visitor* visitor) { // Class is ignored so no checking here. } -void C::trace(Visitor* visitor) +void C::Trace(Visitor* visitor) { - // Missing trace of m_obj. + // Missing Trace of m_obj. // Ignored base class B does not need tracing. }
diff --git a/tools/clang/blink_gc_plugin/tests/ignore_class.h b/tools/clang/blink_gc_plugin/tests/ignore_class.h index 580ed7c..8bda898 100644 --- a/tools/clang/blink_gc_plugin/tests/ignore_class.h +++ b/tools/clang/blink_gc_plugin/tests/ignore_class.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { }; -// Don't require trace method on ignored class. +// Don't require Trace method on ignored class. class GC_PLUGIN_IGNORE("http://crbug.com/12345") A; class A : public GarbageCollected<A> { private: @@ -22,7 +22,7 @@ class GC_PLUGIN_IGNORE("http://crbug.com/12345") B; class B : public GarbageCollected<B> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: Member<HeapObject> m_obj; }; @@ -30,7 +30,7 @@ // Don't require tracing of an ignored base class. class C : public B { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/ignore_class.txt b/tools/clang/blink_gc_plugin/tests/ignore_class.txt index d3d2d80..212f332 100644 --- a/tools/clang/blink_gc_plugin/tests/ignore_class.txt +++ b/tools/clang/blink_gc_plugin/tests/ignore_class.txt
@@ -1,5 +1,5 @@ ignore_class.cpp:14:1: warning: [blink-gc] Class 'C' has untraced fields that require tracing. -void C::trace(Visitor* visitor) +void C::Trace(Visitor* visitor) ^ ./ignore_class.h:35:5: note: [blink-gc] Untraced field 'm_obj' declared here: Member<HeapObject> m_obj;
diff --git a/tools/clang/blink_gc_plugin/tests/ignore_fields.cpp b/tools/clang/blink_gc_plugin/tests/ignore_fields.cpp index 118af754..80ffd4e 100644 --- a/tools/clang/blink_gc_plugin/tests/ignore_fields.cpp +++ b/tools/clang/blink_gc_plugin/tests/ignore_fields.cpp
@@ -6,9 +6,9 @@ namespace blink { -void C::trace(Visitor* visitor) +void C::Trace(Visitor* visitor) { - // Missing trace of m_one. + // Missing Trace of m_one. // Not missing ignored field m_two. }
diff --git a/tools/clang/blink_gc_plugin/tests/ignore_fields.h b/tools/clang/blink_gc_plugin/tests/ignore_fields.h index e12bbab..b0f773f6 100644 --- a/tools/clang/blink_gc_plugin/tests/ignore_fields.h +++ b/tools/clang/blink_gc_plugin/tests/ignore_fields.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - virtual void trace(Visitor*) { } + virtual void Trace(Visitor*) { } }; // Don't warn about raw pointers to heap allocated objects. @@ -21,7 +21,7 @@ HeapObject* m_obj; }; -// Don't require trace method when (all) GC fields are ignored. +// Don't require Trace method when (all) GC fields are ignored. class B : public GarbageCollected<B> { private: GC_PLUGIN_IGNORE("http://crbug.com/12345") @@ -31,7 +31,7 @@ // Don't require tracing an ignored field. class C : public GarbageCollected<C> { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_one; GC_PLUGIN_IGNORE("http://crbug.com/12345")
diff --git a/tools/clang/blink_gc_plugin/tests/ignore_fields.txt b/tools/clang/blink_gc_plugin/tests/ignore_fields.txt index b4de4981..a1b2591d 100644 --- a/tools/clang/blink_gc_plugin/tests/ignore_fields.txt +++ b/tools/clang/blink_gc_plugin/tests/ignore_fields.txt
@@ -1,5 +1,5 @@ ignore_fields.cpp:9:1: warning: [blink-gc] Class 'C' has untraced fields that require tracing. -void C::trace(Visitor* visitor) +void C::Trace(Visitor* visitor) ^ ./ignore_fields.h:36:5: note: [blink-gc] Untraced field 'm_one' declared here: Member<HeapObject> m_one;
diff --git a/tools/clang/blink_gc_plugin/tests/inner_class.cpp b/tools/clang/blink_gc_plugin/tests/inner_class.cpp index 03a53ea..cb74d8bb 100644 --- a/tools/clang/blink_gc_plugin/tests/inner_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/inner_class.cpp
@@ -6,9 +6,9 @@ namespace blink { -void SomeObject::InnerObject::trace(Visitor* visitor) +void SomeObject::InnerObject::Trace(Visitor* visitor) { - // Missing: visitor->trace(m_obj); + // Missing: visitor->Trace(m_obj); } }
diff --git a/tools/clang/blink_gc_plugin/tests/inner_class.h b/tools/clang/blink_gc_plugin/tests/inner_class.h index 30f6ce3..5010a2c2 100644 --- a/tools/clang/blink_gc_plugin/tests/inner_class.h +++ b/tools/clang/blink_gc_plugin/tests/inner_class.h
@@ -13,7 +13,7 @@ private: class InnerObject : public GarbageCollected<InnerObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<InnerObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/inner_class.txt b/tools/clang/blink_gc_plugin/tests/inner_class.txt index acdef6e..9e57527 100644 --- a/tools/clang/blink_gc_plugin/tests/inner_class.txt +++ b/tools/clang/blink_gc_plugin/tests/inner_class.txt
@@ -1,5 +1,5 @@ inner_class.cpp:9:1: warning: [blink-gc] Class 'InnerObject' has untraced fields that require tracing. -void SomeObject::InnerObject::trace(Visitor* visitor) +void SomeObject::InnerObject::Trace(Visitor* visitor) ^ ./inner_class.h:18:9: note: [blink-gc] Untraced field 'm_obj' declared here: Member<InnerObject> m_obj;
diff --git a/tools/clang/blink_gc_plugin/tests/left_most_gc_base.h b/tools/clang/blink_gc_plugin/tests/left_most_gc_base.h index 0d76d61..96d01d3 100644 --- a/tools/clang/blink_gc_plugin/tests/left_most_gc_base.h +++ b/tools/clang/blink_gc_plugin/tests/left_most_gc_base.h
@@ -20,7 +20,7 @@ class C : public GarbageCollected<C> { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); }; class IllFormed : public A, public C { }; // Error
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/.gitignore b/tools/clang/blink_gc_plugin/tests/legacy_naming/.gitignore new file mode 100644 index 0000000..cc5bb740 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/.gitignore
@@ -0,0 +1 @@ +/*.o
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.cpp new file mode 100644 index 0000000..cd38ec9 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.cpp
@@ -0,0 +1,19 @@ +// Copyright 2014 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. + +#include "base_class_must_define_virtual_trace.h" + +namespace blink { + +void PartDerived::trace(Visitor* visitor) +{ +} + +void HeapDerived::trace(Visitor* visitor) +{ + visitor->trace(m_part); +} + + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.h new file mode 100644 index 0000000..fbd26d73 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.h
@@ -0,0 +1,38 @@ +// Copyright 2014 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. + +#ifndef BASE_CLASS_MUST_DEFINE_VIRTUAL_TRACE_H_ +#define BASE_CLASS_MUST_DEFINE_VIRTUAL_TRACE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class PartBase { + DISALLOW_NEW(); + // Missing virtual trace. +}; + +class PartDerived : public PartBase { + DISALLOW_NEW(); +public: + virtual void trace(Visitor*); +}; + +class HeapBase : public GarbageCollected<HeapBase> { + // Missing virtual trace. +}; + + +class HeapDerived : public HeapBase { +public: + virtual void trace(Visitor*); +private: + PartDerived m_part; +}; + + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.txt new file mode 100644 index 0000000..f8276eb2 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_class_must_define_virtual_trace.txt
@@ -0,0 +1,8 @@ +In file included from base_class_must_define_virtual_trace.cpp:5: +./base_class_must_define_virtual_trace.h:12:1: warning: [blink-gc] Left-most base class 'PartBase' of derived class 'PartDerived' must define a virtual trace method. +class PartBase { +^ +./base_class_must_define_virtual_trace.h:23:1: warning: [blink-gc] Left-most base class 'HeapBase' of derived class 'HeapDerived' must define a virtual trace method. +class HeapBase : public GarbageCollected<HeapBase> { +^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.cpp new file mode 100644 index 0000000..87559a85 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.cpp
@@ -0,0 +1,21 @@ +// Copyright 2014 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. + +#include "base_requires_tracing.h" + +namespace blink { + +void A::trace(Visitor* visitor) { } + +void C::trace(Visitor* visitor) { + visitor->trace(m_a); + // Missing B::trace(visitor) +} + +void D::trace(Visitor* visitor) { + visitor->trace(m_a); + C::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.h new file mode 100644 index 0000000..0205a08 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.h
@@ -0,0 +1,37 @@ +// Copyright 2014 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. + +#ifndef BASE_REQUIRES_TRACING_H_ +#define BASE_REQUIRES_TRACING_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + virtual void trace(Visitor*); +}; + +class B : public A { + // Does not need trace +}; + +class C : public B { +public: + void trace(Visitor*); +private: + Member<A> m_a; +}; + +class D : public C { +public: + void trace(Visitor*); +private: + Member<A> m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.txt new file mode 100644 index 0000000..ee525b9d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/base_requires_tracing.txt
@@ -0,0 +1,4 @@ +base_requires_tracing.cpp:11:1: warning: [blink-gc] Base class 'B' of derived class 'C' requires tracing. +void C::trace(Visitor* visitor) { +^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.cpp new file mode 100644 index 0000000..9c51eca --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.cpp
@@ -0,0 +1,22 @@ +// Copyright 2014 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. + +#include "class_does_not_require_finalization.h" + +namespace blink { + +void DoesNotNeedFinalizer::trace(Visitor* visitor) +{ +} + +DoesNotNeedFinalizer2::~DoesNotNeedFinalizer2() +{ +} + +void DoesNotNeedFinalizer2::trace(Visitor* visitor) +{ +} + + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.flags new file mode 100644 index 0000000..b0bf138 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.flags
@@ -0,0 +1 @@ +-Xclang -plugin-arg-blink-gc-plugin -Xclang warn-unneeded-finalizer \ No newline at end of file
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.h new file mode 100644 index 0000000..c6530f30 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.h
@@ -0,0 +1,47 @@ +// Copyright 2014 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. + +#ifndef CLASS_DOES_NOT_REQUIRE_FINALIZATION_BASE_H_ +#define CLASS_DOES_NOT_REQUIRE_FINALIZATION_BASE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class DoesNeedFinalizer : public GarbageCollectedFinalized<DoesNeedFinalizer> { +public: + ~DoesNeedFinalizer() { ; } + void trace(Visitor*); +}; + +class DoesNotNeedFinalizer + : public GarbageCollectedFinalized<DoesNotNeedFinalizer> { +public: + void trace(Visitor*); +}; + +class DoesNotNeedFinalizer2 + : public GarbageCollectedFinalized<DoesNotNeedFinalizer2> { +public: + ~DoesNotNeedFinalizer2(); + void trace(Visitor*); +}; + +class HasEmptyDtor { +public: + virtual ~HasEmptyDtor() { } +}; + +// If there are any virtual destructors involved, give up. + +class DoesNeedFinalizer2 + : public GarbageCollectedFinalized<DoesNeedFinalizer2>, + public HasEmptyDtor { +public: + void trace(Visitor*); +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.txt new file mode 100644 index 0000000..91e264d6 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_does_not_require_finalization.txt
@@ -0,0 +1,8 @@ +In file included from class_does_not_require_finalization.cpp:5: +./class_does_not_require_finalization.h:18:1: warning: [blink-gc] Class 'DoesNotNeedFinalizer' may not require finalization. +class DoesNotNeedFinalizer +^ +./class_does_not_require_finalization.h:24:1: warning: [blink-gc] Class 'DoesNotNeedFinalizer2' may not require finalization. +class DoesNotNeedFinalizer2 +^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.cpp new file mode 100644 index 0000000..5bb87c9 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.cpp
@@ -0,0 +1,22 @@ +// Copyright 2014 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. + +#include "class_multiple_trace_bases.h" + +namespace blink { + +void Base::trace(Visitor* visitor) { } + +void Mixin1::trace(Visitor* visitor) { } + +void Mixin2::trace(Visitor* visitor) { } + +// Missing: void Derived1::trace(Visitor* visitor); + +void Derived2::trace(Visitor* visitor) { + Base::trace(visitor); + Mixin1::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.h new file mode 100644 index 0000000..133f006 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.h
@@ -0,0 +1,39 @@ +// Copyright 2014 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. + +#ifndef CLASS_MULTIPLE_TRACE_BASES_H_ +#define CLASS_MULTIPLE_TRACE_BASES_H_ + +#include "heap/stubs.h" + +namespace blink { + +class Base : public GarbageCollected<Base> { +public: + virtual void trace(Visitor*); +}; + +class Mixin1 : public GarbageCollectedMixin { +public: + void trace(Visitor*); +}; + +class Mixin2 : public GarbageCollectedMixin { +public: + void trace(Visitor*); +}; + +class Derived1 : public Base, public Mixin1 { + USING_GARBAGE_COLLECTED_MIXIN(Derived1); + // Requires trace method. +}; + +class Derived2 : public Base, public Mixin1, public Mixin2 { + USING_GARBAGE_COLLECTED_MIXIN(Derived2); + void trace(Visitor*) override; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.txt new file mode 100644 index 0000000..33ae5f5 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_multiple_trace_bases.txt
@@ -0,0 +1,14 @@ +In file included from class_multiple_trace_bases.cpp:5: +./class_multiple_trace_bases.h:27:1: warning: [blink-gc] Class 'Derived1' requires a trace method. +class Derived1 : public Base, public Mixin1 { +^ +./class_multiple_trace_bases.h:27:18: note: [blink-gc] Untraced base class 'Base' declared here: +class Derived1 : public Base, public Mixin1 { + ^ +./class_multiple_trace_bases.h:27:31: note: [blink-gc] Untraced base class 'Mixin1' declared here: +class Derived1 : public Base, public Mixin1 { + ^ +class_multiple_trace_bases.cpp:17:1: warning: [blink-gc] Base class 'Mixin2' of derived class 'Derived2' requires tracing. +void Derived2::trace(Visitor* visitor) { +^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.cpp new file mode 100644 index 0000000..9f47f82a --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.cpp
@@ -0,0 +1,7 @@ +// Copyright 2014 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. + +#include "class_overrides_new.h" + +// Nothing to define.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.h new file mode 100644 index 0000000..3e80e37 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.h
@@ -0,0 +1,20 @@ +// Copyright 2014 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. + +#ifndef CLASS_OVERRIDES_NEW_H_ +#define CLASS_OVERRIDES_NEW_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { + WTF_MAKE_FAST_ALLOCATED; +public: + void trace(Visitor*) { } +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.txt new file mode 100644 index 0000000..17f50fe --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_overrides_new.txt
@@ -0,0 +1,8 @@ +In file included from class_overrides_new.cpp:5: +./class_overrides_new.h:13:5: warning: [blink-gc] Garbage collected class 'HeapObject' is not permitted to override its new operator. + WTF_MAKE_FAST_ALLOCATED; + ^ +./heap/stubs.h:14:5: note: expanded from macro 'WTF_MAKE_FAST_ALLOCATED' + void* operator new(size_t size); \ + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.cpp new file mode 100644 index 0000000..8d47634 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.cpp
@@ -0,0 +1,19 @@ +// Copyright 2014 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. + +#include "class_requires_finalization_base.h" + +namespace blink { + +void NeedsFinalizer::trace(Visitor* visitor) +{ + A::trace(visitor); +} + +void DoesNotNeedFinalizer::trace(Visitor* visitor) +{ + A::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.h new file mode 100644 index 0000000..239c2cf1 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.h
@@ -0,0 +1,36 @@ +// Copyright 2014 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. + +#ifndef CLASS_REQUIRES_FINALIZATION_BASE_H_ +#define CLASS_REQUIRES_FINALIZATION_BASE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + virtual void trace(Visitor*) {} +}; + +class B { +public: + ~B() { /* user-declared, thus, non-trivial */ } +}; + +// Second base class needs finalization. +class NeedsFinalizer : public A, public B { +public: + void trace(Visitor*); +}; + +// Base does not need finalization. +class DoesNotNeedFinalizer : public A { +public: + void trace(Visitor*); +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.txt new file mode 100644 index 0000000..935883d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_base.txt
@@ -0,0 +1,8 @@ +In file included from class_requires_finalization_base.cpp:5: +./class_requires_finalization_base.h:23:1: warning: [blink-gc] Class 'NeedsFinalizer' requires finalization. +class NeedsFinalizer : public A, public B { +^ +./class_requires_finalization_base.h:23:34: note: [blink-gc] Base class 'B' requiring finalization declared here: +class NeedsFinalizer : public A, public B { + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.cpp new file mode 100644 index 0000000..eb23ab03 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.cpp
@@ -0,0 +1,34 @@ +// Copyright 2014 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. + +#include "class_requires_finalization_field.h" + +namespace blink { + +void NeedsFinalizer::trace(Visitor* visitor) +{ + visitor->trace(m_as); + A::trace(visitor); +} + +void AlsoNeedsFinalizer::trace(Visitor* visitor) +{ + visitor->trace(m_bs); + A::trace(visitor); +} + +void DoesNotNeedFinalizer::trace(Visitor* visitor) +{ + visitor->trace(m_bs); + A::trace(visitor); +} + +void AlsoDoesNotNeedFinalizer::trace(Visitor* visitor) +{ + visitor->trace(m_as); + visitor->trace(m_cs); + A::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.h new file mode 100644 index 0000000..9596127 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.h
@@ -0,0 +1,80 @@ +// Copyright 2014 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. + +#ifndef CLASS_REQUIRES_FINALIZATION_H_ +#define CLASS_REQUIRES_FINALIZATION_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + virtual void trace(Visitor*) { } +}; + +// Has a non-trivial dtor (user-declared). +class B { +public: + ~B() { } + void trace(Visitor*) { }; +}; + +// Has a trivial dtor. +class C { +public: + void trace(Visitor*) { }; +}; + +} // blink namespace + +namespace WTF { + +template<> +struct VectorTraits<blink::C> { + static const bool needsDestruction = false; +}; + +} // WTF namespace + +namespace blink { + +// Off-heap vectors always need to be finalized. +class NeedsFinalizer : public A { +public: + void trace(Visitor*); +private: + Vector<Member<A> > m_as; +}; + +// On-heap vectors with inlined objects that need destruction +// need to be finalized. +class AlsoNeedsFinalizer : public A { +public: + void trace(Visitor*); +private: + HeapVector<B, 10> m_bs; +}; + +// On-heap vectors with no inlined objects never need to be finalized. +class DoesNotNeedFinalizer : public A { +public: + void trace(Visitor*); +private: + HeapVector<B> m_bs; +}; + +// On-heap vectors with inlined objects that don't need destruction +// don't need to be finalized. +class AlsoDoesNotNeedFinalizer : public A { +public: + void trace(Visitor*); +private: + HeapVector<Member<A>, 10> m_as; + HeapVector<C, 10> m_cs; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.txt new file mode 100644 index 0000000..9e37c46 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_field.txt
@@ -0,0 +1,14 @@ +In file included from class_requires_finalization_field.cpp:5: +./class_requires_finalization_field.h:44:1: warning: [blink-gc] Class 'NeedsFinalizer' requires finalization. +class NeedsFinalizer : public A { +^ +./class_requires_finalization_field.h:48:5: note: [blink-gc] Field 'm_as' requiring finalization declared here: + Vector<Member<A> > m_as; + ^ +./class_requires_finalization_field.h:53:1: warning: [blink-gc] Class 'AlsoNeedsFinalizer' requires finalization. +class AlsoNeedsFinalizer : public A { +^ +./class_requires_finalization_field.h:57:5: note: [blink-gc] Field 'm_bs' requiring finalization declared here: + HeapVector<B, 10> m_bs; + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.cpp new file mode 100644 index 0000000..782810e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.cpp
@@ -0,0 +1,37 @@ +// Copyright 2014 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. + +#include "class_requires_finalization_mixin.h" + +namespace blink { + +void MixinFinalizable::trace(Visitor* visitor) +{ + visitor->trace(m_onHeap); +} + +void MixinNotFinalizable::trace(Visitor* visitor) +{ + visitor->trace(m_onHeap); +} + +void NeedsFinalizer::trace(Visitor* visitor) +{ + visitor->trace(m_obj); + MixinFinalizable::trace(visitor); +} + +void HasFinalizer::trace(Visitor* visitor) +{ + visitor->trace(m_obj); + MixinFinalizable::trace(visitor); +} + +void NeedsNoFinalization::trace(Visitor* visitor) +{ + visitor->trace(m_obj); + MixinNotFinalizable::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.h new file mode 100644 index 0000000..10befbd --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.h
@@ -0,0 +1,61 @@ +// Copyright 2014 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. + +#ifndef CLASS_REQUIRES_FINALIZATION_MIXIN_H_ +#define CLASS_REQUIRES_FINALIZATION_MIXIN_H_ + +#include "heap/stubs.h" + +namespace blink { + +class OffHeap : public RefCounted<OffHeap> { }; +class OnHeap : public GarbageCollected<OnHeap> { }; + +class MixinFinalizable : public GarbageCollectedMixin { +public: + virtual void trace(Visitor*) override; +private: + RefPtr<OffHeap> m_offHeap; // Requires finalization + Member<OnHeap> m_onHeap; +}; + +class MixinNotFinalizable : public GarbageCollectedMixin { +public: + virtual void trace(Visitor*) override; +private: + Member<OnHeap> m_onHeap; +}; + +class NeedsFinalizer + : public GarbageCollected<NeedsFinalizer> + , public MixinFinalizable { + USING_GARBAGE_COLLECTED_MIXIN(NeedsFinalizer); +public: + virtual void trace(Visitor*) override; +private: + Member<OnHeap> m_obj; +}; + +class HasFinalizer : public GarbageCollectedFinalized<HasFinalizer>, + public MixinFinalizable { + USING_GARBAGE_COLLECTED_MIXIN(HasFinalizer); +public: + virtual void trace(Visitor*) override; +private: + Member<OnHeap> m_obj; +}; + +class NeedsNoFinalization + : public GarbageCollected<NeedsNoFinalization> + , public MixinNotFinalizable { + USING_GARBAGE_COLLECTED_MIXIN(NeedsNoFinalization); +public: + virtual void trace(Visitor*) override; +private: + Member<OnHeap> m_obj; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.txt new file mode 100644 index 0000000..0bf93d5 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_finalization_mixin.txt
@@ -0,0 +1,8 @@ +In file included from class_requires_finalization_mixin.cpp:5: +./class_requires_finalization_mixin.h:30:1: warning: [blink-gc] Class 'NeedsFinalizer' requires finalization. +class NeedsFinalizer +^ +./class_requires_finalization_mixin.h:32:7: note: [blink-gc] Base class 'MixinFinalizable' requiring finalization declared here: + , public MixinFinalizable { + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.cpp new file mode 100644 index 0000000..f18fdf6d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.cpp
@@ -0,0 +1,19 @@ +// Copyright 2014 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. + +#include "class_requires_trace_method.h" + +namespace blink { + +void Mixin2::trace(Visitor* visitor) +{ + Mixin::trace(visitor); +} + +void Mixin3::trace(Visitor* visitor) +{ + Mixin::trace(visitor); +} + +} // namespace blink
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.h new file mode 100644 index 0000000..4a442b72 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.h
@@ -0,0 +1,59 @@ +// Copyright 2014 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. + +#ifndef CLASS_REQUIRES_TRACE_METHOD_H_ +#define CLASS_REQUIRES_TRACE_METHOD_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + Member<HeapObject> m_obj; +}; + +class HeapObject : public GarbageCollected<HeapObject> { +private: + PartObject m_part; +}; + +class Mixin : public GarbageCollectedMixin { +public: + virtual void trace(Visitor*) override; + Member<Mixin> m_self; +}; + +class HeapObjectMixin : public GarbageCollected<HeapObjectMixin>, public Mixin { + USING_GARBAGE_COLLECTED_MIXIN(HeapObjectMixin); +}; + +class Mixin2 : public Mixin { +public: + virtual void trace(Visitor*) override; +}; + +class HeapObjectMixin2 + : public GarbageCollected<HeapObjectMixin2>, public Mixin2 { + USING_GARBAGE_COLLECTED_MIXIN(HeapObjectMixin2); +}; + +class Mixin3 : public Mixin { +public: + virtual void trace(Visitor*) override; +}; + +class HeapObjectMixin3 + : public GarbageCollected<HeapObjectMixin3>, public Mixin { + USING_GARBAGE_COLLECTED_MIXIN(HeapObjectMixin2); +public: + virtual void trace(Visitor*) override; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.txt new file mode 100644 index 0000000..de6fd94 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method.txt
@@ -0,0 +1,14 @@ +In file included from class_requires_trace_method.cpp:5: +./class_requires_trace_method.h:14:1: warning: [blink-gc] Class 'PartObject' requires a trace method. +class PartObject { +^ +./class_requires_trace_method.h:17:5: note: [blink-gc] Untraced field 'm_obj' declared here: + Member<HeapObject> m_obj; + ^ +./class_requires_trace_method.h:20:1: warning: [blink-gc] Class 'HeapObject' requires a trace method. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./class_requires_trace_method.h:22:5: note: [blink-gc] Untraced field 'm_part' declared here: + PartObject m_part; + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.cpp new file mode 100644 index 0000000..7051fb2 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.cpp
@@ -0,0 +1,15 @@ +// Copyright 2014 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. + +#include "class_requires_trace_method_tmpl.h" + +namespace blink { + +// Does not need a trace method. +class NoTrace : public TemplatedObject<PartObjectA> { }; + +// Needs a trace method. +class NeedsTrace : public TemplatedObject<PartObjectB> { }; + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.h new file mode 100644 index 0000000..70cab61 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.h
@@ -0,0 +1,34 @@ +// Copyright 2014 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. + +#ifndef CLASS_REQUIRES_TRACE_METHOD_TMPL_H_ +#define CLASS_REQUIRES_TRACE_METHOD_TMPL_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { }; + +class PartObjectA { + DISALLOW_NEW(); +}; + +class PartObjectB { + DISALLOW_NEW(); +public: + void trace(Visitor* visitor) { visitor->trace(m_obj); } +private: + Member<HeapObject> m_obj; +}; + +template<typename T> +class TemplatedObject { +private: + T m_part; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.txt new file mode 100644 index 0000000..49705b9 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/class_requires_trace_method_tmpl.txt
@@ -0,0 +1,8 @@ +In file included from class_requires_trace_method_tmpl.cpp:5: +./class_requires_trace_method_tmpl.h:27:1: warning: [blink-gc] Class 'TemplatedObject<blink::PartObjectB>' requires a trace method. +class TemplatedObject { +^ +./class_requires_trace_method_tmpl.h:29:5: note: [blink-gc] Untraced field 'm_part' declared here: + T m_part; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.cpp new file mode 100644 index 0000000..6370812e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.cpp
@@ -0,0 +1,7 @@ +// Copyright 2014 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. + +#include "crash_on_invalid.h" + +// Nothing to define.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.h new file mode 100644 index 0000000..a77d097 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.h
@@ -0,0 +1,26 @@ +// Copyright 2014 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. + +// Regression test for http://crbug.com/421958 + +#ifndef CRASH_ON_INVALID_H_ +#define CRASH_ON_INVALID_H_ + +namespace blink { + +class Visitor; +class GamepadCommon {}; +class ScriptWrappable {}; + +class Gamepad final : public GarbageCollectedFinalized<Gamepad>, + public GamepadCommon, + public ScriptWrappable { +public: + virtual const WrapperTypeInfo *wrapperTypeInfo() const {} + void trace(Visitor *); +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.txt new file mode 100644 index 0000000..cf19ff5 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/crash_on_invalid.txt
@@ -0,0 +1,8 @@ +In file included from crash_on_invalid.cpp:5: +./crash_on_invalid.h:16:30: error: unknown template name 'GarbageCollectedFinalized' +class Gamepad final : public GarbageCollectedFinalized<Gamepad>, + ^ +./crash_on_invalid.h:20:19: error: unknown type name 'WrapperTypeInfo' + virtual const WrapperTypeInfo *wrapperTypeInfo() const {} + ^ +2 errors generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.cpp new file mode 100644 index 0000000..f3b39892 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.cpp
@@ -0,0 +1,17 @@ +// Copyright 2014 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. + +#include "cycle_ptrs.h" + +namespace blink { + +void A::trace(Visitor* visitor) { + visitor->trace(m_b); +} + +void B::trace(Visitor* visitor) { + visitor->trace(m_a); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.flags new file mode 100644 index 0000000..a55c2f09 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.flags
@@ -0,0 +1 @@ +-Xclang -plugin-arg-blink-gc-plugin -Xclang dump-graph \ No newline at end of file
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.h new file mode 100644 index 0000000..8c07a06 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.h
@@ -0,0 +1,54 @@ +// Copyright 2014 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. + +#ifndef CYCLE_PTRS_H_ +#define CYCLE_PTRS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class B; +class C; +class D; +class E; + +// This contains a leaking cycle: +// E -per-> A -mem-> B -ref-> C -own-> D -own-vec-> E + +// The traced cycle from A -> B -> A does not leak. + +class A : public GarbageCollected<A> { +public: + virtual void trace(Visitor*); +private: + Member<B> m_b; +}; + +class B : public GarbageCollectedFinalized<B> { +public: + virtual void trace(Visitor*); +private: + Member<A> m_a; + RefPtr<C> m_c; +}; + +class C : public RefCounted<C> { +private: + OwnPtr<D> m_d; +}; + +class D { +private: + Vector<OwnPtr<E> > m_es; +}; + +class E { +private: + Persistent<A> m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.txt new file mode 100644 index 0000000..4d242a6 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_ptrs.txt
@@ -0,0 +1,8 @@ + +Found a potentially leaking cycle starting from a GC root: +./cycle_ptrs.h:49:5: blink::E (m_a) => blink::A +./cycle_ptrs.h:26:5: blink::A (m_b) => blink::B +./cycle_ptrs.h:34:5: blink::B (m_c) => blink::C +./cycle_ptrs.h:39:5: blink::C (m_d) => blink::D +./cycle_ptrs.h:44:5: blink::D (m_es) => blink::E +
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.cpp new file mode 100644 index 0000000..dfe835a --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.cpp
@@ -0,0 +1,14 @@ +// Copyright 2014 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. + +#include "cycle_sub.h" + +namespace blink { + +void B::trace(Visitor* visitor) { + visitor->trace(m_c); + A::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.flags new file mode 100644 index 0000000..a55c2f09 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.flags
@@ -0,0 +1 @@ +-Xclang -plugin-arg-blink-gc-plugin -Xclang dump-graph \ No newline at end of file
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.h new file mode 100644 index 0000000..a007061 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.h
@@ -0,0 +1,36 @@ +// Copyright 2014 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. + +#ifndef CYCLE_SUB_H_ +#define CYCLE_SUB_H_ + +#include "heap/stubs.h" + +namespace blink { + +class C; + +// This contains a leaking cycle: +// C -per-> A -sub-> B -ref-> C + +class A : public GarbageCollectedFinalized<A> { +public: + virtual void trace(Visitor*) {} +}; + +class B : public A { +public: + virtual void trace(Visitor*); +private: + RefPtr<C> m_c; +}; + +class C : public RefCounted<C> { +private: + Persistent<A> m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.txt new file mode 100644 index 0000000..b37907d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_sub.txt
@@ -0,0 +1,6 @@ + +Found a potentially leaking cycle starting from a GC root: +./cycle_sub.h:31:5: blink::C (m_a) => blink::A +./cycle_sub.h:22:11: blink::A (<subclass>) => blink::B +./cycle_sub.h:26:5: blink::B (m_c) => blink::C +
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.cpp new file mode 100644 index 0000000..d9ecd79 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.cpp
@@ -0,0 +1,21 @@ +// Copyright 2014 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. + +#include "cycle_super.h" + +namespace blink { + +void A::trace(Visitor* visitor) { + visitor->trace(m_d); +} + +void B::trace(Visitor* visitor) { + A::trace(visitor); +} + +void C::trace(Visitor* visitor) { + B::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.flags new file mode 100644 index 0000000..a55c2f09 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.flags
@@ -0,0 +1 @@ +-Xclang -plugin-arg-blink-gc-plugin -Xclang dump-graph \ No newline at end of file
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.h new file mode 100644 index 0000000..13b05c12 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.h
@@ -0,0 +1,41 @@ +// Copyright 2014 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. + +#ifndef CYCLE_SUPER_H_ +#define CYCLE_SUPER_H_ + +#include "heap/stubs.h" + +namespace blink { + +class D; + +// This contains a leaking cycle: +// D -per-> C -sup-> B -sup-> A -ref-> D + +class A : public GarbageCollectedFinalized<A> { +public: + virtual void trace(Visitor*); +private: + RefPtr<D> m_d; +}; + +class B : public A { +public: + virtual void trace(Visitor*); +}; + +class C : public B { +public: + virtual void trace(Visitor*); +}; + +class D : public RefCounted<C> { +private: + Persistent<C> m_c; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.txt new file mode 100644 index 0000000..89b3675 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super.txt
@@ -0,0 +1,5 @@ + +Found a potentially leaking cycle starting from a GC root: +./cycle_super.h:36:5: blink::D (m_c) => blink::C +./cycle_super.h:21:5: blink::C (blink::B <: blink::A <: m_d) => blink::D +
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.cpp new file mode 100644 index 0000000..33dec59 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.cpp
@@ -0,0 +1,18 @@ +// Copyright 2014 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. + +#include "cycle_super_neg.h" + +namespace blink { + +void B::trace(Visitor* visitor) { + A::trace(visitor); +} + +void D::trace(Visitor* visitor) { + visitor->trace(m_c); + A::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.flags new file mode 100644 index 0000000..a55c2f09 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.flags
@@ -0,0 +1 @@ +-Xclang -plugin-arg-blink-gc-plugin -Xclang dump-graph \ No newline at end of file
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.h new file mode 100644 index 0000000..6f99eff --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.h
@@ -0,0 +1,44 @@ +// Copyright 2014 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. + +#ifndef CYCLE_SUPER_NEG_H_ +#define CYCLE_SUPER_NEG_H_ + +#include "heap/stubs.h" + +namespace blink { + +class C; + +// The chain: +// C -per-> B -sup-> A -sub-> D -ref-> C +// is not a leaking cycle, because the super-class relationship +// should not transitively imply sub-class relationships. +// I.e. B -/-> D + +class A : public GarbageCollectedFinalized<A> { +public: + virtual void trace(Visitor*) {} +}; + +class B : public A { +public: + virtual void trace(Visitor*); +}; + +class C : public RefCounted<C> { +private: + Persistent<B> m_b; +}; + +class D : public A { +public: + virtual void trace(Visitor*); +private: + RefPtr<C> m_c; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/cycle_super_neg.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.cpp new file mode 100644 index 0000000..149d95e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.cpp
@@ -0,0 +1,25 @@ +// Copyright 2015 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. + +#include "heap/stubs.h" + +namespace blink { + +struct HeapObject : public GarbageCollected<HeapObject> { + void trace(Visitor*) { } +}; + +template<typename T> +class TemplateBase + : public GarbageCollected<TemplateBase<T> > { +public: + void trace(Visitor* visitor) { visitor->trace(m_obj); } +private: + Member<HeapObject> m_obj; +}; + +class Subclass : public TemplateBase<Subclass> { +}; + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.flags new file mode 100644 index 0000000..94af50f --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.flags
@@ -0,0 +1 @@ +-fdelayed-template-parsing
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/delayed_parsing.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.cpp new file mode 100644 index 0000000..b6bbfd2 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.cpp
@@ -0,0 +1,35 @@ +// Copyright 2014 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. + +#include "destructor_access_finalized_field.h" + +namespace blink { + +HeapObject::~HeapObject() +{ + // Valid access to fields. + if (m_ref->foo() && !m_obj) { + m_objs.size(); + m_part.obj(); + } + + // Invalid access to fields. + bar(m_obj); + m_obj->foo(); + m_objs[0]; +} + +void HeapObject::trace(Visitor* visitor) +{ + visitor->trace(m_obj); + visitor->trace(m_objs); + visitor->trace(m_part); +} + +void PartOther::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.h new file mode 100644 index 0000000..4c72156 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.h
@@ -0,0 +1,45 @@ +// Copyright 2014 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. + +#ifndef DESTRUCTOR_ACCESS_FINALIZED_FIELD_H_ +#define DESTRUCTOR_ACCESS_FINALIZED_FIELD_H_ + +#include "heap/stubs.h" + +namespace blink { + +class Other : public RefCounted<Other> { +public: + bool foo() { return true; } +}; + +class HeapObject; + +class PartOther { + ALLOW_ONLY_INLINE_ALLOCATION(); +public: + void trace(Visitor*); + + HeapObject* obj() { return m_obj; } + +private: + Member<HeapObject> m_obj; +}; + +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +public: + ~HeapObject(); + void trace(Visitor*); + bool foo() { return true; } + void bar(HeapObject*) { } +private: + RefPtr<Other> m_ref; + Member<HeapObject> m_obj; + Vector<Member<HeapObject> > m_objs; + PartOther m_part; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.txt new file mode 100644 index 0000000..0470b51 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_access_finalized_field.txt
@@ -0,0 +1,19 @@ +destructor_access_finalized_field.cpp:18:9: warning: [blink-gc] Finalizer '~HeapObject' accesses potentially finalized field 'm_obj'. + bar(m_obj); + ^ +./destructor_access_finalized_field.h:38:5: note: [blink-gc] Potentially finalized field 'm_obj' declared here: + Member<HeapObject> m_obj; + ^ +destructor_access_finalized_field.cpp:19:5: warning: [blink-gc] Finalizer '~HeapObject' accesses potentially finalized field 'm_obj'. + m_obj->foo(); + ^ +./destructor_access_finalized_field.h:38:5: note: [blink-gc] Potentially finalized field 'm_obj' declared here: + Member<HeapObject> m_obj; + ^ +destructor_access_finalized_field.cpp:20:5: warning: [blink-gc] Finalizer '~HeapObject' accesses potentially finalized field 'm_objs'. + m_objs[0]; + ^ +./destructor_access_finalized_field.h:39:5: note: [blink-gc] Potentially finalized field 'm_objs' declared here: + Vector<Member<HeapObject> > m_objs; + ^ +3 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.cpp new file mode 100644 index 0000000..07409cc3 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.cpp
@@ -0,0 +1,37 @@ +// Copyright 2015 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. + +#include "destructor_eagerly_finalized.h" + +namespace blink { + +HeapObjectEagerFinalized::~HeapObjectEagerFinalized() +{ + // Valid access to a non-eagerly finalized field + m_obj->foo(); +} + +void HeapObjectEagerFinalized::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +HeapObjectEagerFinalizedAlso::~HeapObjectEagerFinalizedAlso() +{ + // Valid access to a non-eagerly finalized field + m_heapObject->foo(); + + // Non-valid accesses to eagerly finalized fields. + m_heapObjectFinalized->foo(); + m_heapVector[0]->foo(); +} + +void HeapObjectEagerFinalizedAlso::trace(Visitor* visitor) +{ + visitor->trace(m_heapObject); + visitor->trace(m_heapObjectFinalized); + visitor->trace(m_heapVector); +} + +} // namespace blink
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.h new file mode 100644 index 0000000..77a29de --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.h
@@ -0,0 +1,47 @@ +// Copyright 2015 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. + +#ifndef DESTRUCTOR_EAGERLY_FINALIZED_H_ +#define DESTRUCTOR_EAGERLY_FINALIZED_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*) { } + void foo() { } +}; + +class HeapObjectEagerFinalized + : public GarbageCollectedFinalized<HeapObjectEagerFinalized> { +public: + EAGERLY_FINALIZED(); + ~HeapObjectEagerFinalized(); + void trace(Visitor*); + + void foo() { } + +private: + Member<HeapObject> m_obj; +}; + +// Accessing other eagerly finalized objects during finalization is not allowed. +class HeapObjectEagerFinalizedAlso + : public GarbageCollectedFinalized<HeapObjectEagerFinalizedAlso> { +public: + EAGERLY_FINALIZED(); + ~HeapObjectEagerFinalizedAlso(); + void trace(Visitor*); + +private: + Member<HeapObject> m_heapObject; + Member<HeapObjectEagerFinalized> m_heapObjectFinalized; + HeapVector<Member<HeapObjectEagerFinalized>> m_heapVector; +}; + +} // namespace blink + +#endif // DESTRUCTOR_EAGERLY_FINALIZED_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.txt new file mode 100644 index 0000000..97d5089 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_eagerly_finalized.txt
@@ -0,0 +1,13 @@ +destructor_eagerly_finalized.cpp:26:5: warning: [blink-gc] Finalizer '~HeapObjectEagerFinalizedAlso' accesses eagerly finalized field 'm_heapObjectFinalized'. + m_heapObjectFinalized->foo(); + ^ +./destructor_eagerly_finalized.h:41:5: note: [blink-gc] Field 'm_heapObjectFinalized' having eagerly finalized value, declared here: + Member<HeapObjectEagerFinalized> m_heapObjectFinalized; + ^ +destructor_eagerly_finalized.cpp:27:5: warning: [blink-gc] Finalizer '~HeapObjectEagerFinalizedAlso' accesses eagerly finalized field 'm_heapVector'. + m_heapVector[0]->foo(); + ^ +./destructor_eagerly_finalized.h:42:5: note: [blink-gc] Field 'm_heapVector' having eagerly finalized value, declared here: + HeapVector<Member<HeapObjectEagerFinalized>> m_heapVector; + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.cpp new file mode 100644 index 0000000..8efc41d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.cpp
@@ -0,0 +1,20 @@ +// Copyright 2014 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. + +#include "destructor_in_nonfinalized_class.h" + +namespace blink { + +HeapObject::~HeapObject() +{ + // Do something when destructed... + (void)this; +} + +void HeapObject::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.h new file mode 100644 index 0000000..f3fa506a --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.h
@@ -0,0 +1,22 @@ +// Copyright 2014 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. + +#ifndef DESTRUCTOR_IN_NONFINALIZED_CLASS_H_ +#define DESTRUCTOR_IN_NONFINALIZED_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + ~HeapObject(); + void trace(Visitor*); +private: + Member<HeapObject> m_obj; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.txt new file mode 100644 index 0000000..cf19ea1 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/destructor_in_nonfinalized_class.txt
@@ -0,0 +1,8 @@ +In file included from destructor_in_nonfinalized_class.cpp:5: +./destructor_in_nonfinalized_class.h:12:1: warning: [blink-gc] Class 'HeapObject' requires finalization. +class HeapObject : public GarbageCollected<HeapObject> { +^ +destructor_in_nonfinalized_class.cpp:9:1: note: [blink-gc] User-declared destructor declared here: +HeapObject::~HeapObject() +^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.cpp new file mode 100644 index 0000000..b831077 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.cpp
@@ -0,0 +1,23 @@ +// Copyright 2016 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. + +#include "fields_illegal_tracing.h" + +namespace blink { + +void PartObject::trace(Visitor* visitor) { + visitor->trace(m_obj1); + visitor->trace(m_obj2); + visitor->trace(m_obj3); + visitor->trace(m_obj4); +} + +void HeapObject::trace(Visitor* visitor) { + visitor->trace(m_obj1); + visitor->trace(m_obj2); + visitor->trace(m_obj3); + visitor->trace(m_obj4); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.h new file mode 100644 index 0000000..f4d91dd2 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.h
@@ -0,0 +1,63 @@ +// Copyright 2016 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. + +#ifndef FIELDS_ILLEGAL_TRACING_H_ +#define FIELDS_ILLEGAL_TRACING_H_ + +#include "heap/stubs.h" + +namespace blink { + +namespace bar { + +// check that (only) std::unique_ptr<> is reported +// as an illegal smart pointer type. +template<typename T> class unique_ptr { +public: + ~unique_ptr() { } + operator T*() const { return 0; } + T* operator->() { return 0; } + + void trace(Visitor* visitor) + { + } +}; + +} + +class HeapObject; +class PartObject; + +class PartObject { + DISALLOW_NEW(); +public: + void trace(Visitor*); +private: + OwnPtr<HeapObject> m_obj1; + RefPtr<HeapObject> m_obj2; + bar::unique_ptr<HeapObject> m_obj3; + std::unique_ptr<HeapObject> m_obj4; + Vector<int>::iterator m_iterator1; + HeapVector<Member<HeapObject>>::iterator m_iterator2; + HeapHashSet<PartObject>::const_iterator m_iterator3; +}; + +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +public: + void trace(Visitor*); +private: + PartObject m_part; + OwnPtr<HeapObject> m_obj1; + RefPtr<HeapObject> m_obj2; + bar::unique_ptr<HeapObject> m_obj3; + std::unique_ptr<HeapObject> m_obj4; + HeapHashMap<int, Member<HeapObject>>::reverse_iterator m_iterator3; + HeapDeque<Member<HeapObject>>::const_reverse_iterator m_iterator4; + HeapListHashSet<Member<HeapObject>>::const_iterator m_iterator5; + HeapLinkedHashSet<Member<HeapObject>>::const_iterator m_iterator6; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.txt new file mode 100644 index 0000000..61dc6a2 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_illegal_tracing.txt
@@ -0,0 +1,68 @@ +In file included from fields_illegal_tracing.cpp:5: +./fields_illegal_tracing.h:32:1: warning: [blink-gc] Class 'PartObject' contains invalid fields. +class PartObject { +^ +./fields_illegal_tracing.h:37:5: note: [blink-gc] OwnPtr field 'm_obj1' to a GC managed class declared here: + OwnPtr<HeapObject> m_obj1; + ^ +./fields_illegal_tracing.h:38:5: note: [blink-gc] RefPtr field 'm_obj2' to a GC managed class declared here: + RefPtr<HeapObject> m_obj2; + ^ +./fields_illegal_tracing.h:40:5: note: [blink-gc] std::unique_ptr field 'm_obj4' to a GC managed class declared here: + std::unique_ptr<HeapObject> m_obj4; + ^ +./fields_illegal_tracing.h:42:5: note: [blink-gc] Iterator field 'm_iterator2' to a GC managed collection declared here: + HeapVector<Member<HeapObject>>::iterator m_iterator2; + ^ +./fields_illegal_tracing.h:43:5: note: [blink-gc] Iterator field 'm_iterator3' to a GC managed collection declared here: + HeapHashSet<PartObject>::const_iterator m_iterator3; + ^ +./fields_illegal_tracing.h:46:1: warning: [blink-gc] Class 'HeapObject' contains invalid fields. +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +^ +./fields_illegal_tracing.h:51:5: note: [blink-gc] OwnPtr field 'm_obj1' to a GC managed class declared here: + OwnPtr<HeapObject> m_obj1; + ^ +./fields_illegal_tracing.h:52:5: note: [blink-gc] RefPtr field 'm_obj2' to a GC managed class declared here: + RefPtr<HeapObject> m_obj2; + ^ +./fields_illegal_tracing.h:54:5: note: [blink-gc] std::unique_ptr field 'm_obj4' to a GC managed class declared here: + std::unique_ptr<HeapObject> m_obj4; + ^ +./fields_illegal_tracing.h:55:5: note: [blink-gc] Iterator field 'm_iterator3' to a GC managed collection declared here: + HeapHashMap<int, Member<HeapObject>>::reverse_iterator m_iterator3; + ^ +./fields_illegal_tracing.h:56:5: note: [blink-gc] Iterator field 'm_iterator4' to a GC managed collection declared here: + HeapDeque<Member<HeapObject>>::const_reverse_iterator m_iterator4; + ^ +./fields_illegal_tracing.h:58:5: note: [blink-gc] Iterator field 'm_iterator6' to a GC managed collection declared here: + HeapLinkedHashSet<Member<HeapObject>>::const_iterator m_iterator6; + ^ +fields_illegal_tracing.cpp:9:1: warning: [blink-gc] Class 'PartObject' has untraced or not traceable fields. +void PartObject::trace(Visitor* visitor) { +^ +./fields_illegal_tracing.h:37:5: note: [blink-gc] Untraceable field 'm_obj1' declared here: + OwnPtr<HeapObject> m_obj1; + ^ +./fields_illegal_tracing.h:38:5: note: [blink-gc] Untraceable field 'm_obj2' declared here: + RefPtr<HeapObject> m_obj2; + ^ +./fields_illegal_tracing.h:40:5: note: [blink-gc] Untraceable field 'm_obj4' declared here: + std::unique_ptr<HeapObject> m_obj4; + ^ +fields_illegal_tracing.cpp:16:1: warning: [blink-gc] Class 'HeapObject' has untraced or not traceable fields. +void HeapObject::trace(Visitor* visitor) { +^ +./fields_illegal_tracing.h:51:5: note: [blink-gc] Untraceable field 'm_obj1' declared here: + OwnPtr<HeapObject> m_obj1; + ^ +./fields_illegal_tracing.h:52:5: note: [blink-gc] Untraceable field 'm_obj2' declared here: + RefPtr<HeapObject> m_obj2; + ^ +./fields_illegal_tracing.h:54:5: note: [blink-gc] Untraceable field 'm_obj4' declared here: + std::unique_ptr<HeapObject> m_obj4; + ^ +./fields_illegal_tracing.h:57:5: note: [blink-gc] Untraced field 'm_iterator5' declared here: + HeapListHashSet<Member<HeapObject>>::const_iterator m_iterator5; + ^ +4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.cpp new file mode 100644 index 0000000..880ce1e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.cpp
@@ -0,0 +1,26 @@ +// Copyright 2014 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. + +#include "fields_require_tracing.h" + +namespace blink { + +void PartObject::trace(Visitor* visitor) { + m_obj1->trace(visitor); // Don't allow direct tracing. + visitor->trace(m_obj2); + // Missing visitor->trace(m_obj3); + visitor->trace(m_parts); +} + +void PartBObject::trace(Visitor* visitor) { + // Missing visitor->trace(m_set); + visitor->trace(m_vector); +} + +void HeapObject::trace(Visitor* visitor) { + // Missing visitor->trace(m_part); + visitor->trace(m_obj); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.h new file mode 100644 index 0000000..1819411 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.h
@@ -0,0 +1,46 @@ +// Copyright 2014 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. + +#ifndef FIELDS_REQUIRE_TRACING_H_ +#define FIELDS_REQUIRE_TRACING_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; +class PartObject; + +class PartBObject { + DISALLOW_NEW(); +public: + void trace(Visitor*); +private: + HeapHashSet<PartBObject> m_set; + HeapVector<PartBObject> m_vector; +}; + +class PartObject { + DISALLOW_NEW(); +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj1; + Member<HeapObject> m_obj2; + Member<HeapObject> m_obj3; + + HeapVector<PartBObject> m_parts; +}; + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + PartObject m_part; + Member<HeapObject> m_obj; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.txt new file mode 100644 index 0000000..39d49f3 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/fields_require_tracing.txt
@@ -0,0 +1,22 @@ +fields_require_tracing.cpp:9:1: warning: [blink-gc] Class 'PartObject' has untraced fields that require tracing. +void PartObject::trace(Visitor* visitor) { +^ +./fields_require_tracing.h:29:5: note: [blink-gc] Untraced field 'm_obj1' declared here: + Member<HeapObject> m_obj1; + ^ +./fields_require_tracing.h:31:5: note: [blink-gc] Untraced field 'm_obj3' declared here: + Member<HeapObject> m_obj3; + ^ +fields_require_tracing.cpp:16:1: warning: [blink-gc] Class 'PartBObject' has untraced fields that require tracing. +void PartBObject::trace(Visitor* visitor) { +^ +./fields_require_tracing.h:20:5: note: [blink-gc] Untraced field 'm_set' declared here: + HeapHashSet<PartBObject> m_set; + ^ +fields_require_tracing.cpp:21:1: warning: [blink-gc] Class 'HeapObject' has untraced fields that require tracing. +void HeapObject::trace(Visitor* visitor) { +^ +./fields_require_tracing.h:40:5: note: [blink-gc] Untraced field 'm_part' declared here: + PartObject m_part; + ^ +3 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.cpp new file mode 100644 index 0000000..91244d1 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.cpp
@@ -0,0 +1,63 @@ +// Copyright 2014 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. + +#include "finalize_after_dispatch.h" + +namespace blink { + +static B* toB(A* a) { return static_cast<B*>(a); } + +void A::trace(Visitor* visitor) +{ + switch (m_type) { + case TB: + toB(this)->traceAfterDispatch(visitor); + break; + case TC: + static_cast<C*>(this)->traceAfterDispatch(visitor); + break; + case TD: + static_cast<D*>(this)->traceAfterDispatch(visitor); + break; + } +} + +void A::traceAfterDispatch(Visitor* visitor) +{ +} + +void A::finalizeGarbageCollectedObject() +{ + switch (m_type) { + case TB: + toB(this)->~B(); + break; + case TC: + static_cast<C*>(this)->~C(); + break; + case TD: + // Missing static_cast<D*>(this)->~D(); + break; + } +} + +void B::traceAfterDispatch(Visitor* visitor) +{ + visitor->trace(m_a); + A::traceAfterDispatch(visitor); +} + +void C::traceAfterDispatch(Visitor* visitor) +{ + visitor->trace(m_a); + A::traceAfterDispatch(visitor); +} + +void D::traceAfterDispatch(Visitor* visitor) +{ + visitor->trace(m_a); + Abstract::traceAfterDispatch(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.h new file mode 100644 index 0000000..acd16ec --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.h
@@ -0,0 +1,78 @@ +// Copyright 2014 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. + +#ifndef FINALIZE_AFTER_DISPATCH_H_ +#define FINALIZE_AFTER_DISPATCH_H_ + +#include "heap/stubs.h" + +namespace blink { + +class NeedsFinalize : public GarbageCollectedFinalized<NeedsFinalize> { +public: + void trace(Visitor*); + void traceAfterDispatch(Visitor*); + // Needs a finalizeGarbageCollectedObject method. +}; + +class NeedsDispatch : public GarbageCollectedFinalized<NeedsDispatch> { +public: + void trace(Visitor*); + // Needs a traceAfterDispatch method. + void finalizeGarbageCollectedObject() { }; +}; + +class NeedsFinalizedBase : public GarbageCollected<NeedsFinalizedBase> { +public: + void trace(Visitor*) { }; + void traceAfterDispatch(Visitor*) { }; + void finalizeGarbageCollectedObject() { }; +}; + +class A : GarbageCollectedFinalized<A> { +public: + void trace(Visitor*); + void traceAfterDispatch(Visitor*); + void finalizeGarbageCollectedObject(); +protected: + enum Type { TB, TC, TD }; + A(Type type) : m_type(type) { } +private: + Type m_type; +}; + +class B : public A { +public: + B() : A(TB) { } + ~B() { } + void traceAfterDispatch(Visitor*); +private: + Member<A> m_a; +}; + +class C : public A { +public: + C() : A(TC) { } + void traceAfterDispatch(Visitor*); +private: + Member<A> m_a; +}; + +// This class is considered abstract does not need to be dispatched to. +class Abstract : public A { +protected: + Abstract(Type type) : A(type) { } +}; + +class D : public Abstract { +public: + D() : Abstract(TD) { } + void traceAfterDispatch(Visitor*); +private: + Member<A> m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.txt new file mode 100644 index 0000000..8a652a4 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/finalize_after_dispatch.txt
@@ -0,0 +1,17 @@ +In file included from finalize_after_dispatch.cpp:5: +./finalize_after_dispatch.h:12:1: warning: [blink-gc] Class 'NeedsFinalize' is missing manual finalize dispatch. +class NeedsFinalize : public GarbageCollectedFinalized<NeedsFinalize> { +^ +./finalize_after_dispatch.h:19:1: warning: [blink-gc] Class 'NeedsDispatch' is missing manual trace dispatch. +class NeedsDispatch : public GarbageCollectedFinalized<NeedsDispatch> { +^ +./finalize_after_dispatch.h:26:1: warning: [blink-gc] Class 'NeedsFinalizedBase' requires finalization. +class NeedsFinalizedBase : public GarbageCollected<NeedsFinalizedBase> { +^ +./finalize_after_dispatch.h:30:5: note: [blink-gc] User-declared finalizer declared here: + void finalizeGarbageCollectedObject() { }; + ^ +finalize_after_dispatch.cpp:30:1: warning: [blink-gc] Missing dispatch to class 'D' in manual finalize dispatch. +void A::finalizeGarbageCollectedObject() +^ +4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.cpp new file mode 100644 index 0000000..e8f42f2 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.cpp
@@ -0,0 +1,20 @@ +// Copyright 2014 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. + +#include "garbage_collected_mixin.h" + +namespace blink { + +void Mixin::trace(Visitor* visitor) +{ + // Missing: visitor->trace(m_self); +} + +void HeapObject::trace(Visitor* visitor) +{ + visitor->trace(m_mix); + // Missing: Mixin::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.h new file mode 100644 index 0000000..3c6f8686 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.h
@@ -0,0 +1,29 @@ +// Copyright 2014 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. + +#ifndef GARBAGE_COLLECTED_MIXIN_H_ +#define GARBAGE_COLLECTED_MIXIN_H_ + +#include "heap/stubs.h" + +namespace blink { + +class Mixin : public GarbageCollectedMixin { +public: + virtual void trace(Visitor*) override; +private: + Member<Mixin> m_self; +}; + +class HeapObject : public GarbageCollected<HeapObject>, public Mixin { + USING_GARBAGE_COLLECTED_MIXIN(HeapObject); +public: + virtual void trace(Visitor*) override; +private: + Member<Mixin> m_mix; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.txt new file mode 100644 index 0000000..4051a6a0 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/garbage_collected_mixin.txt
@@ -0,0 +1,10 @@ +garbage_collected_mixin.cpp:9:1: warning: [blink-gc] Class 'Mixin' has untraced fields that require tracing. +void Mixin::trace(Visitor* visitor) +^ +./garbage_collected_mixin.h:16:5: note: [blink-gc] Untraced field 'm_self' declared here: + Member<Mixin> m_self; + ^ +garbage_collected_mixin.cpp:14:1: warning: [blink-gc] Base class 'Mixin' of derived class 'HeapObject' requires tracing. +void HeapObject::trace(Visitor* visitor) +^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/heap/stubs.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/heap/stubs.h new file mode 100644 index 0000000..f8fde06 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/heap/stubs.h
@@ -0,0 +1,324 @@ +// Copyright 2014 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. + +#ifndef HEAP_STUBS_H_ +#define HEAP_STUBS_H_ + +#include "stddef.h" + +#define WTF_MAKE_FAST_ALLOCATED \ + public: \ + void* operator new(size_t, void* p); \ + void* operator new[](size_t, void* p); \ + void* operator new(size_t size); \ + private: \ + typedef int __thisIsHereToForceASemicolonAfterThisMacro + +namespace WTF { + +template<typename T> class RefCounted { }; + +template<typename T> class RawPtr { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } +}; + +template<typename T> class RefPtr { +public: + ~RefPtr() { } + operator T*() const { return 0; } + T* operator->() { return 0; } +}; + +template<typename T> class OwnPtr { +public: + ~OwnPtr() { } + operator T*() const { return 0; } + T* operator->() { return 0; } +}; + +class DefaultAllocator { +public: + static const bool isGarbageCollected = false; +}; + +template<typename T> +struct VectorTraits { + static const bool needsDestruction = true; +}; + +template<size_t inlineCapacity, bool isGarbageCollected, bool tNeedsDestruction> +class VectorDestructorBase { +public: + ~VectorDestructorBase() {} +}; + +template<size_t inlineCapacity> +class VectorDestructorBase<inlineCapacity, true, false> {}; + +template<> +class VectorDestructorBase<0, true, true> {}; + +template< + typename T, + size_t inlineCapacity = 0, + typename Allocator = DefaultAllocator> +class Vector : public VectorDestructorBase<inlineCapacity, + Allocator::isGarbageCollected, + VectorTraits<T>::needsDestruction> { + public: + using iterator = T*; + using const_iterator = const T*; + using reverse_iterator = T*; + using const_reverse_iterator = const T*; + + size_t size(); + T& operator[](size_t); +}; + +template <typename T, + size_t inlineCapacity = 0, + typename Allocator = DefaultAllocator> +class Deque { + public: + using iterator = T*; + using const_iterator = const T*; + using reverse_iterator = T*; + using const_reverse_iterator = const T*; +}; + +template <typename ValueArg, + typename HashArg = void, + typename TraitsArg = void, + typename Allocator = DefaultAllocator> +class HashSet { + public: + typedef ValueArg* iterator; + typedef const ValueArg* const_iterator; + typedef ValueArg* reverse_iterator; + typedef const ValueArg* const_reverse_iterator; +}; + +template <typename ValueArg, + typename HashArg = void, + typename TraitsArg = void, + typename Allocator = DefaultAllocator> +class ListHashSet { + public: + typedef ValueArg* iterator; + typedef const ValueArg* const_iterator; + typedef ValueArg* reverse_iterator; + typedef const ValueArg* const_reverse_iterator; +}; + +template <typename ValueArg, + typename HashArg = void, + typename TraitsArg = void, + typename Allocator = DefaultAllocator> +class LinkedHashSet { + public: + typedef ValueArg* iterator; + typedef const ValueArg* const_iterator; + typedef ValueArg* reverse_iterator; + typedef const ValueArg* const_reverse_iterator; +}; + +template< + typename ValueArg, + typename HashArg = void, + typename TraitsArg = void, + typename Allocator = DefaultAllocator> +class HashCountedSet {}; + +template <typename KeyArg, + typename MappedArg, + typename HashArg = void, + typename KeyTraitsArg = void, + typename MappedTraitsArg = void, + typename Allocator = DefaultAllocator> +class HashMap { + public: + typedef MappedArg* iterator; + typedef const MappedArg* const_iterator; + typedef MappedArg* reverse_iterator; + typedef const MappedArg* const_reverse_iterator; +}; +} + +// Empty namespace declaration to exercise internal +// handling of namespace equality. +namespace std { + /* empty */ +} + +namespace std { + +template<typename T> class unique_ptr { +public: + ~unique_ptr() { } + operator T*() const { return 0; } + T* operator->() { return 0; } +}; + +} + +namespace blink { + +using namespace WTF; + +#define DISALLOW_NEW() \ + private: \ + void* operator new(size_t) = delete; \ + void* operator new(size_t, void*) = delete; + +#define STACK_ALLOCATED() \ + private: \ + __attribute__((annotate("blink_stack_allocated"))) \ + void* operator new(size_t) = delete; \ + void* operator new(size_t, void*) = delete; + +#define ALLOW_ONLY_INLINE_ALLOCATION() \ + public: \ + void* operator new(size_t, void*); \ + private: \ + void* operator new(size_t) = delete; + +#define GC_PLUGIN_IGNORE(bug) \ + __attribute__((annotate("blink_gc_plugin_ignore"))) + +#define USING_GARBAGE_COLLECTED_MIXIN(type) \ +public: \ + virtual void adjustAndMark(Visitor*) const override { } \ + virtual bool isHeapObjectAlive(Visitor*) const override { return 0; } + +#define EAGERLY_FINALIZED() typedef int IsEagerlyFinalizedMarker + +template<typename T> class GarbageCollected { }; + +template<typename T> +class GarbageCollectedFinalized : public GarbageCollected<T> { }; + +template<typename T> +class RefCountedGarbageCollected : public GarbageCollectedFinalized<T> { }; + +template<typename T> class Member { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } + bool operator!() const { return false; } +}; + +template<typename T> class WeakMember { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } + bool operator!() const { return false; } +}; + +template<typename T> class Persistent { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } + bool operator!() const { return false; } +}; + +template<typename T> class WeakPersistent { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } + bool operator!() const { return false; } +}; + +template<typename T> class CrossThreadPersistent { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } + bool operator!() const { return false; } +}; + +template<typename T> class CrossThreadWeakPersistent { +public: + operator T*() const { return 0; } + T* operator->() { return 0; } + bool operator!() const { return false; } +}; + +class HeapAllocator { +public: + static const bool isGarbageCollected = true; +}; + +template<typename T, size_t inlineCapacity = 0> +class HeapVector : public Vector<T, inlineCapacity, HeapAllocator> { }; + +template<typename T, size_t inlineCapacity = 0> +class HeapDeque : public Vector<T, inlineCapacity, HeapAllocator> { }; + +template<typename T> +class HeapHashSet : public HashSet<T, void, void, HeapAllocator> { }; + +template<typename T> +class HeapListHashSet : public ListHashSet<T, void, void, HeapAllocator> { }; + +template<typename T> +class HeapLinkedHashSet : public LinkedHashSet<T, void, void, HeapAllocator> { +}; + +template<typename T> +class HeapHashCountedSet : public HashCountedSet<T, void, void, HeapAllocator> { +}; + +template<typename K, typename V> +class HeapHashMap : public HashMap<K, V, void, void, void, HeapAllocator> { }; + +template<typename T> +class PersistentHeapVector : public Vector<T, 0, HeapAllocator> { }; + +template <typename Derived> +class VisitorHelper { +public: + template<typename T> + void trace(const T&); +}; + +class Visitor : public VisitorHelper<Visitor> { +public: + template<typename T, void (T::*method)(Visitor*)> + void registerWeakMembers(const T* obj); +}; + +class InlinedGlobalMarkingVisitor + : public VisitorHelper<InlinedGlobalMarkingVisitor> { +public: + InlinedGlobalMarkingVisitor* operator->() { return this; } + + template<typename T, void (T::*method)(Visitor*)> + void registerWeakMembers(const T* obj); +}; + +class GarbageCollectedMixin { +public: + virtual void adjustAndMark(Visitor*) const = 0; + virtual bool isHeapObjectAlive(Visitor*) const = 0; + virtual void trace(Visitor*) { } +}; + +template<typename T> +struct TraceIfNeeded { + static void trace(Visitor*, T*); +}; + +} + +namespace WTF { + +template<typename T> +struct VectorTraits<blink::Member<T> > { + static const bool needsDestruction = false; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.cpp new file mode 100644 index 0000000..c539eb6 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.cpp
@@ -0,0 +1,20 @@ +// Copyright 2014 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. + +#include "ignore_class.h" + +namespace blink { + +void B::trace(Visitor* visitor) +{ + // Class is ignored so no checking here. +} + +void C::trace(Visitor* visitor) +{ + // Missing trace of m_obj. + // Ignored base class B does not need tracing. +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.h new file mode 100644 index 0000000..580ed7c --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.h
@@ -0,0 +1,40 @@ +// Copyright 2014 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. + +#ifndef IGNORE_CLASS_H_ +#define IGNORE_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { }; + +// Don't require trace method on ignored class. +class GC_PLUGIN_IGNORE("http://crbug.com/12345") A; +class A : public GarbageCollected<A> { +private: + Member<HeapObject> m_obj; +}; + +// Don't require tracing of fields on ignored class. +class GC_PLUGIN_IGNORE("http://crbug.com/12345") B; +class B : public GarbageCollected<B> { +public: + virtual void trace(Visitor*); +private: + Member<HeapObject> m_obj; +}; + +// Don't require tracing of an ignored base class. +class C : public B { +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.txt new file mode 100644 index 0000000..d3d2d80 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_class.txt
@@ -0,0 +1,7 @@ +ignore_class.cpp:14:1: warning: [blink-gc] Class 'C' has untraced fields that require tracing. +void C::trace(Visitor* visitor) +^ +./ignore_class.h:35:5: note: [blink-gc] Untraced field 'm_obj' declared here: + Member<HeapObject> m_obj; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.cpp new file mode 100644 index 0000000..118af754 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.cpp
@@ -0,0 +1,15 @@ +// Copyright 2014 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. + +#include "ignore_fields.h" + +namespace blink { + +void C::trace(Visitor* visitor) +{ + // Missing trace of m_one. + // Not missing ignored field m_two. +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.h new file mode 100644 index 0000000..e12bbab --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.h
@@ -0,0 +1,43 @@ +// Copyright 2014 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. + +#ifndef IGNORE_FIELDS_H_ +#define IGNORE_FIELDS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + virtual void trace(Visitor*) { } +}; + +// Don't warn about raw pointers to heap allocated objects. +class A : public GarbageCollected<A>{ +private: + GC_PLUGIN_IGNORE("http://crbug.com/12345") + HeapObject* m_obj; +}; + +// Don't require trace method when (all) GC fields are ignored. +class B : public GarbageCollected<B> { +private: + GC_PLUGIN_IGNORE("http://crbug.com/12345") + Member<HeapObject> m_one; +}; + +// Don't require tracing an ignored field. +class C : public GarbageCollected<C> { +public: + void trace(Visitor*); +private: + Member<HeapObject> m_one; + GC_PLUGIN_IGNORE("http://crbug.com/12345") + Member<HeapObject> m_two; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.txt new file mode 100644 index 0000000..b4de4981 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ignore_fields.txt
@@ -0,0 +1,7 @@ +ignore_fields.cpp:9:1: warning: [blink-gc] Class 'C' has untraced fields that require tracing. +void C::trace(Visitor* visitor) +^ +./ignore_fields.h:36:5: note: [blink-gc] Untraced field 'm_one' declared here: + Member<HeapObject> m_one; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.cpp new file mode 100644 index 0000000..03a53ea --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.cpp
@@ -0,0 +1,14 @@ +// Copyright 2014 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. + +#include "inner_class.h" + +namespace blink { + +void SomeObject::InnerObject::trace(Visitor* visitor) +{ + // Missing: visitor->trace(m_obj); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.h new file mode 100644 index 0000000..30f6ce3 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.h
@@ -0,0 +1,24 @@ +// Copyright 2014 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. + +#ifndef INNER_CLASS_H_ +#define INNER_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class SomeObject { +private: + class InnerObject : public GarbageCollected<InnerObject> { + public: + void trace(Visitor*); + private: + Member<InnerObject> m_obj; + }; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.txt new file mode 100644 index 0000000..acdef6e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/inner_class.txt
@@ -0,0 +1,7 @@ +inner_class.cpp:9:1: warning: [blink-gc] Class 'InnerObject' has untraced fields that require tracing. +void SomeObject::InnerObject::trace(Visitor* visitor) +^ +./inner_class.h:18:9: note: [blink-gc] Untraced field 'm_obj' declared here: + Member<InnerObject> m_obj; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.cpp new file mode 100644 index 0000000..041d9f07 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.cpp
@@ -0,0 +1,7 @@ +// Copyright 2014 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. + +#include "left_most_gc_base.h" + +// Nothing to define.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.h new file mode 100644 index 0000000..0d76d61 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.h
@@ -0,0 +1,30 @@ +// Copyright 2014 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. + +#ifndef LEFT_MOST_GC_BASE_H_ +#define LEFT_MOST_GC_BASE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A { }; +class B { }; + +class Right : public A, public B, public GarbageCollected<Right> { }; // Error +class Left : public GarbageCollected<Left>, public B, public A { }; + +class DerivedRight : public Right, public Left { }; // Error +class DerivedLeft : public Left, public Right { }; + +class C : public GarbageCollected<C> { +public: + virtual void trace(Visitor*); +}; + +class IllFormed : public A, public C { }; // Error + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.txt new file mode 100644 index 0000000..e2d04186 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/left_most_gc_base.txt
@@ -0,0 +1,14 @@ +In file included from left_most_gc_base.cpp:5: +./left_most_gc_base.h:15:1: warning: [blink-gc] Class 'Right' must derive its GC base in the left-most position. +class Right : public A, public B, public GarbageCollected<Right> { }; // Error +^ +./left_most_gc_base.h:18:1: warning: [blink-gc] Class 'DerivedRight' must derive its GC base in the left-most position. +class DerivedRight : public Right, public Left { }; // Error +^ +./left_most_gc_base.h:12:1: warning: [blink-gc] Left-most base class 'A' of derived class 'IllFormed' must be polymorphic. +class A { }; +^ +./left_most_gc_base.h:26:1: warning: [blink-gc] Class 'IllFormed' must derive its GC base in the left-most position. +class IllFormed : public A, public C { }; // Error +^ +4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.cpp new file mode 100644 index 0000000..4b44c2d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.cpp
@@ -0,0 +1,24 @@ +// Copyright 2014 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. + +#include "member_in_offheap_class.h" + +namespace blink { + +void OffHeapObject::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +void PartObject::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +void InlineObject::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.h new file mode 100644 index 0000000..2a7c868 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.h
@@ -0,0 +1,48 @@ +// Copyright 2014 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. + +#ifndef MEMBER_IN_OFFHEAP_CLASS_H_ +#define MEMBER_IN_OFFHEAP_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { }; + +class OffHeapObject { +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj; // Must not contain Member. + Persistent<HeapVector<Member<HeapObject> > > m_objs; // OK +}; + +class StackObject { + STACK_ALLOCATED(); +private: + Member<HeapObject> m_obj; // OK + Member<OffHeapObject> m_memberOff; // NOT OK + HeapVector<Member<OffHeapObject>> m_heapVectorMemberOff; // NOT OK +}; + +class PartObject { + DISALLOW_NEW(); +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj; // OK +}; + +class InlineObject { + ALLOW_ONLY_INLINE_ALLOCATION(); +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj; // OK +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.txt new file mode 100644 index 0000000..9d5f2388 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/member_in_offheap_class.txt
@@ -0,0 +1,17 @@ +In file included from member_in_offheap_class.cpp:5: +./member_in_offheap_class.h:14:1: warning: [blink-gc] Class 'OffHeapObject' contains invalid fields. +class OffHeapObject { +^ +./member_in_offheap_class.h:18:5: note: [blink-gc] Member field 'm_obj' in unmanaged class declared here: + Member<HeapObject> m_obj; // Must not contain Member. + ^ +./member_in_offheap_class.h:22:1: warning: [blink-gc] Class 'StackObject' contains invalid fields. +class StackObject { +^ +./member_in_offheap_class.h:26:5: note: [blink-gc] Member field 'm_memberOff' to non-GC managed class declared here: + Member<OffHeapObject> m_memberOff; // NOT OK + ^ +./member_in_offheap_class.h:27:5: note: [blink-gc] Member field 'm_heapVectorMemberOff' to non-GC managed class declared here: + HeapVector<Member<OffHeapObject>> m_heapVectorMemberOff; // NOT OK + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.cpp new file mode 100644 index 0000000..9f57711 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.cpp
@@ -0,0 +1,23 @@ +// Copyright 2014 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. + +#include "non_virtual_trace.h" + +namespace blink { + +void A::trace(Visitor* visitor) +{ +} + +void C::trace(Visitor* visitor) +{ + B::trace(visitor); +} + +void D::trace(Visitor* visitor) +{ + B::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.h new file mode 100644 index 0000000..4179d49 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.h
@@ -0,0 +1,32 @@ +// Copyright 2014 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. + +#ifndef NON_VIRTUAL_TRACE_H_ +#define NON_VIRTUAL_TRACE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + void trace(Visitor*); +}; + +class B : public A { +}; + +class C : public B { +public: + void trace(Visitor*); // Cannot override a non-virtual trace. +}; + +class D : public B { +public: + virtual void trace(Visitor*); // Cannot override a non-virtual trace. +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.txt new file mode 100644 index 0000000..a05a94d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/non_virtual_trace.txt
@@ -0,0 +1,17 @@ +In file included from non_virtual_trace.cpp:5: +./non_virtual_trace.h:12:1: warning: [blink-gc] Left-most base class 'A' of derived class 'D' must define a virtual trace method. +class A : public GarbageCollected<A> { +^ +non_virtual_trace.cpp:13:1: warning: [blink-gc] Class 'C' overrides non-virtual trace of base class 'A'. +void C::trace(Visitor* visitor) +^ +./non_virtual_trace.h:14:5: note: [blink-gc] Non-virtual trace method declared here: + void trace(Visitor*); + ^ +non_virtual_trace.cpp:18:1: warning: [blink-gc] Class 'D' overrides non-virtual trace of base class 'A'. +void D::trace(Visitor* visitor) +^ +./non_virtual_trace.h:14:5: note: [blink-gc] Non-virtual trace method declared here: + void trace(Visitor*); + ^ +3 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.cpp new file mode 100644 index 0000000..9e27c3d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.cpp
@@ -0,0 +1,11 @@ +// Copyright 2014 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. + +#include "own_ptr_to_gc_managed_class.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) { } + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.h new file mode 100644 index 0000000..6f47bafe --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.h
@@ -0,0 +1,30 @@ +// Copyright 2014 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. + +#ifndef OWN_PTR_TO_GC_MANAGED_CLASS_H_ +#define OWN_PTR_TO_GC_MANAGED_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + OwnPtr<HeapObject> m_obj; +}; + +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +public: + void trace(Visitor*); +private: + Vector<OwnPtr<HeapObject> > m_objs; + OwnPtr<HeapVector<Member<HeapObject> > > m_objs2; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.txt new file mode 100644 index 0000000..4102e86 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/own_ptr_to_gc_managed_class.txt
@@ -0,0 +1,17 @@ +In file included from own_ptr_to_gc_managed_class.cpp:5: +./own_ptr_to_gc_managed_class.h:14:1: warning: [blink-gc] Class 'PartObject' contains invalid fields. +class PartObject { +^ +./own_ptr_to_gc_managed_class.h:17:5: note: [blink-gc] OwnPtr field 'm_obj' to a GC managed class declared here: + OwnPtr<HeapObject> m_obj; + ^ +./own_ptr_to_gc_managed_class.h:20:1: warning: [blink-gc] Class 'HeapObject' contains invalid fields. +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +^ +./own_ptr_to_gc_managed_class.h:24:5: note: [blink-gc] OwnPtr field 'm_objs' to a GC managed class declared here: + Vector<OwnPtr<HeapObject> > m_objs; + ^ +./own_ptr_to_gc_managed_class.h:25:5: note: [blink-gc] OwnPtr field 'm_objs2' to a GC managed class declared here: + OwnPtr<HeapVector<Member<HeapObject> > > m_objs2; + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.cpp new file mode 100644 index 0000000..2da8661 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.cpp
@@ -0,0 +1,14 @@ +// Copyright 2014 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. + +#include "part_object_to_gc_derived_class.h" + +namespace blink { + +void B::trace(Visitor* visitor) +{ + visitor->trace(m_a); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.h new file mode 100644 index 0000000..ef5a649 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.h
@@ -0,0 +1,23 @@ +// Copyright 2014 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. + +#ifndef PART_OBJECT_TO_GC_DERIVED_CLASS_H_ +#define PART_OBJECT_TO_GC_DERIVED_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { }; + +class B : public GarbageCollected<B> { +public: + void trace(Visitor*); +private: + A m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.txt new file mode 100644 index 0000000..5970132 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/part_object_to_gc_derived_class.txt
@@ -0,0 +1,8 @@ +In file included from part_object_to_gc_derived_class.cpp:5: +./part_object_to_gc_derived_class.h:14:1: warning: [blink-gc] Class 'B' contains invalid fields. +class B : public GarbageCollected<B> { +^ +./part_object_to_gc_derived_class.h:18:5: note: [blink-gc] Part-object field 'm_a' to a GC derived class declared here: + A m_a; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.cpp new file mode 100644 index 0000000..7b3f286 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.cpp
@@ -0,0 +1,13 @@ +// Copyright 2014 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. + +#include "persistent_field_in_gc_managed_class.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) { + visitor->trace(m_parts); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.h new file mode 100644 index 0000000..a90f63c --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.h
@@ -0,0 +1,32 @@ +// Copyright 2014 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. + +#ifndef PERSISTENT_FIELD_IN_GC_MANAGED_CLASS_H_ +#define PERSISTENT_FIELD_IN_GC_MANAGED_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + Persistent<HeapObject> m_obj; +}; + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + PartObject m_part; + HeapVector<PartObject> m_parts; + PersistentHeapVector<Member<HeapObject> > m_objs; + WeakPersistent<HeapObject> m_weakPersistent; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.txt new file mode 100644 index 0000000..dd5bc74 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_field_in_gc_managed_class.txt
@@ -0,0 +1,32 @@ +In file included from persistent_field_in_gc_managed_class.cpp:5: +./persistent_field_in_gc_managed_class.h:20:1: warning: [blink-gc] Class 'HeapObject' contains GC root in field 'm_part'. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./persistent_field_in_gc_managed_class.h:24:5: note: [blink-gc] Field 'm_part' with embedded GC root in 'HeapObject' declared here: + PartObject m_part; + ^ +./persistent_field_in_gc_managed_class.h:17:5: note: [blink-gc] Field 'm_obj' defining a GC root declared here: + Persistent<HeapObject> m_obj; + ^ +./persistent_field_in_gc_managed_class.h:20:1: warning: [blink-gc] Class 'HeapObject' contains GC root in field 'm_parts'. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./persistent_field_in_gc_managed_class.h:25:5: note: [blink-gc] Field 'm_parts' with embedded GC root in 'HeapObject' declared here: + HeapVector<PartObject> m_parts; + ^ +./persistent_field_in_gc_managed_class.h:17:5: note: [blink-gc] Field 'm_obj' defining a GC root declared here: + Persistent<HeapObject> m_obj; + ^ +./persistent_field_in_gc_managed_class.h:20:1: warning: [blink-gc] Class 'HeapObject' contains GC root in field 'm_objs'. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./persistent_field_in_gc_managed_class.h:26:5: note: [blink-gc] Field 'm_objs' defining a GC root declared here: + PersistentHeapVector<Member<HeapObject> > m_objs; + ^ +./persistent_field_in_gc_managed_class.h:20:1: warning: [blink-gc] Class 'HeapObject' contains GC root in field 'm_weakPersistent'. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./persistent_field_in_gc_managed_class.h:27:5: note: [blink-gc] Field 'm_weakPersistent' defining a GC root declared here: + WeakPersistent<HeapObject> m_weakPersistent; + ^ +4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.cpp new file mode 100644 index 0000000..637b46f --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.cpp
@@ -0,0 +1,14 @@ +// Copyright 2016 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. + +#include "persistent_no_trace.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) { + visitor->trace(m_crossThreadPersistent); + visitor->trace(m_crossThreadWeakPersistent); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.h new file mode 100644 index 0000000..c8beb996 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.h
@@ -0,0 +1,22 @@ +// Copyright 2016 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. + +#ifndef PERSISTENT_NO_TRACE_H_ +#define PERSISTENT_NO_TRACE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + CrossThreadPersistent<HeapObject> m_crossThreadPersistent; + CrossThreadWeakPersistent<HeapObject> m_crossThreadWeakPersistent; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.txt new file mode 100644 index 0000000..dcfe76d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/persistent_no_trace.txt
@@ -0,0 +1,10 @@ +persistent_no_trace.cpp:9:1: warning: [blink-gc] Class 'HeapObject' has untraced or not traceable fields. +void HeapObject::trace(Visitor* visitor) { +^ +./persistent_no_trace.h:16:5: note: [blink-gc] Untraceable field 'm_crossThreadPersistent' declared here: + CrossThreadPersistent<HeapObject> m_crossThreadPersistent; + ^ +./persistent_no_trace.h:17:5: note: [blink-gc] Untraceable field 'm_crossThreadWeakPersistent' declared here: + CrossThreadWeakPersistent<HeapObject> m_crossThreadWeakPersistent; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.cpp new file mode 100644 index 0000000..dc7620a --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.cpp
@@ -0,0 +1,19 @@ +// Copyright 2014 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. + +#include "polymorphic_class_with_non_virtual_trace.h" + +namespace blink { + +void IsLeftMostPolymorphic::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +void IsNotLeftMostPolymorphic::trace(Visitor* visitor) +{ + visitor->trace(m_obj); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.h new file mode 100644 index 0000000..f5d999eb --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.h
@@ -0,0 +1,61 @@ +// Copyright 2014 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. + +#ifndef POLYMORPHIC_CLASS_WITH_NON_VIRTUAL_TRACE_H_ +#define POLYMORPHIC_CLASS_WITH_NON_VIRTUAL_TRACE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*) { } +}; + +class NonPolymorphicBase { +}; + +class PolymorphicBase { +public: + virtual void foo(); +}; + +class IsLeftMostPolymorphic + : public GarbageCollected<IsLeftMostPolymorphic>, + public PolymorphicBase { +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj; +}; + +class IsNotLeftMostPolymorphic + : public GarbageCollected<IsNotLeftMostPolymorphic>, + public NonPolymorphicBase, + public PolymorphicBase { +public: + void trace(Visitor*); +private: + Member<HeapObject> m_obj; +}; + +template<typename T> +class TemplatedNonPolymorphicBase + : public GarbageCollected<TemplatedNonPolymorphicBase<T> > { +public: + void trace(Visitor* visitor) { visitor->trace(m_obj); } +private: + Member<HeapObject> m_obj; +}; + +// Looks OK, but will result in an incorrect object pointer when marking. +class TemplatedIsNotLeftMostPolymorphic + : public TemplatedNonPolymorphicBase<TemplatedIsNotLeftMostPolymorphic>, + public PolymorphicBase { +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.txt new file mode 100644 index 0000000..38f2e77 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/polymorphic_class_with_non_virtual_trace.txt
@@ -0,0 +1,8 @@ +In file included from polymorphic_class_with_non_virtual_trace.cpp:5: +./polymorphic_class_with_non_virtual_trace.h:17:1: warning: [blink-gc] Left-most base class 'NonPolymorphicBase' of derived class 'IsNotLeftMostPolymorphic' must be polymorphic. +class NonPolymorphicBase { +^ +./polymorphic_class_with_non_virtual_trace.h:45:1: warning: [blink-gc] Left-most base class 'TemplatedNonPolymorphicBase<blink::TemplatedIsNotLeftMostPolymorphic>' of derived class 'TemplatedIsNotLeftMostPolymorphic' must be polymorphic. +class TemplatedNonPolymorphicBase +^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.cpp new file mode 100644 index 0000000..d993a326 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.cpp
@@ -0,0 +1,7 @@ +// Copyright 2014 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. + +#include "pure_virtual_trace.h" + +// Nothing to define
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.h new file mode 100644 index 0000000..356a95e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.h
@@ -0,0 +1,19 @@ +// Copyright 2014 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. + +#ifndef PURE_VIRTUAL_TRACE_H_ +#define PURE_VIRTUAL_TRACE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + virtual void trace(Visitor*) = 0; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.txt new file mode 100644 index 0000000..175a28a --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/pure_virtual_trace.txt
@@ -0,0 +1,5 @@ +In file included from pure_virtual_trace.cpp:5: +./pure_virtual_trace.h:14:5: warning: [blink-gc] Garbage collected class 'A' is not permitted to declare a pure-virtual trace method. + virtual void trace(Visitor*) = 0; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.cpp new file mode 100644 index 0000000..4d6cc05 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.cpp
@@ -0,0 +1,13 @@ +// Copyright 2014 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. + +#include "raw_ptr_to_gc_managed_class.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) { + visitor->trace(m_objs); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.h new file mode 100644 index 0000000..18fa9fa4 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.h
@@ -0,0 +1,33 @@ +// Copyright 2014 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. + +#ifndef RAW_PTR_TO_GC_MANAGED_CLASS_H_ +#define RAW_PTR_TO_GC_MANAGED_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + PartObject(); + + HeapObject* m_rawObj; + HeapObject& m_refObj; +}; + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + PartObject m_part; + HeapVector<HeapObject*> m_objs; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.txt new file mode 100644 index 0000000..98f5abe8 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class.txt
@@ -0,0 +1,17 @@ +In file included from raw_ptr_to_gc_managed_class.cpp:5: +./raw_ptr_to_gc_managed_class.h:14:1: warning: [blink-gc] Class 'PartObject' contains invalid fields. +class PartObject { +^ +./raw_ptr_to_gc_managed_class.h:19:5: note: [blink-gc] Raw pointer field 'm_rawObj' to a GC managed class declared here: + HeapObject* m_rawObj; + ^ +./raw_ptr_to_gc_managed_class.h:20:5: note: [blink-gc] Reference pointer field 'm_refObj' to a GC managed class declared here: + HeapObject& m_refObj; + ^ +./raw_ptr_to_gc_managed_class.h:23:1: warning: [blink-gc] Class 'HeapObject' contains invalid fields. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./raw_ptr_to_gc_managed_class.h:28:5: note: [blink-gc] Raw pointer field 'm_objs' to a GC managed class declared here: + HeapVector<HeapObject*> m_objs; + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.cpp new file mode 100644 index 0000000..f71d1b8 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.cpp
@@ -0,0 +1,13 @@ +// Copyright 2015 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. + +#include "raw_ptr_to_gc_managed_class_error.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) { + visitor->trace(m_objs); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.flags b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.flags new file mode 100644 index 0000000..2f41be66 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.flags
@@ -0,0 +1 @@ +-Werror
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.h new file mode 100644 index 0000000..f4921c4 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.h
@@ -0,0 +1,33 @@ +// Copyright 2015 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. + +#ifndef RAW_PTR_TO_GC_MANAGED_CLASS_ERROR_H_ +#define RAW_PTR_TO_GC_MANAGED_CLASS_ERROR_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + PartObject(); + + HeapObject* m_rawObj; + HeapObject& m_refObj; +}; + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + PartObject m_part; + HeapVector<HeapObject*> m_objs; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.txt new file mode 100644 index 0000000..c21c8172 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/raw_ptr_to_gc_managed_class_error.txt
@@ -0,0 +1,17 @@ +In file included from raw_ptr_to_gc_managed_class_error.cpp:5: +./raw_ptr_to_gc_managed_class_error.h:14:1: error: [blink-gc] Class 'PartObject' contains invalid fields. +class PartObject { +^ +./raw_ptr_to_gc_managed_class_error.h:19:5: note: [blink-gc] Raw pointer field 'm_rawObj' to a GC managed class declared here: + HeapObject* m_rawObj; + ^ +./raw_ptr_to_gc_managed_class_error.h:20:5: note: [blink-gc] Reference pointer field 'm_refObj' to a GC managed class declared here: + HeapObject& m_refObj; + ^ +./raw_ptr_to_gc_managed_class_error.h:23:1: error: [blink-gc] Class 'HeapObject' contains invalid fields. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./raw_ptr_to_gc_managed_class_error.h:28:5: note: [blink-gc] Raw pointer field 'm_objs' to a GC managed class declared here: + HeapVector<HeapObject*> m_objs; + ^ +2 errors generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.cpp new file mode 100644 index 0000000..e0a200f --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.cpp
@@ -0,0 +1,11 @@ +// Copyright 2014 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. + +#include "ref_ptr_to_gc_managed_class.h" + +namespace blink { + +void HeapObject::trace(Visitor*) { } + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.h new file mode 100644 index 0000000..c3df7f8 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.h
@@ -0,0 +1,30 @@ +// Copyright 2014 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. + +#ifndef REF_PTR_TO_GC_MANAGED_CLASS_H_ +#define REF_PTR_TO_GC_MANAGED_CLASS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + RefPtr<HeapObject> m_obj; +}; + +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +public: + void trace(Visitor*); +private: + PartObject m_part; + Vector<RefPtr<HeapObject> > m_objs; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.txt new file mode 100644 index 0000000..fd4978512 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/ref_ptr_to_gc_managed_class.txt
@@ -0,0 +1,14 @@ +In file included from ref_ptr_to_gc_managed_class.cpp:5: +./ref_ptr_to_gc_managed_class.h:14:1: warning: [blink-gc] Class 'PartObject' contains invalid fields. +class PartObject { +^ +./ref_ptr_to_gc_managed_class.h:17:5: note: [blink-gc] RefPtr field 'm_obj' to a GC managed class declared here: + RefPtr<HeapObject> m_obj; + ^ +./ref_ptr_to_gc_managed_class.h:20:1: warning: [blink-gc] Class 'HeapObject' contains invalid fields. +class HeapObject : public GarbageCollectedFinalized<HeapObject> { +^ +./ref_ptr_to_gc_managed_class.h:25:5: note: [blink-gc] RefPtr field 'm_objs' to a GC managed class declared here: + Vector<RefPtr<HeapObject> > m_objs; + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.cpp new file mode 100644 index 0000000..6742c22 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.cpp
@@ -0,0 +1,7 @@ +// Copyright 2015 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. + +#include "register_weak_members_template.h" + +// Nothing to define here.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.h new file mode 100644 index 0000000..7d3905a --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.h
@@ -0,0 +1,43 @@ +// Copyright 2015 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. + +#ifndef REGISTER_WEAK_MEMBERS_TEMPLATE_H_ +#define REGISTER_WEAK_MEMBERS_TEMPLATE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + void trace(Visitor* visitor) { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) {} +}; + +class HasUntracedWeakMembers : public GarbageCollected<HasUntracedWeakMembers> { + public: + void trace(Visitor* visitor) { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + + // Don't have to be defined for the purpose of this test. + void clearWeakMembers(Visitor* visitor); + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + visitor->template registerWeakMembers< + HasUntracedWeakMembers, + &HasUntracedWeakMembers::clearWeakMembers>(this); + } + + WeakMember<X> x_; +}; + +} + +#endif // REGISTER_WEAK_MEMBERS_TEMPLATE_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/register_weak_members_template.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.cpp new file mode 100644 index 0000000..3c4e321 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.cpp
@@ -0,0 +1,23 @@ +// Copyright 2014 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. + +#include "stack_allocated.h" + +namespace blink { + +// Verify that anon namespaces are checked. +namespace { + +class AnonStackObject : public StackObject { +public: + HeapObject* m_obj; +}; + +} + +void HeapObject::trace(Visitor* visitor) +{ +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.h new file mode 100644 index 0000000..10d8f41 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.h
@@ -0,0 +1,50 @@ +// Copyright 2014 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. + +#ifndef STACK_ALLOCATED_H_ +#define STACK_ALLOCATED_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class PartObject { + DISALLOW_NEW(); +private: + Member<HeapObject> m_obj; // Needs tracing. +}; + +class StackObject { + STACK_ALLOCATED(); +private: + Member<HeapObject> m_obj; // Does not need tracing. +}; + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + StackObject m_part; // Cannot embed a stack allocated object. +}; + +// Cannot derive from both heap- and stack-allocated objects. +class DerivedHeapObject : public HeapObject, public StackObject { +}; + +// Cannot be stack-allocated and derive from a heap-allocated object. +class DerivedHeapObject2 : public HeapObject { + STACK_ALLOCATED(); +}; + +// STACK_ALLOCATED is inherited. +class DerivedStackObject : public StackObject { +private: + StackObject m_anotherPart; // Also fine. +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.txt new file mode 100644 index 0000000..80980c3 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/stack_allocated.txt
@@ -0,0 +1,32 @@ +In file included from stack_allocated.cpp:5: +./stack_allocated.h:14:1: warning: [blink-gc] Class 'PartObject' requires a trace method. +class PartObject { +^ +./stack_allocated.h:17:5: note: [blink-gc] Untraced field 'm_obj' declared here: + Member<HeapObject> m_obj; // Needs tracing. + ^ +./stack_allocated.h:26:1: warning: [blink-gc] Class 'HeapObject' contains invalid fields. +class HeapObject : public GarbageCollected<HeapObject> { +^ +./stack_allocated.h:30:5: note: [blink-gc] Stack-allocated field 'm_part' declared here: + StackObject m_part; // Cannot embed a stack allocated object. + ^ +./stack_allocated.h:34:27: warning: [blink-gc] Stack-allocated class 'DerivedHeapObject' derives class 'HeapObject' which is garbage collected. +class DerivedHeapObject : public HeapObject, public StackObject { + ^ +./stack_allocated.h:38:28: warning: [blink-gc] Stack-allocated class 'DerivedHeapObject2' derives class 'HeapObject' which is garbage collected. +class DerivedHeapObject2 : public HeapObject { + ^ +./stack_allocated.h:39:3: warning: [blink-gc] Garbage collected class 'DerivedHeapObject2' is not permitted to override its new operator. + STACK_ALLOCATED(); + ^ +./heap/stubs.h:178:5: note: expanded from macro 'STACK_ALLOCATED' + __attribute__((annotate("blink_stack_allocated"))) \ + ^ +stack_allocated.cpp:12:1: warning: [blink-gc] Class 'AnonStackObject' contains invalid fields. +class AnonStackObject : public StackObject { +^ +stack_allocated.cpp:14:5: note: [blink-gc] Raw pointer field 'm_obj' to a GC managed class declared here: + HeapObject* m_obj; + ^ +6 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.cpp new file mode 100644 index 0000000..bd8b737 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.cpp
@@ -0,0 +1,26 @@ +// Copyright 2014 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. + +#include "templated_class_with_local_class_requires_trace.h" + +namespace blink { + +template<typename T> +void TemplatedObject<T>::trace(Visitor* visitor) +{ + visitor->trace(m_local); + visitor->trace(m_memberRef); +} + +class Test { +public: + static void test() + { + HeapObject* obj = new HeapObject(); + TemplatedObject<HeapObject>* instance = + new TemplatedObject<HeapObject>(obj); + } +}; + +} // namespace blink
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.h new file mode 100644 index 0000000..d2b0225 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.h
@@ -0,0 +1,52 @@ +// Copyright 2014 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. + +#ifndef TEMPLATED_CLASS_WITH_LOCAL_CLASS_REQUIRES_TRACE_H +#define TEMPLATED_CLASS_WITH_LOCAL_CLASS_REQUIRES_TRACE_H + +#include "heap/stubs.h" + +namespace blink { + +class NonHeapObject { }; + +class HeapObject : public GarbageCollected<HeapObject> { +public: + HeapObject() { } + + void trace(Visitor*) { } +}; + +template<typename T> +class TemplatedObject final + : public GarbageCollectedFinalized<TemplatedObject<T> > { +public: + TemplatedObject(T*) + { + } + + void trace(Visitor*); + +private: + class Local final : public GarbageCollected<Local> { + public: + void trace(Visitor* visitor) + { + visitor->trace(m_heapObject); + visitor->trace(m_object); + } + private: + Member<HeapObject> m_heapObject; + OwnPtr<HeapObject> m_object; + }; + + Member<Local> m_local; + Member<T> m_memberRef; + OwnPtr<T> m_ownRef; +}; + +} // namespace blink + +#endif // TEMPLATED_CLASS_WITH_LOCAL_CLASS_REQUIRES_TRACE_H +
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.txt new file mode 100644 index 0000000..fa6b9f5 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/templated_class_with_local_class_requires_trace.txt
@@ -0,0 +1,26 @@ +In file included from templated_class_with_local_class_requires_trace.cpp:5: +./templated_class_with_local_class_requires_trace.h:22:1: warning: [blink-gc] Class 'TemplatedObject<blink::HeapObject>' contains invalid fields. +class TemplatedObject final +^ +./templated_class_with_local_class_requires_trace.h:46:5: note: [blink-gc] OwnPtr field 'm_ownRef' to a GC managed class declared here: + OwnPtr<T> m_ownRef; + ^ +./templated_class_with_local_class_requires_trace.h:32:5: warning: [blink-gc] Class 'Local' contains invalid fields. + class Local final : public GarbageCollected<Local> { + ^ +./templated_class_with_local_class_requires_trace.h:41:9: note: [blink-gc] OwnPtr field 'm_object' to a GC managed class declared here: + OwnPtr<HeapObject> m_object; + ^ +./templated_class_with_local_class_requires_trace.h:32:5: warning: [blink-gc] Class 'Local' requires finalization. + class Local final : public GarbageCollected<Local> { + ^ +./templated_class_with_local_class_requires_trace.h:41:9: note: [blink-gc] Field 'm_object' requiring finalization declared here: + OwnPtr<HeapObject> m_object; + ^ +./templated_class_with_local_class_requires_trace.h:34:9: warning: [blink-gc] Class 'Local' has untraced or not traceable fields. + void trace(Visitor* visitor) + ^ +./templated_class_with_local_class_requires_trace.h:41:9: note: [blink-gc] Untraceable field 'm_object' declared here: + OwnPtr<HeapObject> m_object; + ^ +4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/test.py b/tools/clang/blink_gc_plugin/tests/legacy_naming/test.py new file mode 100755 index 0000000..475f6fbf --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/test.py
@@ -0,0 +1,66 @@ +#!/usr/bin/env python +# Copyright 2015 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. + +import argparse +import os +import subprocess +import sys + +script_dir = os.path.dirname(os.path.realpath(__file__)) +tool_dir = os.path.abspath(os.path.join(script_dir, '../../../pylib')) +sys.path.insert(0, tool_dir) + +from clang import plugin_testing + + +class BlinkGcPluginTest(plugin_testing.ClangPluginTest): + """Test harness for the Blink GC plugin.""" + + def AdjustClangArguments(self, clang_cmd): + clang_cmd.append('-Wno-inaccessible-base') + + def ProcessOneResult(self, test_name, actual): + # Some Blink GC plugins dump a JSON representation of the object graph, and + # use the processed results as the actual results of the test. + if os.path.exists('%s.graph.json' % test_name): + try: + actual = subprocess.check_output( + ['python', '../../process-graph.py', '-c', + '%s.graph.json' % test_name], + stderr=subprocess.STDOUT) + except subprocess.CalledProcessError, e: + # The graph processing script returns a failure exit code if the graph + # is bad (e.g. it has a cycle). The output still needs to be captured in + # that case, since the expected results capture the errors. + actual = e.output + finally: + # Clean up the .graph.json file to prevent false passes from stale + # results from a previous run. + os.remove('%s.graph.json' % test_name) + return super(BlinkGcPluginTest, self).ProcessOneResult(test_name, actual) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--reset-results', + action='store_true', + help='If specified, overwrites the expected results in place.') + parser.add_argument('clang_path', help='The path to the clang binary.') + parser.add_argument('plugin_path', + nargs='?', + help='The path to the plugin library, if any.') + args = parser.parse_args() + + return BlinkGcPluginTest( + os.path.dirname(os.path.realpath(__file__)), + args.clang_path, + args.plugin_path, + 'blink-gc-plugin', + args.reset_results).Run() + + +if __name__ == '__main__': + sys.exit(main())
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.cpp new file mode 100644 index 0000000..c246aaaf --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.cpp
@@ -0,0 +1,50 @@ +// Copyright 2014 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. + +#include "trace_after_dispatch.h" + +namespace blink { + +static B* toB(A* a) { return static_cast<B*>(a); } + +void A::trace(Visitor* visitor) +{ + switch (m_type) { + case TB: + toB(this)->traceAfterDispatch(visitor); + break; + case TC: + static_cast<C*>(this)->traceAfterDispatch(visitor); + break; + case TD: + // Missing static_cast<D*>(this)->traceAfterDispatch(visitor); + break; + } +} + +void A::traceAfterDispatch(Visitor* visitor) +{ +} + +void B::traceAfterDispatch(Visitor* visitor) +{ + visitor->trace(m_a); + // Missing A::traceAfterDispatch(visitor); + // Also check that calling trace does not count. + A::trace(visitor); +} + +void C::traceAfterDispatch(Visitor* visitor) +{ + // Missing visitor->trace(m_a); + A::traceAfterDispatch(visitor); +} + +void D::traceAfterDispatch(Visitor* visitor) +{ + visitor->trace(m_a); + Abstract::traceAfterDispatch(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.h new file mode 100644 index 0000000..a19a536 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.h
@@ -0,0 +1,55 @@ +// Copyright 2014 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. + +#ifndef TRACE_AFTER_DISPATCH_H_ +#define TRACE_AFTER_DISPATCH_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + void trace(Visitor*); + void traceAfterDispatch(Visitor*); +protected: + enum Type { TB, TC, TD }; + A(Type type) : m_type(type) { } +private: + Type m_type; +}; + +class B : public A { +public: + B() : A(TB) { } + void traceAfterDispatch(Visitor*); +private: + Member<A> m_a; +}; + +class C : public A { +public: + C() : A(TC) { } + void traceAfterDispatch(Visitor*); +private: + Member<A> m_a; +}; + +// This class is considered abstract does not need to be dispatched to. +class Abstract : public A { +protected: + Abstract(Type type) : A(type) { } +}; + +class D : public Abstract { +public: + D() : Abstract(TD) { } + void traceAfterDispatch(Visitor*); +private: + Member<A> m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.txt new file mode 100644 index 0000000..877fbbe --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch.txt
@@ -0,0 +1,13 @@ +trace_after_dispatch.cpp:11:1: warning: [blink-gc] Missing dispatch to class 'D' in manual trace dispatch. +void A::trace(Visitor* visitor) +^ +trace_after_dispatch.cpp:30:1: warning: [blink-gc] Base class 'A' of derived class 'B' requires tracing. +void B::traceAfterDispatch(Visitor* visitor) +^ +trace_after_dispatch.cpp:38:1: warning: [blink-gc] Class 'C' has untraced fields that require tracing. +void C::traceAfterDispatch(Visitor* visitor) +^ +./trace_after_dispatch.h:36:5: note: [blink-gc] Untraced field 'm_a' declared here: + Member<A> m_a; + ^ +3 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.cpp new file mode 100644 index 0000000..53a6855 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.cpp
@@ -0,0 +1,74 @@ +// Copyright 2015 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. + +#include "trace_after_dispatch_impl.h" + +namespace blink { + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchInlinedBase::traceImpl( + VisitorDispatcher visitor) { + // Implement a simple form of manual dispatching, because BlinkGCPlugin + // checks if the tracing is dispatched to all derived classes. + // + // This function has to be implemented out-of-line, since we need to know the + // definition of derived classes here. + if (tag_ == DERIVED) { + static_cast<TraceAfterDispatchInlinedDerived*>(this)->traceAfterDispatch( + visitor); + } else { + traceAfterDispatch(visitor); + } +} + +void TraceAfterDispatchExternBase::trace(Visitor* visitor) { + traceImpl(visitor); +} + +void TraceAfterDispatchExternBase::trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchExternBase::traceImpl(VisitorDispatcher visitor) { + if (tag_ == DERIVED) { + static_cast<TraceAfterDispatchExternDerived*>(this)->traceAfterDispatch( + visitor); + } else { + traceAfterDispatch(visitor); + } +} + +void TraceAfterDispatchExternBase::traceAfterDispatch(Visitor* visitor) { + traceAfterDispatchImpl(visitor); +} + +void TraceAfterDispatchExternBase::traceAfterDispatch( + InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchExternBase::traceAfterDispatchImpl( + VisitorDispatcher visitor) { + visitor->trace(x_base_); +} + +void TraceAfterDispatchExternDerived::traceAfterDispatch(Visitor* visitor) { + traceAfterDispatchImpl(visitor); +} + +void TraceAfterDispatchExternDerived::traceAfterDispatch( + InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchExternDerived::traceAfterDispatchImpl( + VisitorDispatcher visitor) { + visitor->trace(x_derived_); + TraceAfterDispatchExternBase::traceAfterDispatch(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.h new file mode 100644 index 0000000..fe25279 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.h
@@ -0,0 +1,104 @@ +// Copyright 2015 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. + +#ifndef TRACE_AFTER_DISPATCH_IMPL_H_ +#define TRACE_AFTER_DISPATCH_IMPL_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + void trace(Visitor*) {} +}; + +enum ClassTag { + BASE, DERIVED +}; + +class TraceAfterDispatchInlinedBase + : public GarbageCollected<TraceAfterDispatchInlinedBase> { + public: + explicit TraceAfterDispatchInlinedBase(ClassTag tag) : tag_(tag) {} + + void trace(Visitor* visitor) { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + + void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor); + + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor) { + visitor->trace(x_base_); + } + + ClassTag tag_; + Member<X> x_base_; +}; + +class TraceAfterDispatchInlinedDerived : public TraceAfterDispatchInlinedBase { + public: + TraceAfterDispatchInlinedDerived() : TraceAfterDispatchInlinedBase(DERIVED) {} + + void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor) { + visitor->trace(x_derived_); + TraceAfterDispatchInlinedBase::traceAfterDispatch(visitor); + } + + Member<X> x_derived_; +}; + +class TraceAfterDispatchExternBase + : public GarbageCollected<TraceAfterDispatchExternBase> { + public: + explicit TraceAfterDispatchExternBase(ClassTag tag) : tag_(tag) {} + + void trace(Visitor* visitor); + void trace(InlinedGlobalMarkingVisitor visitor); + + void traceAfterDispatch(Visitor* visitor); + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor); + + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor); + + ClassTag tag_; + Member<X> x_base_; +}; + +class TraceAfterDispatchExternDerived : public TraceAfterDispatchExternBase { + public: + TraceAfterDispatchExternDerived() : TraceAfterDispatchExternBase(DERIVED) {} + + void traceAfterDispatch(Visitor* visitor); + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + + private: + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor); + + Member<X> x_derived_; +}; + +} + +#endif // TRACE_AFTER_DISPATCH_IMPL_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.cpp new file mode 100644 index 0000000..23798f7 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.cpp
@@ -0,0 +1,75 @@ +// Copyright 2015 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. + +#include "trace_after_dispatch_impl_error.h" + +namespace blink { + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchInlinedBase::traceImpl( + VisitorDispatcher visitor) { + // Implement a simple form of manual dispatching, because BlinkGCPlugin + // checks if the tracing is dispatched to all derived classes. + // + // This function has to be implemented out-of-line, since we need to know the + // definition of derived classes here. + if (tag_ == DERIVED) { + // Missing dispatch call: + // static_cast<TraceAfterDispatchInlinedDerived*>(this)->traceAfterDispatch( + // visitor); + } else { + traceAfterDispatch(visitor); + } +} + +void TraceAfterDispatchExternBase::trace(Visitor* visitor) { + traceImpl(visitor); +} + +void TraceAfterDispatchExternBase::trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchExternBase::traceImpl(VisitorDispatcher visitor) { + if (tag_ == DERIVED) { + // Missing dispatch call: + // static_cast<TraceAfterDispatchExternDerived*>(this)->traceAfterDispatch( + // visitor); + } else { + traceAfterDispatch(visitor); + } +} + +void TraceAfterDispatchExternBase::traceAfterDispatch(Visitor* visitor) { + traceAfterDispatchImpl(visitor); +} + +void TraceAfterDispatchExternBase::traceAfterDispatch( + InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchExternBase::traceAfterDispatchImpl( + VisitorDispatcher visitor) { + // No trace call. +} + +void TraceAfterDispatchExternDerived::traceAfterDispatch(Visitor* visitor) { + traceAfterDispatchImpl(visitor); +} + +void TraceAfterDispatchExternDerived::traceAfterDispatch( + InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceAfterDispatchExternDerived::traceAfterDispatchImpl( + VisitorDispatcher visitor) { + // Ditto. +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.h new file mode 100644 index 0000000..b480e39 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.h
@@ -0,0 +1,103 @@ +// Copyright 2015 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. + +#ifndef TRACE_AFTER_DISPATCH_IMPL_ERROR_H_ +#define TRACE_AFTER_DISPATCH_IMPL_ERROR_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + void trace(Visitor*) {} +}; + +enum ClassTag { + BASE, DERIVED +}; + +class TraceAfterDispatchInlinedBase + : public GarbageCollected<TraceAfterDispatchInlinedBase> { + public: + explicit TraceAfterDispatchInlinedBase(ClassTag tag) : tag_(tag) {} + + void trace(Visitor* visitor) { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + + void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor); + + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor) { + // No trace call; should get a warning. + } + + ClassTag tag_; + Member<X> x_base_; +}; + +class TraceAfterDispatchInlinedDerived : public TraceAfterDispatchInlinedBase { + public: + TraceAfterDispatchInlinedDerived() : TraceAfterDispatchInlinedBase(DERIVED) {} + + void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + traceAfterDispatchImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor) { + // No trace call (for member and base class). + } + + Member<X> x_derived_; +}; + +class TraceAfterDispatchExternBase + : public GarbageCollected<TraceAfterDispatchExternBase> { + public: + explicit TraceAfterDispatchExternBase(ClassTag tag) : tag_(tag) {} + + void trace(Visitor* visitor); + void trace(InlinedGlobalMarkingVisitor visitor); + + void traceAfterDispatch(Visitor* visitor); + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor); + + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor); + + ClassTag tag_; + Member<X> x_base_; +}; + +class TraceAfterDispatchExternDerived : public TraceAfterDispatchExternBase { + public: + TraceAfterDispatchExternDerived() : TraceAfterDispatchExternBase(DERIVED) {} + + void traceAfterDispatch(Visitor* visitor); + void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + + private: + template <typename VisitorDispatcher> + void traceAfterDispatchImpl(VisitorDispatcher visitor); + + Member<X> x_derived_; +}; + +} + +#endif // TRACE_AFTER_DISPATCH_IMPL_ERROR_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.txt new file mode 100644 index 0000000..058fccb8 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_after_dispatch_impl_error.txt
@@ -0,0 +1,34 @@ +trace_after_dispatch_impl_error.cpp:10:1: warning: [blink-gc] Missing dispatch to class 'TraceAfterDispatchInlinedDerived' in manual trace dispatch. +inline void TraceAfterDispatchInlinedBase::traceImpl( +^ +trace_after_dispatch_impl_error.cpp:35:1: warning: [blink-gc] Missing dispatch to class 'TraceAfterDispatchExternDerived' in manual trace dispatch. +inline void TraceAfterDispatchExternBase::traceImpl(VisitorDispatcher visitor) { +^ +In file included from trace_after_dispatch_impl_error.cpp:5: +./trace_after_dispatch_impl_error.h:39:3: warning: [blink-gc] Class 'TraceAfterDispatchInlinedBase' has untraced fields that require tracing. + void traceAfterDispatchImpl(VisitorDispatcher visitor) { + ^ +./trace_after_dispatch_impl_error.h:44:3: note: [blink-gc] Untraced field 'x_base_' declared here: + Member<X> x_base_; + ^ +./trace_after_dispatch_impl_error.h:58:3: warning: [blink-gc] Base class 'TraceAfterDispatchInlinedBase' of derived class 'TraceAfterDispatchInlinedDerived' requires tracing. + void traceAfterDispatchImpl(VisitorDispatcher visitor) { + ^ +./trace_after_dispatch_impl_error.h:58:3: warning: [blink-gc] Class 'TraceAfterDispatchInlinedDerived' has untraced fields that require tracing. +./trace_after_dispatch_impl_error.h:62:3: note: [blink-gc] Untraced field 'x_derived_' declared here: + Member<X> x_derived_; + ^ +trace_after_dispatch_impl_error.cpp:55:1: warning: [blink-gc] Class 'TraceAfterDispatchExternBase' has untraced fields that require tracing. +inline void TraceAfterDispatchExternBase::traceAfterDispatchImpl( +^ +./trace_after_dispatch_impl_error.h:84:3: note: [blink-gc] Untraced field 'x_base_' declared here: + Member<X> x_base_; + ^ +trace_after_dispatch_impl_error.cpp:70:1: warning: [blink-gc] Base class 'TraceAfterDispatchExternBase' of derived class 'TraceAfterDispatchExternDerived' requires tracing. +inline void TraceAfterDispatchExternDerived::traceAfterDispatchImpl( +^ +trace_after_dispatch_impl_error.cpp:70:1: warning: [blink-gc] Class 'TraceAfterDispatchExternDerived' has untraced fields that require tracing. +./trace_after_dispatch_impl_error.h:98:3: note: [blink-gc] Untraced field 'x_derived_' declared here: + Member<X> x_derived_; + ^ +8 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.cpp new file mode 100644 index 0000000..9ba7c96 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.cpp
@@ -0,0 +1,13 @@ +// Copyright 2014 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. + +#include "trace_collections.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) +{ +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.h new file mode 100644 index 0000000..219b056 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.h
@@ -0,0 +1,44 @@ +// Copyright 2014 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. + +#ifndef TRACE_COLLECTIONS_H_ +#define TRACE_COLLECTIONS_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); +private: + HeapVector<Member<HeapObject> > m_heapVector; + Vector<Member<HeapObject>, 0, HeapAllocator> m_wtfVector; + + HeapDeque<Member<HeapObject> > m_heapDeque; + Deque<Member<HeapObject>, 0, HeapAllocator> m_wtfDeque; + + HeapHashSet<Member<HeapObject> > m_heapSet; + HashSet<Member<HeapObject>, void, HeapAllocator> m_wtfSet; + + HeapListHashSet<Member<HeapObject> > m_heapListSet; + ListHashSet<Member<HeapObject>, void, HeapAllocator> m_wtfListSet; + + HeapLinkedHashSet<Member<HeapObject> > m_heapLinkedSet; + LinkedHashSet<Member<HeapObject>, void, HeapAllocator> m_wtfLinkedSet; + + HeapHashCountedSet<Member<HeapObject> > m_heapCountedSet; + HashCountedSet<Member<HeapObject>, void, HeapAllocator> m_wtfCountedSet; + + HeapHashMap<int, Member<HeapObject> > m_heapMapKey; + HeapHashMap<Member<HeapObject>, int > m_heapMapVal; + HashMap<int, Member<HeapObject>, void, void, void, HeapAllocator> + m_wtfMapKey; + HashMap<Member<HeapObject>, int, void, void, void, HeapAllocator> + m_wtfMapVal; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.txt new file mode 100644 index 0000000..7c20ad4 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_collections.txt
@@ -0,0 +1,52 @@ +trace_collections.cpp:9:1: warning: [blink-gc] Class 'HeapObject' has untraced fields that require tracing. +void HeapObject::trace(Visitor* visitor) +^ +./trace_collections.h:16:5: note: [blink-gc] Untraced field 'm_heapVector' declared here: + HeapVector<Member<HeapObject> > m_heapVector; + ^ +./trace_collections.h:17:5: note: [blink-gc] Untraced field 'm_wtfVector' declared here: + Vector<Member<HeapObject>, 0, HeapAllocator> m_wtfVector; + ^ +./trace_collections.h:19:5: note: [blink-gc] Untraced field 'm_heapDeque' declared here: + HeapDeque<Member<HeapObject> > m_heapDeque; + ^ +./trace_collections.h:20:5: note: [blink-gc] Untraced field 'm_wtfDeque' declared here: + Deque<Member<HeapObject>, 0, HeapAllocator> m_wtfDeque; + ^ +./trace_collections.h:22:5: note: [blink-gc] Untraced field 'm_heapSet' declared here: + HeapHashSet<Member<HeapObject> > m_heapSet; + ^ +./trace_collections.h:23:5: note: [blink-gc] Untraced field 'm_wtfSet' declared here: + HashSet<Member<HeapObject>, void, HeapAllocator> m_wtfSet; + ^ +./trace_collections.h:25:5: note: [blink-gc] Untraced field 'm_heapListSet' declared here: + HeapListHashSet<Member<HeapObject> > m_heapListSet; + ^ +./trace_collections.h:26:5: note: [blink-gc] Untraced field 'm_wtfListSet' declared here: + ListHashSet<Member<HeapObject>, void, HeapAllocator> m_wtfListSet; + ^ +./trace_collections.h:28:5: note: [blink-gc] Untraced field 'm_heapLinkedSet' declared here: + HeapLinkedHashSet<Member<HeapObject> > m_heapLinkedSet; + ^ +./trace_collections.h:29:5: note: [blink-gc] Untraced field 'm_wtfLinkedSet' declared here: + LinkedHashSet<Member<HeapObject>, void, HeapAllocator> m_wtfLinkedSet; + ^ +./trace_collections.h:31:5: note: [blink-gc] Untraced field 'm_heapCountedSet' declared here: + HeapHashCountedSet<Member<HeapObject> > m_heapCountedSet; + ^ +./trace_collections.h:32:5: note: [blink-gc] Untraced field 'm_wtfCountedSet' declared here: + HashCountedSet<Member<HeapObject>, void, HeapAllocator> m_wtfCountedSet; + ^ +./trace_collections.h:34:5: note: [blink-gc] Untraced field 'm_heapMapKey' declared here: + HeapHashMap<int, Member<HeapObject> > m_heapMapKey; + ^ +./trace_collections.h:35:5: note: [blink-gc] Untraced field 'm_heapMapVal' declared here: + HeapHashMap<Member<HeapObject>, int > m_heapMapVal; + ^ +./trace_collections.h:36:5: note: [blink-gc] Untraced field 'm_wtfMapKey' declared here: + HashMap<int, Member<HeapObject>, void, void, void, HeapAllocator> + ^ +./trace_collections.h:38:5: note: [blink-gc] Untraced field 'm_wtfMapVal' declared here: + HashMap<Member<HeapObject>, int, void, void, void, HeapAllocator> + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.cpp new file mode 100644 index 0000000..563c6cc1 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.cpp
@@ -0,0 +1,16 @@ +// Copyright 2014 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. + +#include "trace_if_needed.h" + +namespace blink { + +template<typename T> +void TemplatedObject<T>::trace(Visitor* visitor) +{ + TraceIfNeeded<T>::trace(visitor, &m_one); + // Missing trace of m_two +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.h new file mode 100644 index 0000000..00b8f22 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.h
@@ -0,0 +1,27 @@ +// Copyright 2014 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. + +#ifndef TRACE_IF_NEEDED_H_ +#define TRACE_IF_NEEDED_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { }; + +template<typename T> +class TemplatedObject : public GarbageCollected<TemplatedObject<T> > { +public: + virtual void trace(Visitor*); +private: + T m_one; + T m_two; +}; + +class InstantiatedObject : public TemplatedObject<Member<HeapObject> > { }; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.txt new file mode 100644 index 0000000..79a24e8 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_if_needed.txt
@@ -0,0 +1,7 @@ +trace_if_needed.cpp:9:1: warning: [blink-gc] Class 'TemplatedObject<blink::Member<blink::HeapObject> >' has untraced fields that require tracing. +template<typename T> +^ +./trace_if_needed.h:20:5: note: [blink-gc] Untraced field 'm_two' declared here: + T m_two; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.cpp new file mode 100644 index 0000000..2b59034 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.cpp
@@ -0,0 +1,36 @@ +// Copyright 2014 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. + +#include "trace_templated_super.h" + +namespace blink { + +template<typename T> +void Super<T>::clearWeakMembers(Visitor* visitor) +{ + (void)m_weak; +} + +template<typename T> +void Super<T>::trace(Visitor* visitor) +{ + visitor->registerWeakMembers<Super<T>, &Super<T>::clearWeakMembers>(this); + visitor->trace(m_obj); + Mixin::trace(visitor); +} + +template<typename T> +void Sub<T>::trace(Visitor* visitor) +{ + // Missing trace of m_obj. + Super<T>::trace(visitor); +} + +void HeapObject::trace(Visitor* visitor) +{ + visitor->trace(m_obj); + Sub<HeapObject>::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.h new file mode 100644 index 0000000..de8fd7b --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.h
@@ -0,0 +1,47 @@ +// Copyright 2014 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. + +#ifndef TRACE_TEMPLATED_SUPER_H_ +#define TRACE_TEMPLATED_SUPER_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject; + +class Mixin : public GarbageCollectedMixin { +public: + virtual void trace(Visitor*) override { } +}; + +template<typename T> +class Super : public GarbageCollected<Super<T> >, public Mixin { + USING_GARBAGE_COLLECTED_MIXIN(Super); +public: + virtual void trace(Visitor*) override; + void clearWeakMembers(Visitor*); +private: + Member<HeapObject> m_obj; + WeakMember<HeapObject> m_weak; +}; + +template<typename T> +class Sub : public Super<T> { +public: + virtual void trace(Visitor* visitor) override; +private: + Member<HeapObject> m_obj; +}; + +class HeapObject : public Sub<HeapObject> { +public: + virtual void trace(Visitor*) override; +private: + Member<HeapObject> m_obj; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.txt new file mode 100644 index 0000000..291b018 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/trace_templated_super.txt
@@ -0,0 +1,7 @@ +trace_templated_super.cpp:23:1: warning: [blink-gc] Class 'Sub<blink::HeapObject>' has untraced fields that require tracing. +template<typename T> +^ +./trace_templated_super.h:35:5: note: [blink-gc] Untraced field 'm_obj' declared here: + Member<HeapObject> m_obj; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.cpp new file mode 100644 index 0000000..c8849cc --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.cpp
@@ -0,0 +1,28 @@ +// Copyright 2014 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. + +#include "traceimpl.h" + +namespace blink { + +void TraceImplExtern::trace(Visitor* visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceImplExtern::traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_); +} + +void TraceImplBaseExtern::trace(Visitor* visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceImplBaseExtern::traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_); + Base::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.h new file mode 100644 index 0000000..64fae26 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.h
@@ -0,0 +1,68 @@ +// Copyright 2014 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. + +#ifndef TRACEIMPL_H_ +#define TRACEIMPL_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + virtual void trace(Visitor*) {} +}; + +class TraceImplInlined : public GarbageCollected<TraceImplInlined> { + public: + void trace(Visitor* visitor) { traceImpl(visitor); } + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_); + } + + private: + Member<X> x_; +}; + +class TraceImplExtern : public GarbageCollected<TraceImplExtern> { + public: + void trace(Visitor* visitor); + template <typename VisitorDispatcher> + inline void traceImpl(VisitorDispatcher); + + private: + Member<X> x_; +}; + +class Base : public GarbageCollected<Base> { + public: + virtual void trace(Visitor* visitor) {} +}; + +class TraceImplBaseInlined : public Base { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + Base::trace(visitor); + } +}; + +class TraceImplBaseExtern : public Base { + public: + void trace(Visitor* visitor) override; + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher); + + private: + Member<X> x_; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.cpp new file mode 100644 index 0000000..11b576c --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.cpp
@@ -0,0 +1,13 @@ +// Copyright 2015 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. + +#include "traceimpl_dependent_scope.h" + +namespace blink { + +// Template instantiation. +template class Derived<int>; +template class DerivedMissingTrace<int>; + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.h new file mode 100644 index 0000000..0d079f6f --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.h
@@ -0,0 +1,62 @@ +// Copyright 2015 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. + +#ifndef TRACEIMPL_DEPENDENT_SCOPE_H_ +#define TRACEIMPL_DEPENDENT_SCOPE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + virtual void trace(Visitor*) {} +}; + +template <typename T> +class Base : public GarbageCollected<Base<T> > { + public: + virtual void trace(Visitor* visitor) { traceImpl(visitor); } + virtual void trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) {} +}; + +template <typename T> +class Derived : public Base<T> { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) override { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + Base<T>::trace(visitor); + } +}; + +template <typename T> +class DerivedMissingTrace : public Base<T> { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) override { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + // Missing Base<T>::trace(visitor). + } +}; + +} + +#endif // TRACEIMPL_DEPENDENT_SCOPE_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.txt new file mode 100644 index 0000000..e1aab335 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_dependent_scope.txt
@@ -0,0 +1,5 @@ +In file included from traceimpl_dependent_scope.cpp:5: +./traceimpl_dependent_scope.h:55:3: warning: [blink-gc] Base class 'Base<int>' of derived class 'DerivedMissingTrace<int>' requires tracing. + void traceImpl(VisitorDispatcher visitor) { + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.cpp new file mode 100644 index 0000000..9636fca7 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.cpp
@@ -0,0 +1,7 @@ +// Copyright 2015 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. + +#include "traceimpl_derived_from_templated_base.h" + +// Nothing to define.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.h new file mode 100644 index 0000000..21b99789 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.h
@@ -0,0 +1,37 @@ +// Copyright 2015 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. + +#ifndef TRACEIMPL_DERIVED_FROM_TEMPLATED_BASE_H_ +#define TRACEIMPL_DERIVED_FROM_TEMPLATED_BASE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + virtual void trace(Visitor*) {} +}; + +template <int Y> +class TraceImplTemplatedBase + : public GarbageCollected<TraceImplTemplatedBase<Y> > { + public: + void trace(Visitor* visitor) { traceImpl(visitor); } + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_); + } + + private: + Member<X> x_; +}; + +class TraceImplDerivedFromTemplatedBase : public TraceImplTemplatedBase<0> { +}; + +} + +#endif // TRACEIMPL_DERIVED_FROM_TEMPLATED_BASE_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_derived_from_templated_base.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.cpp new file mode 100644 index 0000000..041c565e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.cpp
@@ -0,0 +1,29 @@ +// Copyright 2015 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. + +#include "traceimpl_error.h" + +namespace blink { + +void TraceImplExternWithUntracedMember::trace(Visitor* visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceImplExternWithUntracedMember::traceImpl( + VisitorDispatcher visitor) { + // Should get a warning as well. +} + +void TraceImplExternWithUntracedBase::trace(Visitor* visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void TraceImplExternWithUntracedBase::traceImpl( + VisitorDispatcher visitor) { + // Ditto. +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.h new file mode 100644 index 0000000..5a883b4e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.h
@@ -0,0 +1,68 @@ +// Copyright 2015 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. + +#ifndef TRACEIMPL_ERROR_H_ +#define TRACEIMPL_ERROR_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + virtual void trace(Visitor*) {} +}; + +class TraceImplInlinedWithUntracedMember + : public GarbageCollected<TraceImplInlinedWithUntracedMember> { + public: + void trace(Visitor* visitor) { traceImpl(visitor); } + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + // Empty; should get complaints from the plugin for untraced x_. + } + + private: + Member<X> x_; +}; + +class TraceImplExternWithUntracedMember + : public GarbageCollected<TraceImplExternWithUntracedMember> { + public: + void trace(Visitor* visitor); + + template <typename VisitorDispatcher> + inline void traceImpl(VisitorDispatcher); + + private: + Member<X> x_; +}; + +class Base : public GarbageCollected<Base> { + public: + virtual void trace(Visitor*) {} +}; + +class TraceImplInlineWithUntracedBase : public Base { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + // Empty; should get complaints from the plugin for untraced Base. + } +}; + +class TraceImplExternWithUntracedBase : public Base { + public: + void trace(Visitor*) override; + + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor); +}; + +} + +#endif // TRACEIMPL_ERROR_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.txt new file mode 100644 index 0000000..070b0296 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_error.txt
@@ -0,0 +1,20 @@ +In file included from traceimpl_error.cpp:5: +./traceimpl_error.h:23:3: warning: [blink-gc] Class 'TraceImplInlinedWithUntracedMember' has untraced fields that require tracing. + void traceImpl(VisitorDispatcher visitor) { + ^ +./traceimpl_error.h:28:3: note: [blink-gc] Untraced field 'x_' declared here: + Member<X> x_; + ^ +./traceimpl_error.h:53:3: warning: [blink-gc] Base class 'Base' of derived class 'TraceImplInlineWithUntracedBase' requires tracing. + void traceImpl(VisitorDispatcher visitor) { + ^ +traceimpl_error.cpp:14:1: warning: [blink-gc] Class 'TraceImplExternWithUntracedMember' has untraced fields that require tracing. +inline void TraceImplExternWithUntracedMember::traceImpl( +^ +./traceimpl_error.h:40:3: note: [blink-gc] Untraced field 'x_' declared here: + Member<X> x_; + ^ +traceimpl_error.cpp:24:1: warning: [blink-gc] Base class 'Base' of derived class 'TraceImplExternWithUntracedBase' requires tracing. +inline void TraceImplExternWithUntracedBase::traceImpl( +^ +4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.cpp new file mode 100644 index 0000000..b6dc2dff --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.cpp
@@ -0,0 +1,7 @@ +// Copyright 2015 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. + +#include "traceimpl_omitted_trace.h" + +// Nothing to define here.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.h new file mode 100644 index 0000000..3c5e955 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.h
@@ -0,0 +1,47 @@ +// Copyright 2015 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. + +#ifndef TRACEIMPL_OMITTED_TRACE_H_ +#define TRACEIMPL_OMITTED_TRACE_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { + public: + virtual void trace(Visitor* visitor) { traceImpl(visitor); } + virtual void trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) {} +}; + +class B : public A { + // trace() isn't necessary because we've got nothing to trace here. +}; + +class C : public B { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) override { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + // B::trace() is actually A::trace(), and in certain cases we only get + // limited information like "there is a function call that will be resolved + // to A::trace()". We still want to mark B as traced. + B::trace(visitor); + } +}; + +} + +#endif // TRACEIMPL_OMITTED_TRACE_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_omitted_trace.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.cpp new file mode 100644 index 0000000..02d4858 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.cpp
@@ -0,0 +1,36 @@ +// Copyright 2015 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. + +#include "traceimpl_overloaded.h" + +namespace blink { + +void ExternBase::trace(Visitor* visitor) { + traceImpl(visitor); +} + +void ExternBase::trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void ExternBase::traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_base_); +} + +void ExternDerived::trace(Visitor* visitor) { + traceImpl(visitor); +} + +void ExternDerived::trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void ExternDerived::traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_derived_); + ExternBase::trace(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.h new file mode 100644 index 0000000..808821df --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.h
@@ -0,0 +1,75 @@ +// Copyright 2015 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. + +#ifndef TRACEIMPL_OVERLOADED_H_ +#define TRACEIMPL_OVERLOADED_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + void trace(Visitor*) {} + void trace(InlinedGlobalMarkingVisitor) {} +}; + +class InlinedBase : public GarbageCollected<InlinedBase> { + public: + virtual void trace(Visitor* visitor) { traceImpl(visitor); } + virtual void trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { visitor->trace(x_base_); } + + Member<X> x_base_; +}; + +class InlinedDerived : public InlinedBase { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) override { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + visitor->trace(x_derived_); + InlinedBase::trace(visitor); + } + + Member<X> x_derived_; +}; + +class ExternBase : public GarbageCollected<ExternBase> { + public: + virtual void trace(Visitor*); + virtual void trace(InlinedGlobalMarkingVisitor); + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher); + + Member<X> x_base_; +}; + +class ExternDerived : public ExternBase { + public: + void trace(Visitor*) override; + void trace(InlinedGlobalMarkingVisitor) override; + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher); + + Member<X> x_derived_; +}; + +} + +#endif // TRACEIMPL_OVERLOADED_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded.txt
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.cpp new file mode 100644 index 0000000..07cab63 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.cpp
@@ -0,0 +1,35 @@ +// Copyright 2015 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. + +#include "traceimpl_overloaded_error.h" + +namespace blink { + +void ExternBase::trace(Visitor* visitor) { + traceImpl(visitor); +} + +void ExternBase::trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void ExternBase::traceImpl(VisitorDispatcher visitor) { + // Missing visitor->trace(x_base_). +} + +void ExternDerived::trace(Visitor* visitor) { + traceImpl(visitor); +} + +void ExternDerived::trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); +} + +template <typename VisitorDispatcher> +inline void ExternDerived::traceImpl(VisitorDispatcher visitor) { + // Missing visitor->trace(x_derived_) and ExternBase::trace(visitor). +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.h new file mode 100644 index 0000000..7d7a038 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.h
@@ -0,0 +1,76 @@ +// Copyright 2015 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. + +#ifndef TRACEIMPL_OVERLOADED_ERROR_H_ +#define TRACEIMPL_OVERLOADED_ERROR_H_ + +#include "heap/stubs.h" + +namespace blink { + +class X : public GarbageCollected<X> { + public: + void trace(Visitor*) {} + void trace(InlinedGlobalMarkingVisitor) {} +}; + +class InlinedBase : public GarbageCollected<InlinedBase> { + public: + virtual void trace(Visitor* visitor) { traceImpl(visitor); } + virtual void trace(InlinedGlobalMarkingVisitor visitor) { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + // Missing visitor->trace(x_base_). + } + + Member<X> x_base_; +}; + +class InlinedDerived : public InlinedBase { + public: + void trace(Visitor* visitor) override { traceImpl(visitor); } + void trace(InlinedGlobalMarkingVisitor visitor) override { + traceImpl(visitor); + } + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher visitor) { + // Missing visitor->trace(x_derived_) and InlinedBase::trace(visitor). + } + + Member<X> x_derived_; +}; + +class ExternBase : public GarbageCollected<ExternBase> { + public: + virtual void trace(Visitor*); + virtual void trace(InlinedGlobalMarkingVisitor); + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher); + + Member<X> x_base_; +}; + +class ExternDerived : public ExternBase { + public: + void trace(Visitor*) override; + void trace(InlinedGlobalMarkingVisitor) override; + + private: + template <typename VisitorDispatcher> + void traceImpl(VisitorDispatcher); + + Member<X> x_derived_; +}; + +} + +#endif // TRACEIMPL_OVERLOADED_ERROR_H_
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.txt new file mode 100644 index 0000000..644f9f0 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/traceimpl_overloaded_error.txt
@@ -0,0 +1,28 @@ +In file included from traceimpl_overloaded_error.cpp:5: +./traceimpl_overloaded_error.h:27:3: warning: [blink-gc] Class 'InlinedBase' has untraced fields that require tracing. + void traceImpl(VisitorDispatcher visitor) { + ^ +./traceimpl_overloaded_error.h:31:3: note: [blink-gc] Untraced field 'x_base_' declared here: + Member<X> x_base_; + ^ +./traceimpl_overloaded_error.h:43:3: warning: [blink-gc] Base class 'InlinedBase' of derived class 'InlinedDerived' requires tracing. + void traceImpl(VisitorDispatcher visitor) { + ^ +./traceimpl_overloaded_error.h:43:3: warning: [blink-gc] Class 'InlinedDerived' has untraced fields that require tracing. +./traceimpl_overloaded_error.h:47:3: note: [blink-gc] Untraced field 'x_derived_' declared here: + Member<X> x_derived_; + ^ +traceimpl_overloaded_error.cpp:18:1: warning: [blink-gc] Class 'ExternBase' has untraced fields that require tracing. +inline void ExternBase::traceImpl(VisitorDispatcher visitor) { +^ +./traceimpl_overloaded_error.h:59:3: note: [blink-gc] Untraced field 'x_base_' declared here: + Member<X> x_base_; + ^ +traceimpl_overloaded_error.cpp:31:1: warning: [blink-gc] Base class 'ExternBase' of derived class 'ExternDerived' requires tracing. +inline void ExternDerived::traceImpl(VisitorDispatcher visitor) { +^ +traceimpl_overloaded_error.cpp:31:1: warning: [blink-gc] Class 'ExternDerived' has untraced fields that require tracing. +./traceimpl_overloaded_error.h:71:3: note: [blink-gc] Untraced field 'x_derived_' declared here: + Member<X> x_derived_; + ^ +6 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.cpp new file mode 100644 index 0000000..2ba6f1e --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.cpp
@@ -0,0 +1,30 @@ +// Copyright 2014 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. + +#include "virtual_and_trace_after_dispatch.h" + +namespace blink { + +static B* toB(A* a) { return static_cast<B*>(a); } + +void A::trace(Visitor* visitor) +{ + switch (m_type) { + case TB: + toB(this)->traceAfterDispatch(visitor); + break; + } +} + +void A::traceAfterDispatch(Visitor* visitor) +{ +} + +void B::traceAfterDispatch(Visitor* visitor) +{ + visitor->trace(m_a); + A::traceAfterDispatch(visitor); +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.h new file mode 100644 index 0000000..50483496 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.h
@@ -0,0 +1,34 @@ +// Copyright 2014 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. + +#ifndef VIRTUAL_AND_TRACE_AFTER_DISPATCH_H_ +#define VIRTUAL_AND_TRACE_AFTER_DISPATCH_H_ + +#include "heap/stubs.h" + +namespace blink { + +class A : public GarbageCollected<A> { +public: + void trace(Visitor*); + void traceAfterDispatch(Visitor*); +protected: + enum Type { TB }; + A(Type type) : m_type(type) { } +private: + Type m_type; +}; + +class B : public A { +public: + B() : A(TB) { } + void traceAfterDispatch(Visitor*); + virtual void foo() { } +private: + Member<A> m_a; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.txt new file mode 100644 index 0000000..fb466967 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/virtual_and_trace_after_dispatch.txt
@@ -0,0 +1,11 @@ +In file included from virtual_and_trace_after_dispatch.cpp:5: +./virtual_and_trace_after_dispatch.h:12:1: warning: [blink-gc] Left-most base class 'A' of derived class 'B' must be polymorphic. +class A : public GarbageCollected<A> { +^ +./virtual_and_trace_after_dispatch.h:23:1: warning: [blink-gc] Class 'B' contains or inherits virtual methods but implements manual dispatching. +class B : public A { +^ +./virtual_and_trace_after_dispatch.h:14:5: note: [blink-gc] Manual dispatch 'trace' declared here: + void trace(Visitor*); + ^ +2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.cpp b/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.cpp new file mode 100644 index 0000000..382e9f97 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.cpp
@@ -0,0 +1,28 @@ +// Copyright 2014 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. + +#include "weak_fields_require_tracing.h" + +namespace blink { + +void HeapObject::trace(Visitor* visitor) +{ + // Missing visitor->trace(m_obj1); + // Missing visitor->trace(m_obj2); + // visitor->trace(m_obj3) in callback. + // Missing visitor->trace(m_set1); + visitor->trace(m_set2); + visitor->registerWeakMembers<HeapObject, + &HeapObject::clearWeakMembers>(this); +} + +void HeapObject::clearWeakMembers(Visitor* visitor) +{ + visitor->trace(m_obj1); // Does not count. + // Missing visitor->trace(m_obj2); + visitor->trace(m_obj3); // OK. + visitor->trace(m_set1); // Does not count. +} + +}
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.h b/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.h new file mode 100644 index 0000000..c6850e6d --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.h
@@ -0,0 +1,26 @@ +// Copyright 2014 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. + +#ifndef WEAK_FIELDS_REQUIRE_TRACING_H_ +#define WEAK_FIELDS_REQUIRE_TRACING_H_ + +#include "heap/stubs.h" + +namespace blink { + +class HeapObject : public GarbageCollected<HeapObject> { +public: + void trace(Visitor*); + void clearWeakMembers(Visitor*); +private: + Member<HeapObject> m_obj1; + WeakMember<HeapObject> m_obj2; + WeakMember<HeapObject> m_obj3; + HeapHashSet<WeakMember<HeapObject> > m_set1; + HeapHashSet<WeakMember<HeapObject> > m_set2; +}; + +} + +#endif
diff --git a/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.txt b/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.txt new file mode 100644 index 0000000..02f56a393 --- /dev/null +++ b/tools/clang/blink_gc_plugin/tests/legacy_naming/weak_fields_require_tracing.txt
@@ -0,0 +1,13 @@ +weak_fields_require_tracing.cpp:9:1: warning: [blink-gc] Class 'HeapObject' has untraced fields that require tracing. +void HeapObject::trace(Visitor* visitor) +^ +./weak_fields_require_tracing.h:17:5: note: [blink-gc] Untraced field 'm_obj1' declared here: + Member<HeapObject> m_obj1; + ^ +./weak_fields_require_tracing.h:18:5: note: [blink-gc] Untraced field 'm_obj2' declared here: + WeakMember<HeapObject> m_obj2; + ^ +./weak_fields_require_tracing.h:20:5: note: [blink-gc] Untraced field 'm_set1' declared here: + HeapHashSet<WeakMember<HeapObject> > m_set1; + ^ +1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.cpp b/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.cpp index 4b44c2d..f182eb11 100644 --- a/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.cpp
@@ -6,19 +6,19 @@ namespace blink { -void OffHeapObject::trace(Visitor* visitor) +void OffHeapObject::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } -void PartObject::trace(Visitor* visitor) +void PartObject::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } -void InlineObject::trace(Visitor* visitor) +void InlineObject::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } }
diff --git a/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.h b/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.h index 2a7c868..89357a3 100644 --- a/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.h +++ b/tools/clang/blink_gc_plugin/tests/member_in_offheap_class.h
@@ -13,7 +13,7 @@ class OffHeapObject { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; // Must not contain Member. Persistent<HeapVector<Member<HeapObject> > > m_objs; // OK @@ -30,7 +30,7 @@ class PartObject { DISALLOW_NEW(); public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; // OK }; @@ -38,7 +38,7 @@ class InlineObject { ALLOW_ONLY_INLINE_ALLOCATION(); public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; // OK };
diff --git a/tools/clang/blink_gc_plugin/tests/non_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/non_virtual_trace.cpp index 9f57711..820b9301 100644 --- a/tools/clang/blink_gc_plugin/tests/non_virtual_trace.cpp +++ b/tools/clang/blink_gc_plugin/tests/non_virtual_trace.cpp
@@ -6,18 +6,18 @@ namespace blink { -void A::trace(Visitor* visitor) +void A::Trace(Visitor* visitor) { } -void C::trace(Visitor* visitor) +void C::Trace(Visitor* visitor) { - B::trace(visitor); + B::Trace(visitor); } -void D::trace(Visitor* visitor) +void D::Trace(Visitor* visitor) { - B::trace(visitor); + B::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/non_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/non_virtual_trace.h index 4179d49..4cbd470 100644 --- a/tools/clang/blink_gc_plugin/tests/non_virtual_trace.h +++ b/tools/clang/blink_gc_plugin/tests/non_virtual_trace.h
@@ -11,7 +11,7 @@ class A : public GarbageCollected<A> { public: - void trace(Visitor*); + void Trace(Visitor*); }; class B : public A { @@ -19,12 +19,12 @@ class C : public B { public: - void trace(Visitor*); // Cannot override a non-virtual trace. + void Trace(Visitor*); // Cannot override a non-virtual Trace. }; class D : public B { public: - virtual void trace(Visitor*); // Cannot override a non-virtual trace. + virtual void Trace(Visitor*); // Cannot override a non-virtual Trace. }; }
diff --git a/tools/clang/blink_gc_plugin/tests/non_virtual_trace.txt b/tools/clang/blink_gc_plugin/tests/non_virtual_trace.txt index a05a94d..65d62eb 100644 --- a/tools/clang/blink_gc_plugin/tests/non_virtual_trace.txt +++ b/tools/clang/blink_gc_plugin/tests/non_virtual_trace.txt
@@ -3,15 +3,15 @@ class A : public GarbageCollected<A> { ^ non_virtual_trace.cpp:13:1: warning: [blink-gc] Class 'C' overrides non-virtual trace of base class 'A'. -void C::trace(Visitor* visitor) +void C::Trace(Visitor* visitor) ^ ./non_virtual_trace.h:14:5: note: [blink-gc] Non-virtual trace method declared here: - void trace(Visitor*); + void Trace(Visitor*); ^ non_virtual_trace.cpp:18:1: warning: [blink-gc] Class 'D' overrides non-virtual trace of base class 'A'. -void D::trace(Visitor* visitor) +void D::Trace(Visitor* visitor) ^ ./non_virtual_trace.h:14:5: note: [blink-gc] Non-virtual trace method declared here: - void trace(Visitor*); + void Trace(Visitor*); ^ 3 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.cpp index 9e27c3d..7621c148 100644 --- a/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.cpp
@@ -6,6 +6,6 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) { } +void HeapObject::Trace(Visitor* visitor) { } }
diff --git a/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.h index 6f47bafe..586716a3 100644 --- a/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.h +++ b/tools/clang/blink_gc_plugin/tests/own_ptr_to_gc_managed_class.h
@@ -19,7 +19,7 @@ class HeapObject : public GarbageCollectedFinalized<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: Vector<OwnPtr<HeapObject> > m_objs; OwnPtr<HeapVector<Member<HeapObject> > > m_objs2;
diff --git a/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.cpp b/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.cpp index 2da8661..43d4e0d 100644 --- a/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.cpp
@@ -6,9 +6,9 @@ namespace blink { -void B::trace(Visitor* visitor) +void B::Trace(Visitor* visitor) { - visitor->trace(m_a); + visitor->Trace(m_a); } }
diff --git a/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.h b/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.h index ef5a649..2b76566 100644 --- a/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.h +++ b/tools/clang/blink_gc_plugin/tests/part_object_to_gc_derived_class.h
@@ -13,7 +13,7 @@ class B : public GarbageCollected<B> { public: - void trace(Visitor*); + void Trace(Visitor*); private: A m_a; };
diff --git a/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.cpp index 7b3f286..a4d03cd 100644 --- a/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.cpp
@@ -6,8 +6,8 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) { - visitor->trace(m_parts); +void HeapObject::Trace(Visitor* visitor) { + visitor->Trace(m_parts); } }
diff --git a/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.h index a90f63c..546d749 100644 --- a/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.h +++ b/tools/clang/blink_gc_plugin/tests/persistent_field_in_gc_managed_class.h
@@ -19,7 +19,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: PartObject m_part; HeapVector<PartObject> m_parts;
diff --git a/tools/clang/blink_gc_plugin/tests/persistent_no_trace.cpp b/tools/clang/blink_gc_plugin/tests/persistent_no_trace.cpp index 637b46f..e503ddb 100644 --- a/tools/clang/blink_gc_plugin/tests/persistent_no_trace.cpp +++ b/tools/clang/blink_gc_plugin/tests/persistent_no_trace.cpp
@@ -6,9 +6,9 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) { - visitor->trace(m_crossThreadPersistent); - visitor->trace(m_crossThreadWeakPersistent); +void HeapObject::Trace(Visitor* visitor) { + visitor->Trace(m_crossThreadPersistent); + visitor->Trace(m_crossThreadWeakPersistent); } }
diff --git a/tools/clang/blink_gc_plugin/tests/persistent_no_trace.h b/tools/clang/blink_gc_plugin/tests/persistent_no_trace.h index c8beb996..761f161 100644 --- a/tools/clang/blink_gc_plugin/tests/persistent_no_trace.h +++ b/tools/clang/blink_gc_plugin/tests/persistent_no_trace.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: CrossThreadPersistent<HeapObject> m_crossThreadPersistent; CrossThreadWeakPersistent<HeapObject> m_crossThreadWeakPersistent;
diff --git a/tools/clang/blink_gc_plugin/tests/persistent_no_trace.txt b/tools/clang/blink_gc_plugin/tests/persistent_no_trace.txt index dcfe76d..d55d80b 100644 --- a/tools/clang/blink_gc_plugin/tests/persistent_no_trace.txt +++ b/tools/clang/blink_gc_plugin/tests/persistent_no_trace.txt
@@ -1,5 +1,5 @@ persistent_no_trace.cpp:9:1: warning: [blink-gc] Class 'HeapObject' has untraced or not traceable fields. -void HeapObject::trace(Visitor* visitor) { +void HeapObject::Trace(Visitor* visitor) { ^ ./persistent_no_trace.h:16:5: note: [blink-gc] Untraceable field 'm_crossThreadPersistent' declared here: CrossThreadPersistent<HeapObject> m_crossThreadPersistent;
diff --git a/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.cpp b/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.cpp index dc7620a..6bf5a9d8 100644 --- a/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.cpp +++ b/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.cpp
@@ -6,14 +6,14 @@ namespace blink { -void IsLeftMostPolymorphic::trace(Visitor* visitor) +void IsLeftMostPolymorphic::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } -void IsNotLeftMostPolymorphic::trace(Visitor* visitor) +void IsNotLeftMostPolymorphic::Trace(Visitor* visitor) { - visitor->trace(m_obj); + visitor->Trace(m_obj); } }
diff --git a/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.h index f5d999eb..7221280 100644 --- a/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.h +++ b/tools/clang/blink_gc_plugin/tests/polymorphic_class_with_non_virtual_trace.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*) { } + void Trace(Visitor*) { } }; class NonPolymorphicBase { @@ -26,7 +26,7 @@ : public GarbageCollected<IsLeftMostPolymorphic>, public PolymorphicBase { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; }; @@ -36,7 +36,7 @@ public NonPolymorphicBase, public PolymorphicBase { public: - void trace(Visitor*); + void Trace(Visitor*); private: Member<HeapObject> m_obj; }; @@ -45,7 +45,7 @@ class TemplatedNonPolymorphicBase : public GarbageCollected<TemplatedNonPolymorphicBase<T> > { public: - void trace(Visitor* visitor) { visitor->trace(m_obj); } + void Trace(Visitor* visitor) { visitor->Trace(m_obj); } private: Member<HeapObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.h b/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.h index 356a95e..12f7abd 100644 --- a/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.h +++ b/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.h
@@ -11,7 +11,7 @@ class A : public GarbageCollected<A> { public: - virtual void trace(Visitor*) = 0; + virtual void Trace(Visitor*) = 0; }; }
diff --git a/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.txt b/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.txt index 175a28a..c7a534f 100644 --- a/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.txt +++ b/tools/clang/blink_gc_plugin/tests/pure_virtual_trace.txt
@@ -1,5 +1,5 @@ In file included from pure_virtual_trace.cpp:5: ./pure_virtual_trace.h:14:5: warning: [blink-gc] Garbage collected class 'A' is not permitted to declare a pure-virtual trace method. - virtual void trace(Visitor*) = 0; + virtual void Trace(Visitor*) = 0; ^ 1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.cpp index 4d6cc05..6a0b6933 100644 --- a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.cpp
@@ -6,8 +6,8 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) { - visitor->trace(m_objs); +void HeapObject::Trace(Visitor* visitor) { + visitor->Trace(m_objs); } }
diff --git a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.h index 18fa9fa4..40333715 100644 --- a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.h +++ b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class.h
@@ -22,7 +22,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: PartObject m_part; HeapVector<HeapObject*> m_objs;
diff --git a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.cpp b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.cpp index f71d1b8..67642c0b 100644 --- a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.cpp +++ b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.cpp
@@ -6,8 +6,8 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) { - visitor->trace(m_objs); +void HeapObject::Trace(Visitor* visitor) { + visitor->Trace(m_objs); } }
diff --git a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.h b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.h index f4921c4..99e5b56 100644 --- a/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.h +++ b/tools/clang/blink_gc_plugin/tests/raw_ptr_to_gc_managed_class_error.h
@@ -22,7 +22,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: PartObject m_part; HeapVector<HeapObject*> m_objs;
diff --git a/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.cpp b/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.cpp index e0a200f..3d0286a 100644 --- a/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.cpp +++ b/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.cpp
@@ -6,6 +6,6 @@ namespace blink { -void HeapObject::trace(Visitor*) { } +void HeapObject::Trace(Visitor*) { } }
diff --git a/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.h b/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.h index c3df7f8..24ff08c0b 100644 --- a/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.h +++ b/tools/clang/blink_gc_plugin/tests/ref_ptr_to_gc_managed_class.h
@@ -19,7 +19,7 @@ class HeapObject : public GarbageCollectedFinalized<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: PartObject m_part; Vector<RefPtr<HeapObject> > m_objs;
diff --git a/tools/clang/blink_gc_plugin/tests/register_weak_members_template.h b/tools/clang/blink_gc_plugin/tests/register_weak_members_template.h index 7d3905a..61d8fbb 100644 --- a/tools/clang/blink_gc_plugin/tests/register_weak_members_template.h +++ b/tools/clang/blink_gc_plugin/tests/register_weak_members_template.h
@@ -11,26 +11,26 @@ class X : public GarbageCollected<X> { public: - void trace(Visitor* visitor) { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) { TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) {} + void TraceImpl(VisitorDispatcher visitor) {} }; class HasUntracedWeakMembers : public GarbageCollected<HasUntracedWeakMembers> { public: - void trace(Visitor* visitor) { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) { TraceImpl(visitor); } // Don't have to be defined for the purpose of this test. void clearWeakMembers(Visitor* visitor); private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - visitor->template registerWeakMembers< + void TraceImpl(VisitorDispatcher visitor) { + visitor->template RegisterWeakMembers< HasUntracedWeakMembers, &HasUntracedWeakMembers::clearWeakMembers>(this); }
diff --git a/tools/clang/blink_gc_plugin/tests/stack_allocated.cpp b/tools/clang/blink_gc_plugin/tests/stack_allocated.cpp index 3c4e321..74ae83b 100644 --- a/tools/clang/blink_gc_plugin/tests/stack_allocated.cpp +++ b/tools/clang/blink_gc_plugin/tests/stack_allocated.cpp
@@ -16,7 +16,7 @@ } -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { }
diff --git a/tools/clang/blink_gc_plugin/tests/stack_allocated.h b/tools/clang/blink_gc_plugin/tests/stack_allocated.h index 10d8f41..574219c 100644 --- a/tools/clang/blink_gc_plugin/tests/stack_allocated.h +++ b/tools/clang/blink_gc_plugin/tests/stack_allocated.h
@@ -25,7 +25,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: StackObject m_part; // Cannot embed a stack allocated object. };
diff --git a/tools/clang/blink_gc_plugin/tests/stack_allocated.txt b/tools/clang/blink_gc_plugin/tests/stack_allocated.txt index 6d33850..80980c3 100644 --- a/tools/clang/blink_gc_plugin/tests/stack_allocated.txt +++ b/tools/clang/blink_gc_plugin/tests/stack_allocated.txt
@@ -20,7 +20,7 @@ ./stack_allocated.h:39:3: warning: [blink-gc] Garbage collected class 'DerivedHeapObject2' is not permitted to override its new operator. STACK_ALLOCATED(); ^ -./heap/stubs.h:184:5: note: expanded from macro 'STACK_ALLOCATED' +./heap/stubs.h:178:5: note: expanded from macro 'STACK_ALLOCATED' __attribute__((annotate("blink_stack_allocated"))) \ ^ stack_allocated.cpp:12:1: warning: [blink-gc] Class 'AnonStackObject' contains invalid fields.
diff --git a/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.cpp b/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.cpp index bd8b737..739318b 100644 --- a/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.cpp +++ b/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.cpp
@@ -7,10 +7,10 @@ namespace blink { template<typename T> -void TemplatedObject<T>::trace(Visitor* visitor) +void TemplatedObject<T>::Trace(Visitor* visitor) { - visitor->trace(m_local); - visitor->trace(m_memberRef); + visitor->Trace(m_local); + visitor->Trace(m_memberRef); } class Test {
diff --git a/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.h b/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.h index d2b0225..6656120 100644 --- a/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.h +++ b/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.h
@@ -15,7 +15,7 @@ public: HeapObject() { } - void trace(Visitor*) { } + void Trace(Visitor*) { } }; template<typename T> @@ -26,15 +26,15 @@ { } - void trace(Visitor*); + void Trace(Visitor*); private: class Local final : public GarbageCollected<Local> { public: - void trace(Visitor* visitor) + void Trace(Visitor* visitor) { - visitor->trace(m_heapObject); - visitor->trace(m_object); + visitor->Trace(m_heapObject); + visitor->Trace(m_object); } private: Member<HeapObject> m_heapObject;
diff --git a/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.txt b/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.txt index fa6b9f5..fa3e0edc4 100644 --- a/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.txt +++ b/tools/clang/blink_gc_plugin/tests/templated_class_with_local_class_requires_trace.txt
@@ -18,7 +18,7 @@ OwnPtr<HeapObject> m_object; ^ ./templated_class_with_local_class_requires_trace.h:34:9: warning: [blink-gc] Class 'Local' has untraced or not traceable fields. - void trace(Visitor* visitor) + void Trace(Visitor* visitor) ^ ./templated_class_with_local_class_requires_trace.h:41:9: note: [blink-gc] Untraceable field 'm_object' declared here: OwnPtr<HeapObject> m_object;
diff --git a/tools/clang/blink_gc_plugin/tests/test.py b/tools/clang/blink_gc_plugin/tests/test.py index a380cc63..b1338bf 100755 --- a/tools/clang/blink_gc_plugin/tests/test.py +++ b/tools/clang/blink_gc_plugin/tests/test.py
@@ -20,6 +20,10 @@ def AdjustClangArguments(self, clang_cmd): clang_cmd.append('-Wno-inaccessible-base') + clang_cmd.append('-Xclang') + clang_cmd.append('-plugin-arg-blink-gc-plugin') + clang_cmd.append('-Xclang') + clang_cmd.append('use-chromium-style-naming') def ProcessOneResult(self, test_name, actual): # Some Blink GC plugins dump a JSON representation of the object graph, and
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.cpp b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.cpp index c246aaaf..4c62354 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.cpp +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.cpp
@@ -8,43 +8,43 @@ static B* toB(A* a) { return static_cast<B*>(a); } -void A::trace(Visitor* visitor) +void A::Trace(Visitor* visitor) { switch (m_type) { case TB: - toB(this)->traceAfterDispatch(visitor); + toB(this)->TraceAfterDispatch(visitor); break; case TC: - static_cast<C*>(this)->traceAfterDispatch(visitor); + static_cast<C*>(this)->TraceAfterDispatch(visitor); break; case TD: - // Missing static_cast<D*>(this)->traceAfterDispatch(visitor); + // Missing static_cast<D*>(this)->TraceAfterDispatch(visitor); break; } } -void A::traceAfterDispatch(Visitor* visitor) +void A::TraceAfterDispatch(Visitor* visitor) { } -void B::traceAfterDispatch(Visitor* visitor) +void B::TraceAfterDispatch(Visitor* visitor) { - visitor->trace(m_a); - // Missing A::traceAfterDispatch(visitor); - // Also check that calling trace does not count. - A::trace(visitor); + visitor->Trace(m_a); + // Missing A::TraceAfterDispatch(visitor); + // Also check that calling Trace does not count. + A::Trace(visitor); } -void C::traceAfterDispatch(Visitor* visitor) +void C::TraceAfterDispatch(Visitor* visitor) { - // Missing visitor->trace(m_a); - A::traceAfterDispatch(visitor); + // Missing visitor->Trace(m_a); + A::TraceAfterDispatch(visitor); } -void D::traceAfterDispatch(Visitor* visitor) +void D::TraceAfterDispatch(Visitor* visitor) { - visitor->trace(m_a); - Abstract::traceAfterDispatch(visitor); + visitor->Trace(m_a); + Abstract::TraceAfterDispatch(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.h b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.h index a19a536..0a5a7c7 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.h +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.h
@@ -11,8 +11,8 @@ class A : public GarbageCollected<A> { public: - void trace(Visitor*); - void traceAfterDispatch(Visitor*); + void Trace(Visitor*); + void TraceAfterDispatch(Visitor*); protected: enum Type { TB, TC, TD }; A(Type type) : m_type(type) { } @@ -23,7 +23,7 @@ class B : public A { public: B() : A(TB) { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); private: Member<A> m_a; }; @@ -31,7 +31,7 @@ class C : public A { public: C() : A(TC) { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); private: Member<A> m_a; }; @@ -45,7 +45,7 @@ class D : public Abstract { public: D() : Abstract(TD) { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); private: Member<A> m_a; };
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.txt b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.txt index 877fbbe..4873999 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.txt +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch.txt
@@ -1,11 +1,11 @@ trace_after_dispatch.cpp:11:1: warning: [blink-gc] Missing dispatch to class 'D' in manual trace dispatch. -void A::trace(Visitor* visitor) +void A::Trace(Visitor* visitor) ^ trace_after_dispatch.cpp:30:1: warning: [blink-gc] Base class 'A' of derived class 'B' requires tracing. -void B::traceAfterDispatch(Visitor* visitor) +void B::TraceAfterDispatch(Visitor* visitor) ^ trace_after_dispatch.cpp:38:1: warning: [blink-gc] Class 'C' has untraced fields that require tracing. -void C::traceAfterDispatch(Visitor* visitor) +void C::TraceAfterDispatch(Visitor* visitor) ^ ./trace_after_dispatch.h:36:5: note: [blink-gc] Untraced field 'm_a' declared here: Member<A> m_a;
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.cpp b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.cpp index 53a6855..17bd1f8b 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.cpp +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.cpp
@@ -7,7 +7,7 @@ namespace blink { template <typename VisitorDispatcher> -inline void TraceAfterDispatchInlinedBase::traceImpl( +inline void TraceAfterDispatchInlinedBase::TraceImpl( VisitorDispatcher visitor) { // Implement a simple form of manual dispatching, because BlinkGCPlugin // checks if the tracing is dispatched to all derived classes. @@ -15,60 +15,60 @@ // This function has to be implemented out-of-line, since we need to know the // definition of derived classes here. if (tag_ == DERIVED) { - static_cast<TraceAfterDispatchInlinedDerived*>(this)->traceAfterDispatch( + static_cast<TraceAfterDispatchInlinedDerived*>(this)->TraceAfterDispatch( visitor); } else { - traceAfterDispatch(visitor); + TraceAfterDispatch(visitor); } } -void TraceAfterDispatchExternBase::trace(Visitor* visitor) { - traceImpl(visitor); +void TraceAfterDispatchExternBase::Trace(Visitor* visitor) { + TraceImpl(visitor); } -void TraceAfterDispatchExternBase::trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); +void TraceAfterDispatchExternBase::Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceAfterDispatchExternBase::traceImpl(VisitorDispatcher visitor) { +inline void TraceAfterDispatchExternBase::TraceImpl(VisitorDispatcher visitor) { if (tag_ == DERIVED) { - static_cast<TraceAfterDispatchExternDerived*>(this)->traceAfterDispatch( + static_cast<TraceAfterDispatchExternDerived*>(this)->TraceAfterDispatch( visitor); } else { - traceAfterDispatch(visitor); + TraceAfterDispatch(visitor); } } -void TraceAfterDispatchExternBase::traceAfterDispatch(Visitor* visitor) { - traceAfterDispatchImpl(visitor); +void TraceAfterDispatchExternBase::TraceAfterDispatch(Visitor* visitor) { + TraceAfterDispatchImpl(visitor); } -void TraceAfterDispatchExternBase::traceAfterDispatch( +void TraceAfterDispatchExternBase::TraceAfterDispatch( InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + TraceAfterDispatchImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceAfterDispatchExternBase::traceAfterDispatchImpl( +inline void TraceAfterDispatchExternBase::TraceAfterDispatchImpl( VisitorDispatcher visitor) { - visitor->trace(x_base_); + visitor->Trace(x_base_); } -void TraceAfterDispatchExternDerived::traceAfterDispatch(Visitor* visitor) { - traceAfterDispatchImpl(visitor); +void TraceAfterDispatchExternDerived::TraceAfterDispatch(Visitor* visitor) { + TraceAfterDispatchImpl(visitor); } -void TraceAfterDispatchExternDerived::traceAfterDispatch( +void TraceAfterDispatchExternDerived::TraceAfterDispatch( InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + TraceAfterDispatchImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceAfterDispatchExternDerived::traceAfterDispatchImpl( +inline void TraceAfterDispatchExternDerived::TraceAfterDispatchImpl( VisitorDispatcher visitor) { - visitor->trace(x_derived_); - TraceAfterDispatchExternBase::traceAfterDispatch(visitor); + visitor->Trace(x_derived_); + TraceAfterDispatchExternBase::TraceAfterDispatch(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.h b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.h index fe25279..c5e3063 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.h +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.h
@@ -11,7 +11,7 @@ class X : public GarbageCollected<X> { public: - void trace(Visitor*) {} + void Trace(Visitor*) {} }; enum ClassTag { @@ -23,21 +23,21 @@ public: explicit TraceAfterDispatchInlinedBase(ClassTag tag) : tag_(tag) {} - void trace(Visitor* visitor) { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) { TraceImpl(visitor); } - void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + void TraceAfterDispatch(Visitor* visitor) { TraceAfterDispatchImpl(visitor); } + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + TraceAfterDispatchImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor); + void TraceImpl(VisitorDispatcher visitor); template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor) { - visitor->trace(x_base_); + void TraceAfterDispatchImpl(VisitorDispatcher visitor) { + visitor->Trace(x_base_); } ClassTag tag_; @@ -48,16 +48,16 @@ public: TraceAfterDispatchInlinedDerived() : TraceAfterDispatchInlinedBase(DERIVED) {} - void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + void TraceAfterDispatch(Visitor* visitor) { TraceAfterDispatchImpl(visitor); } + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + TraceAfterDispatchImpl(visitor); } private: template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor) { - visitor->trace(x_derived_); - TraceAfterDispatchInlinedBase::traceAfterDispatch(visitor); + void TraceAfterDispatchImpl(VisitorDispatcher visitor) { + visitor->Trace(x_derived_); + TraceAfterDispatchInlinedBase::TraceAfterDispatch(visitor); } Member<X> x_derived_; @@ -68,18 +68,18 @@ public: explicit TraceAfterDispatchExternBase(ClassTag tag) : tag_(tag) {} - void trace(Visitor* visitor); - void trace(InlinedGlobalMarkingVisitor visitor); + void Trace(Visitor* visitor); + void Trace(InlinedGlobalMarkingVisitor visitor); - void traceAfterDispatch(Visitor* visitor); - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + void TraceAfterDispatch(Visitor* visitor); + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor); private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor); + void TraceImpl(VisitorDispatcher visitor); template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor); + void TraceAfterDispatchImpl(VisitorDispatcher visitor); ClassTag tag_; Member<X> x_base_; @@ -89,12 +89,12 @@ public: TraceAfterDispatchExternDerived() : TraceAfterDispatchExternBase(DERIVED) {} - void traceAfterDispatch(Visitor* visitor); - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + void TraceAfterDispatch(Visitor* visitor); + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor); private: template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor); + void TraceAfterDispatchImpl(VisitorDispatcher visitor); Member<X> x_derived_; };
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.cpp b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.cpp index 23798f7..46553f3 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.cpp +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.cpp
@@ -7,7 +7,7 @@ namespace blink { template <typename VisitorDispatcher> -inline void TraceAfterDispatchInlinedBase::traceImpl( +inline void TraceAfterDispatchInlinedBase::TraceImpl( VisitorDispatcher visitor) { // Implement a simple form of manual dispatching, because BlinkGCPlugin // checks if the tracing is dispatched to all derived classes. @@ -16,58 +16,58 @@ // definition of derived classes here. if (tag_ == DERIVED) { // Missing dispatch call: - // static_cast<TraceAfterDispatchInlinedDerived*>(this)->traceAfterDispatch( + // static_cast<TraceAfterDispatchInlinedDerived*>(this)->TraceAfterDispatch( // visitor); } else { - traceAfterDispatch(visitor); + TraceAfterDispatch(visitor); } } -void TraceAfterDispatchExternBase::trace(Visitor* visitor) { - traceImpl(visitor); +void TraceAfterDispatchExternBase::Trace(Visitor* visitor) { + TraceImpl(visitor); } -void TraceAfterDispatchExternBase::trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); +void TraceAfterDispatchExternBase::Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceAfterDispatchExternBase::traceImpl(VisitorDispatcher visitor) { +inline void TraceAfterDispatchExternBase::TraceImpl(VisitorDispatcher visitor) { if (tag_ == DERIVED) { // Missing dispatch call: - // static_cast<TraceAfterDispatchExternDerived*>(this)->traceAfterDispatch( + // static_cast<TraceAfterDispatchExternDerived*>(this)->TraceAfterDispatch( // visitor); } else { - traceAfterDispatch(visitor); + TraceAfterDispatch(visitor); } } -void TraceAfterDispatchExternBase::traceAfterDispatch(Visitor* visitor) { - traceAfterDispatchImpl(visitor); +void TraceAfterDispatchExternBase::TraceAfterDispatch(Visitor* visitor) { + TraceAfterDispatchImpl(visitor); } -void TraceAfterDispatchExternBase::traceAfterDispatch( +void TraceAfterDispatchExternBase::TraceAfterDispatch( InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + TraceAfterDispatchImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceAfterDispatchExternBase::traceAfterDispatchImpl( +inline void TraceAfterDispatchExternBase::TraceAfterDispatchImpl( VisitorDispatcher visitor) { - // No trace call. + // No Trace call. } -void TraceAfterDispatchExternDerived::traceAfterDispatch(Visitor* visitor) { - traceAfterDispatchImpl(visitor); +void TraceAfterDispatchExternDerived::TraceAfterDispatch(Visitor* visitor) { + TraceAfterDispatchImpl(visitor); } -void TraceAfterDispatchExternDerived::traceAfterDispatch( +void TraceAfterDispatchExternDerived::TraceAfterDispatch( InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + TraceAfterDispatchImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceAfterDispatchExternDerived::traceAfterDispatchImpl( +inline void TraceAfterDispatchExternDerived::TraceAfterDispatchImpl( VisitorDispatcher visitor) { // Ditto. }
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.h b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.h index b480e39..29f9a8a 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.h +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.h
@@ -11,7 +11,7 @@ class X : public GarbageCollected<X> { public: - void trace(Visitor*) {} + void Trace(Visitor*) {} }; enum ClassTag { @@ -23,21 +23,21 @@ public: explicit TraceAfterDispatchInlinedBase(ClassTag tag) : tag_(tag) {} - void trace(Visitor* visitor) { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) { TraceImpl(visitor); } - void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + void TraceAfterDispatch(Visitor* visitor) { TraceAfterDispatchImpl(visitor); } + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + TraceAfterDispatchImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor); + void TraceImpl(VisitorDispatcher visitor); template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor) { - // No trace call; should get a warning. + void TraceAfterDispatchImpl(VisitorDispatcher visitor) { + // No Trace call; should get a warning. } ClassTag tag_; @@ -48,15 +48,15 @@ public: TraceAfterDispatchInlinedDerived() : TraceAfterDispatchInlinedBase(DERIVED) {} - void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { - traceAfterDispatchImpl(visitor); + void TraceAfterDispatch(Visitor* visitor) { TraceAfterDispatchImpl(visitor); } + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { + TraceAfterDispatchImpl(visitor); } private: template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor) { - // No trace call (for member and base class). + void TraceAfterDispatchImpl(VisitorDispatcher visitor) { + // No Trace call (for member and base class). } Member<X> x_derived_; @@ -67,18 +67,18 @@ public: explicit TraceAfterDispatchExternBase(ClassTag tag) : tag_(tag) {} - void trace(Visitor* visitor); - void trace(InlinedGlobalMarkingVisitor visitor); + void Trace(Visitor* visitor); + void Trace(InlinedGlobalMarkingVisitor visitor); - void traceAfterDispatch(Visitor* visitor); - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + void TraceAfterDispatch(Visitor* visitor); + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor); private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor); + void TraceImpl(VisitorDispatcher visitor); template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor); + void TraceAfterDispatchImpl(VisitorDispatcher visitor); ClassTag tag_; Member<X> x_base_; @@ -88,12 +88,12 @@ public: TraceAfterDispatchExternDerived() : TraceAfterDispatchExternBase(DERIVED) {} - void traceAfterDispatch(Visitor* visitor); - void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor); + void TraceAfterDispatch(Visitor* visitor); + void TraceAfterDispatch(InlinedGlobalMarkingVisitor visitor); private: template <typename VisitorDispatcher> - void traceAfterDispatchImpl(VisitorDispatcher visitor); + void TraceAfterDispatchImpl(VisitorDispatcher visitor); Member<X> x_derived_; };
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.txt b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.txt index 058fccb8..5637daa 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.txt +++ b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl_error.txt
@@ -1,31 +1,31 @@ trace_after_dispatch_impl_error.cpp:10:1: warning: [blink-gc] Missing dispatch to class 'TraceAfterDispatchInlinedDerived' in manual trace dispatch. -inline void TraceAfterDispatchInlinedBase::traceImpl( +inline void TraceAfterDispatchInlinedBase::TraceImpl( ^ trace_after_dispatch_impl_error.cpp:35:1: warning: [blink-gc] Missing dispatch to class 'TraceAfterDispatchExternDerived' in manual trace dispatch. -inline void TraceAfterDispatchExternBase::traceImpl(VisitorDispatcher visitor) { +inline void TraceAfterDispatchExternBase::TraceImpl(VisitorDispatcher visitor) { ^ In file included from trace_after_dispatch_impl_error.cpp:5: ./trace_after_dispatch_impl_error.h:39:3: warning: [blink-gc] Class 'TraceAfterDispatchInlinedBase' has untraced fields that require tracing. - void traceAfterDispatchImpl(VisitorDispatcher visitor) { + void TraceAfterDispatchImpl(VisitorDispatcher visitor) { ^ ./trace_after_dispatch_impl_error.h:44:3: note: [blink-gc] Untraced field 'x_base_' declared here: Member<X> x_base_; ^ ./trace_after_dispatch_impl_error.h:58:3: warning: [blink-gc] Base class 'TraceAfterDispatchInlinedBase' of derived class 'TraceAfterDispatchInlinedDerived' requires tracing. - void traceAfterDispatchImpl(VisitorDispatcher visitor) { + void TraceAfterDispatchImpl(VisitorDispatcher visitor) { ^ ./trace_after_dispatch_impl_error.h:58:3: warning: [blink-gc] Class 'TraceAfterDispatchInlinedDerived' has untraced fields that require tracing. ./trace_after_dispatch_impl_error.h:62:3: note: [blink-gc] Untraced field 'x_derived_' declared here: Member<X> x_derived_; ^ trace_after_dispatch_impl_error.cpp:55:1: warning: [blink-gc] Class 'TraceAfterDispatchExternBase' has untraced fields that require tracing. -inline void TraceAfterDispatchExternBase::traceAfterDispatchImpl( +inline void TraceAfterDispatchExternBase::TraceAfterDispatchImpl( ^ ./trace_after_dispatch_impl_error.h:84:3: note: [blink-gc] Untraced field 'x_base_' declared here: Member<X> x_base_; ^ trace_after_dispatch_impl_error.cpp:70:1: warning: [blink-gc] Base class 'TraceAfterDispatchExternBase' of derived class 'TraceAfterDispatchExternDerived' requires tracing. -inline void TraceAfterDispatchExternDerived::traceAfterDispatchImpl( +inline void TraceAfterDispatchExternDerived::TraceAfterDispatchImpl( ^ trace_after_dispatch_impl_error.cpp:70:1: warning: [blink-gc] Class 'TraceAfterDispatchExternDerived' has untraced fields that require tracing. ./trace_after_dispatch_impl_error.h:98:3: note: [blink-gc] Untraced field 'x_derived_' declared here:
diff --git a/tools/clang/blink_gc_plugin/tests/trace_collections.cpp b/tools/clang/blink_gc_plugin/tests/trace_collections.cpp index 9ba7c96..c4e7c9c 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_collections.cpp +++ b/tools/clang/blink_gc_plugin/tests/trace_collections.cpp
@@ -6,7 +6,7 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { }
diff --git a/tools/clang/blink_gc_plugin/tests/trace_collections.h b/tools/clang/blink_gc_plugin/tests/trace_collections.h index 219b056..208823a 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_collections.h +++ b/tools/clang/blink_gc_plugin/tests/trace_collections.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); private: HeapVector<Member<HeapObject> > m_heapVector; Vector<Member<HeapObject>, 0, HeapAllocator> m_wtfVector;
diff --git a/tools/clang/blink_gc_plugin/tests/trace_collections.txt b/tools/clang/blink_gc_plugin/tests/trace_collections.txt index 7c20ad4..1faecb2 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_collections.txt +++ b/tools/clang/blink_gc_plugin/tests/trace_collections.txt
@@ -1,5 +1,5 @@ trace_collections.cpp:9:1: warning: [blink-gc] Class 'HeapObject' has untraced fields that require tracing. -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) ^ ./trace_collections.h:16:5: note: [blink-gc] Untraced field 'm_heapVector' declared here: HeapVector<Member<HeapObject> > m_heapVector;
diff --git a/tools/clang/blink_gc_plugin/tests/trace_if_needed.cpp b/tools/clang/blink_gc_plugin/tests/trace_if_needed.cpp index 563c6cc1..0787f6d 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_if_needed.cpp +++ b/tools/clang/blink_gc_plugin/tests/trace_if_needed.cpp
@@ -7,10 +7,10 @@ namespace blink { template<typename T> -void TemplatedObject<T>::trace(Visitor* visitor) +void TemplatedObject<T>::Trace(Visitor* visitor) { - TraceIfNeeded<T>::trace(visitor, &m_one); - // Missing trace of m_two + TraceIfNeeded<T>::Trace(visitor, &m_one); + // Missing Trace of m_two } }
diff --git a/tools/clang/blink_gc_plugin/tests/trace_if_needed.h b/tools/clang/blink_gc_plugin/tests/trace_if_needed.h index 00b8f22..9cc1089 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_if_needed.h +++ b/tools/clang/blink_gc_plugin/tests/trace_if_needed.h
@@ -14,7 +14,7 @@ template<typename T> class TemplatedObject : public GarbageCollected<TemplatedObject<T> > { public: - virtual void trace(Visitor*); + virtual void Trace(Visitor*); private: T m_one; T m_two;
diff --git a/tools/clang/blink_gc_plugin/tests/trace_templated_super.cpp b/tools/clang/blink_gc_plugin/tests/trace_templated_super.cpp index 2b59034..a3de020 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_templated_super.cpp +++ b/tools/clang/blink_gc_plugin/tests/trace_templated_super.cpp
@@ -13,24 +13,24 @@ } template<typename T> -void Super<T>::trace(Visitor* visitor) +void Super<T>::Trace(Visitor* visitor) { - visitor->registerWeakMembers<Super<T>, &Super<T>::clearWeakMembers>(this); - visitor->trace(m_obj); - Mixin::trace(visitor); + visitor->RegisterWeakMembers<Super<T>, &Super<T>::clearWeakMembers>(this); + visitor->Trace(m_obj); + Mixin::Trace(visitor); } template<typename T> -void Sub<T>::trace(Visitor* visitor) +void Sub<T>::Trace(Visitor* visitor) { - // Missing trace of m_obj. - Super<T>::trace(visitor); + // Missing Trace of m_obj. + Super<T>::Trace(visitor); } -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { - visitor->trace(m_obj); - Sub<HeapObject>::trace(visitor); + visitor->Trace(m_obj); + Sub<HeapObject>::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/trace_templated_super.h b/tools/clang/blink_gc_plugin/tests/trace_templated_super.h index de8fd7b..a0c9031 100644 --- a/tools/clang/blink_gc_plugin/tests/trace_templated_super.h +++ b/tools/clang/blink_gc_plugin/tests/trace_templated_super.h
@@ -13,14 +13,14 @@ class Mixin : public GarbageCollectedMixin { public: - virtual void trace(Visitor*) override { } + virtual void Trace(Visitor*) override { } }; template<typename T> class Super : public GarbageCollected<Super<T> >, public Mixin { USING_GARBAGE_COLLECTED_MIXIN(Super); public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; void clearWeakMembers(Visitor*); private: Member<HeapObject> m_obj; @@ -30,14 +30,14 @@ template<typename T> class Sub : public Super<T> { public: - virtual void trace(Visitor* visitor) override; + virtual void Trace(Visitor* visitor) override; private: Member<HeapObject> m_obj; }; class HeapObject : public Sub<HeapObject> { public: - virtual void trace(Visitor*) override; + virtual void Trace(Visitor*) override; private: Member<HeapObject> m_obj; };
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl.cpp b/tools/clang/blink_gc_plugin/tests/traceimpl.cpp index c8849cc..fe28a0b 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl.cpp +++ b/tools/clang/blink_gc_plugin/tests/traceimpl.cpp
@@ -6,23 +6,23 @@ namespace blink { -void TraceImplExtern::trace(Visitor* visitor) { - traceImpl(visitor); +void TraceImplExtern::Trace(Visitor* visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceImplExtern::traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_); +inline void TraceImplExtern::TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_); } -void TraceImplBaseExtern::trace(Visitor* visitor) { - traceImpl(visitor); +void TraceImplBaseExtern::Trace(Visitor* visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceImplBaseExtern::traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_); - Base::trace(visitor); +inline void TraceImplBaseExtern::TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_); + Base::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl.h b/tools/clang/blink_gc_plugin/tests/traceimpl.h index 64fae26..8cb51b1 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl.h
@@ -11,16 +11,16 @@ class X : public GarbageCollected<X> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; class TraceImplInlined : public GarbageCollected<TraceImplInlined> { public: - void trace(Visitor* visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_); + void TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_); } private: @@ -29,9 +29,9 @@ class TraceImplExtern : public GarbageCollected<TraceImplExtern> { public: - void trace(Visitor* visitor); + void Trace(Visitor* visitor); template <typename VisitorDispatcher> - inline void traceImpl(VisitorDispatcher); + inline void TraceImpl(VisitorDispatcher); private: Member<X> x_; @@ -39,25 +39,25 @@ class Base : public GarbageCollected<Base> { public: - virtual void trace(Visitor* visitor) {} + virtual void Trace(Visitor* visitor) {} }; class TraceImplBaseInlined : public Base { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } + void Trace(Visitor* visitor) override { TraceImpl(visitor); } template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - Base::trace(visitor); + void TraceImpl(VisitorDispatcher visitor) { + Base::Trace(visitor); } }; class TraceImplBaseExtern : public Base { public: - void trace(Visitor* visitor) override; + void Trace(Visitor* visitor) override; template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher); + void TraceImpl(VisitorDispatcher); private: Member<X> x_;
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.h b/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.h index 0d079f6f..1c54627 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.h
@@ -11,49 +11,49 @@ class X : public GarbageCollected<X> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; template <typename T> class Base : public GarbageCollected<Base<T> > { public: - virtual void trace(Visitor* visitor) { traceImpl(visitor); } - virtual void trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); + virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } + virtual void Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) {} + void TraceImpl(VisitorDispatcher visitor) {} }; template <typename T> class Derived : public Base<T> { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) override { - traceImpl(visitor); + void Trace(Visitor* visitor) override { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) override { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - Base<T>::trace(visitor); + void TraceImpl(VisitorDispatcher visitor) { + Base<T>::Trace(visitor); } }; template <typename T> class DerivedMissingTrace : public Base<T> { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) override { - traceImpl(visitor); + void Trace(Visitor* visitor) override { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) override { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - // Missing Base<T>::trace(visitor). + void TraceImpl(VisitorDispatcher visitor) { + // Missing Base<T>::Trace(visitor). } };
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.txt b/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.txt index e1aab335..b4779a09 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.txt +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_dependent_scope.txt
@@ -1,5 +1,5 @@ In file included from traceimpl_dependent_scope.cpp:5: ./traceimpl_dependent_scope.h:55:3: warning: [blink-gc] Base class 'Base<int>' of derived class 'DerivedMissingTrace<int>' requires tracing. - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { ^ 1 warning generated.
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.h b/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.h index 21b99789..e5ebdd5 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.h
@@ -11,18 +11,18 @@ class X : public GarbageCollected<X> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; template <int Y> class TraceImplTemplatedBase : public GarbageCollected<TraceImplTemplatedBase<Y> > { public: - void trace(Visitor* visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_); + void TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_); } private:
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_error.cpp b/tools/clang/blink_gc_plugin/tests/traceimpl_error.cpp index 041c565e..c14e52d 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_error.cpp +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_error.cpp
@@ -6,22 +6,22 @@ namespace blink { -void TraceImplExternWithUntracedMember::trace(Visitor* visitor) { - traceImpl(visitor); +void TraceImplExternWithUntracedMember::Trace(Visitor* visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceImplExternWithUntracedMember::traceImpl( +inline void TraceImplExternWithUntracedMember::TraceImpl( VisitorDispatcher visitor) { // Should get a warning as well. } -void TraceImplExternWithUntracedBase::trace(Visitor* visitor) { - traceImpl(visitor); +void TraceImplExternWithUntracedBase::Trace(Visitor* visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void TraceImplExternWithUntracedBase::traceImpl( +inline void TraceImplExternWithUntracedBase::TraceImpl( VisitorDispatcher visitor) { // Ditto. }
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_error.h b/tools/clang/blink_gc_plugin/tests/traceimpl_error.h index 5a883b4e..c7254d4 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_error.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_error.h
@@ -11,16 +11,16 @@ class X : public GarbageCollected<X> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; class TraceImplInlinedWithUntracedMember : public GarbageCollected<TraceImplInlinedWithUntracedMember> { public: - void trace(Visitor* visitor) { traceImpl(visitor); } + void Trace(Visitor* visitor) { TraceImpl(visitor); } template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { // Empty; should get complaints from the plugin for untraced x_. } @@ -31,10 +31,10 @@ class TraceImplExternWithUntracedMember : public GarbageCollected<TraceImplExternWithUntracedMember> { public: - void trace(Visitor* visitor); + void Trace(Visitor* visitor); template <typename VisitorDispatcher> - inline void traceImpl(VisitorDispatcher); + inline void TraceImpl(VisitorDispatcher); private: Member<X> x_; @@ -42,25 +42,25 @@ class Base : public GarbageCollected<Base> { public: - virtual void trace(Visitor*) {} + virtual void Trace(Visitor*) {} }; class TraceImplInlineWithUntracedBase : public Base { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } + void Trace(Visitor* visitor) override { TraceImpl(visitor); } template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { // Empty; should get complaints from the plugin for untraced Base. } }; class TraceImplExternWithUntracedBase : public Base { public: - void trace(Visitor*) override; + void Trace(Visitor*) override; template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor); + void TraceImpl(VisitorDispatcher visitor); }; }
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_error.txt b/tools/clang/blink_gc_plugin/tests/traceimpl_error.txt index 070b0296..ec976a0 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_error.txt +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_error.txt
@@ -1,20 +1,20 @@ In file included from traceimpl_error.cpp:5: ./traceimpl_error.h:23:3: warning: [blink-gc] Class 'TraceImplInlinedWithUntracedMember' has untraced fields that require tracing. - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { ^ ./traceimpl_error.h:28:3: note: [blink-gc] Untraced field 'x_' declared here: Member<X> x_; ^ ./traceimpl_error.h:53:3: warning: [blink-gc] Base class 'Base' of derived class 'TraceImplInlineWithUntracedBase' requires tracing. - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { ^ traceimpl_error.cpp:14:1: warning: [blink-gc] Class 'TraceImplExternWithUntracedMember' has untraced fields that require tracing. -inline void TraceImplExternWithUntracedMember::traceImpl( +inline void TraceImplExternWithUntracedMember::TraceImpl( ^ ./traceimpl_error.h:40:3: note: [blink-gc] Untraced field 'x_' declared here: Member<X> x_; ^ traceimpl_error.cpp:24:1: warning: [blink-gc] Base class 'Base' of derived class 'TraceImplExternWithUntracedBase' requires tracing. -inline void TraceImplExternWithUntracedBase::traceImpl( +inline void TraceImplExternWithUntracedBase::TraceImpl( ^ 4 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.h b/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.h index 3c5e955..7a171be 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.h
@@ -11,34 +11,34 @@ class A : public GarbageCollected<A> { public: - virtual void trace(Visitor* visitor) { traceImpl(visitor); } - virtual void trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); + virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } + virtual void Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) {} + void TraceImpl(VisitorDispatcher visitor) {} }; class B : public A { - // trace() isn't necessary because we've got nothing to trace here. + // Trace() isn't necessary because we've got nothing to trace here. }; class C : public B { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) override { - traceImpl(visitor); + void Trace(Visitor* visitor) override { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) override { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - // B::trace() is actually A::trace(), and in certain cases we only get + void TraceImpl(VisitorDispatcher visitor) { + // B::Trace() is actually A::Trace(), and in certain cases we only get // limited information like "there is a function call that will be resolved - // to A::trace()". We still want to mark B as traced. - B::trace(visitor); + // to A::Trace()". We still want to mark B as Traced. + B::Trace(visitor); } };
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.cpp b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.cpp index 02d4858..e5a2fee 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.cpp +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.cpp
@@ -6,31 +6,31 @@ namespace blink { -void ExternBase::trace(Visitor* visitor) { - traceImpl(visitor); +void ExternBase::Trace(Visitor* visitor) { + TraceImpl(visitor); } -void ExternBase::trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); +void ExternBase::Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void ExternBase::traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_base_); +inline void ExternBase::TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_base_); } -void ExternDerived::trace(Visitor* visitor) { - traceImpl(visitor); +void ExternDerived::Trace(Visitor* visitor) { + TraceImpl(visitor); } -void ExternDerived::trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); +void ExternDerived::Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void ExternDerived::traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_derived_); - ExternBase::trace(visitor); +inline void ExternDerived::TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_derived_); + ExternBase::Trace(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.h b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.h index 808821df..63ba65aa6 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.h
@@ -11,36 +11,36 @@ class X : public GarbageCollected<X> { public: - void trace(Visitor*) {} - void trace(InlinedGlobalMarkingVisitor) {} + void Trace(Visitor*) {} + void Trace(InlinedGlobalMarkingVisitor) {} }; class InlinedBase : public GarbageCollected<InlinedBase> { public: - virtual void trace(Visitor* visitor) { traceImpl(visitor); } - virtual void trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); + virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } + virtual void Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { visitor->trace(x_base_); } + void TraceImpl(VisitorDispatcher visitor) { visitor->Trace(x_base_); } Member<X> x_base_; }; class InlinedDerived : public InlinedBase { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) override { - traceImpl(visitor); + void Trace(Visitor* visitor) override { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) override { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - visitor->trace(x_derived_); - InlinedBase::trace(visitor); + void TraceImpl(VisitorDispatcher visitor) { + visitor->Trace(x_derived_); + InlinedBase::Trace(visitor); } Member<X> x_derived_; @@ -48,24 +48,24 @@ class ExternBase : public GarbageCollected<ExternBase> { public: - virtual void trace(Visitor*); - virtual void trace(InlinedGlobalMarkingVisitor); + virtual void Trace(Visitor*); + virtual void Trace(InlinedGlobalMarkingVisitor); private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher); + void TraceImpl(VisitorDispatcher); Member<X> x_base_; }; class ExternDerived : public ExternBase { public: - void trace(Visitor*) override; - void trace(InlinedGlobalMarkingVisitor) override; + void Trace(Visitor*) override; + void Trace(InlinedGlobalMarkingVisitor) override; private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher); + void TraceImpl(VisitorDispatcher); Member<X> x_derived_; };
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.cpp b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.cpp index 07cab63..80d0f65 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.cpp +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.cpp
@@ -6,30 +6,30 @@ namespace blink { -void ExternBase::trace(Visitor* visitor) { - traceImpl(visitor); +void ExternBase::Trace(Visitor* visitor) { + TraceImpl(visitor); } -void ExternBase::trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); +void ExternBase::Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void ExternBase::traceImpl(VisitorDispatcher visitor) { - // Missing visitor->trace(x_base_). +inline void ExternBase::TraceImpl(VisitorDispatcher visitor) { + // Missing visitor->Trace(x_base_). } -void ExternDerived::trace(Visitor* visitor) { - traceImpl(visitor); +void ExternDerived::Trace(Visitor* visitor) { + TraceImpl(visitor); } -void ExternDerived::trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); +void ExternDerived::Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } template <typename VisitorDispatcher> -inline void ExternDerived::traceImpl(VisitorDispatcher visitor) { - // Missing visitor->trace(x_derived_) and ExternBase::trace(visitor). +inline void ExternDerived::TraceImpl(VisitorDispatcher visitor) { + // Missing visitor->Trace(x_derived_) and ExternBase::Trace(visitor). } }
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.h b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.h index 7d7a038..be587dec 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.h +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.h
@@ -11,21 +11,21 @@ class X : public GarbageCollected<X> { public: - void trace(Visitor*) {} - void trace(InlinedGlobalMarkingVisitor) {} + void Trace(Visitor*) {} + void Trace(InlinedGlobalMarkingVisitor) {} }; class InlinedBase : public GarbageCollected<InlinedBase> { public: - virtual void trace(Visitor* visitor) { traceImpl(visitor); } - virtual void trace(InlinedGlobalMarkingVisitor visitor) { - traceImpl(visitor); + virtual void Trace(Visitor* visitor) { TraceImpl(visitor); } + virtual void Trace(InlinedGlobalMarkingVisitor visitor) { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - // Missing visitor->trace(x_base_). + void TraceImpl(VisitorDispatcher visitor) { + // Missing visitor->Trace(x_base_). } Member<X> x_base_; @@ -33,15 +33,15 @@ class InlinedDerived : public InlinedBase { public: - void trace(Visitor* visitor) override { traceImpl(visitor); } - void trace(InlinedGlobalMarkingVisitor visitor) override { - traceImpl(visitor); + void Trace(Visitor* visitor) override { TraceImpl(visitor); } + void Trace(InlinedGlobalMarkingVisitor visitor) override { + TraceImpl(visitor); } private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher visitor) { - // Missing visitor->trace(x_derived_) and InlinedBase::trace(visitor). + void TraceImpl(VisitorDispatcher visitor) { + // Missing visitor->Trace(x_derived_) and InlinedBase::Trace(visitor). } Member<X> x_derived_; @@ -49,24 +49,24 @@ class ExternBase : public GarbageCollected<ExternBase> { public: - virtual void trace(Visitor*); - virtual void trace(InlinedGlobalMarkingVisitor); + virtual void Trace(Visitor*); + virtual void Trace(InlinedGlobalMarkingVisitor); private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher); + void TraceImpl(VisitorDispatcher); Member<X> x_base_; }; class ExternDerived : public ExternBase { public: - void trace(Visitor*) override; - void trace(InlinedGlobalMarkingVisitor) override; + void Trace(Visitor*) override; + void Trace(InlinedGlobalMarkingVisitor) override; private: template <typename VisitorDispatcher> - void traceImpl(VisitorDispatcher); + void TraceImpl(VisitorDispatcher); Member<X> x_derived_; };
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.txt b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.txt index 644f9f0..b603a086 100644 --- a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.txt +++ b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded_error.txt
@@ -1,25 +1,25 @@ In file included from traceimpl_overloaded_error.cpp:5: ./traceimpl_overloaded_error.h:27:3: warning: [blink-gc] Class 'InlinedBase' has untraced fields that require tracing. - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { ^ ./traceimpl_overloaded_error.h:31:3: note: [blink-gc] Untraced field 'x_base_' declared here: Member<X> x_base_; ^ ./traceimpl_overloaded_error.h:43:3: warning: [blink-gc] Base class 'InlinedBase' of derived class 'InlinedDerived' requires tracing. - void traceImpl(VisitorDispatcher visitor) { + void TraceImpl(VisitorDispatcher visitor) { ^ ./traceimpl_overloaded_error.h:43:3: warning: [blink-gc] Class 'InlinedDerived' has untraced fields that require tracing. ./traceimpl_overloaded_error.h:47:3: note: [blink-gc] Untraced field 'x_derived_' declared here: Member<X> x_derived_; ^ traceimpl_overloaded_error.cpp:18:1: warning: [blink-gc] Class 'ExternBase' has untraced fields that require tracing. -inline void ExternBase::traceImpl(VisitorDispatcher visitor) { +inline void ExternBase::TraceImpl(VisitorDispatcher visitor) { ^ ./traceimpl_overloaded_error.h:59:3: note: [blink-gc] Untraced field 'x_base_' declared here: Member<X> x_base_; ^ traceimpl_overloaded_error.cpp:31:1: warning: [blink-gc] Base class 'ExternBase' of derived class 'ExternDerived' requires tracing. -inline void ExternDerived::traceImpl(VisitorDispatcher visitor) { +inline void ExternDerived::TraceImpl(VisitorDispatcher visitor) { ^ traceimpl_overloaded_error.cpp:31:1: warning: [blink-gc] Class 'ExternDerived' has untraced fields that require tracing. ./traceimpl_overloaded_error.h:71:3: note: [blink-gc] Untraced field 'x_derived_' declared here:
diff --git a/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.cpp b/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.cpp index 2ba6f1e..b284ddf 100644 --- a/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.cpp +++ b/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.cpp
@@ -8,23 +8,23 @@ static B* toB(A* a) { return static_cast<B*>(a); } -void A::trace(Visitor* visitor) +void A::Trace(Visitor* visitor) { switch (m_type) { case TB: - toB(this)->traceAfterDispatch(visitor); + toB(this)->TraceAfterDispatch(visitor); break; } } -void A::traceAfterDispatch(Visitor* visitor) +void A::TraceAfterDispatch(Visitor* visitor) { } -void B::traceAfterDispatch(Visitor* visitor) +void B::TraceAfterDispatch(Visitor* visitor) { - visitor->trace(m_a); - A::traceAfterDispatch(visitor); + visitor->Trace(m_a); + A::TraceAfterDispatch(visitor); } }
diff --git a/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.h b/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.h index 50483496..c6a7c959 100644 --- a/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.h +++ b/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.h
@@ -11,8 +11,8 @@ class A : public GarbageCollected<A> { public: - void trace(Visitor*); - void traceAfterDispatch(Visitor*); + void Trace(Visitor*); + void TraceAfterDispatch(Visitor*); protected: enum Type { TB }; A(Type type) : m_type(type) { } @@ -23,7 +23,7 @@ class B : public A { public: B() : A(TB) { } - void traceAfterDispatch(Visitor*); + void TraceAfterDispatch(Visitor*); virtual void foo() { } private: Member<A> m_a;
diff --git a/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.txt b/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.txt index fb466967..7a54b97b 100644 --- a/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.txt +++ b/tools/clang/blink_gc_plugin/tests/virtual_and_trace_after_dispatch.txt
@@ -5,7 +5,7 @@ ./virtual_and_trace_after_dispatch.h:23:1: warning: [blink-gc] Class 'B' contains or inherits virtual methods but implements manual dispatching. class B : public A { ^ -./virtual_and_trace_after_dispatch.h:14:5: note: [blink-gc] Manual dispatch 'trace' declared here: - void trace(Visitor*); +./virtual_and_trace_after_dispatch.h:14:5: note: [blink-gc] Manual dispatch 'Trace' declared here: + void Trace(Visitor*); ^ 2 warnings generated.
diff --git a/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.cpp b/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.cpp index 382e9f97..db9d535 100644 --- a/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.cpp +++ b/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.cpp
@@ -6,23 +6,23 @@ namespace blink { -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) { - // Missing visitor->trace(m_obj1); - // Missing visitor->trace(m_obj2); - // visitor->trace(m_obj3) in callback. - // Missing visitor->trace(m_set1); - visitor->trace(m_set2); - visitor->registerWeakMembers<HeapObject, + // Missing visitor->Trace(m_obj1); + // Missing visitor->Trace(m_obj2); + // visitor->Trace(m_obj3) in callback. + // Missing visitor->Trace(m_set1); + visitor->Trace(m_set2); + visitor->RegisterWeakMembers<HeapObject, &HeapObject::clearWeakMembers>(this); } void HeapObject::clearWeakMembers(Visitor* visitor) { - visitor->trace(m_obj1); // Does not count. - // Missing visitor->trace(m_obj2); - visitor->trace(m_obj3); // OK. - visitor->trace(m_set1); // Does not count. + visitor->Trace(m_obj1); // Does not count. + // Missing visitor->Trace(m_obj2); + visitor->Trace(m_obj3); // OK. + visitor->Trace(m_set1); // Does not count. } }
diff --git a/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.h b/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.h index c6850e6d..f7a2e62 100644 --- a/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.h +++ b/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.h
@@ -11,7 +11,7 @@ class HeapObject : public GarbageCollected<HeapObject> { public: - void trace(Visitor*); + void Trace(Visitor*); void clearWeakMembers(Visitor*); private: Member<HeapObject> m_obj1;
diff --git a/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.txt b/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.txt index 02f56a393..8cb90be 100644 --- a/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.txt +++ b/tools/clang/blink_gc_plugin/tests/weak_fields_require_tracing.txt
@@ -1,5 +1,5 @@ weak_fields_require_tracing.cpp:9:1: warning: [blink-gc] Class 'HeapObject' has untraced fields that require tracing. -void HeapObject::trace(Visitor* visitor) +void HeapObject::Trace(Visitor* visitor) ^ ./weak_fields_require_tracing.h:17:5: note: [blink-gc] Untraced field 'm_obj1' declared here: Member<HeapObject> m_obj1;
diff --git a/tools/gn/docs/reference.md b/tools/gn/docs/reference.md index 26ba5c6..b62abbd 100644 --- a/tools/gn/docs/reference.md +++ b/tools/gn/docs/reference.md
@@ -6584,7 +6584,7 @@ build.gn file. "//foo/bar/baz.txt" => "obj/foo/bar" - {{source_target_relative}}\n" + {{source_target_relative}} The path to the source file relative to the target's directory. This will generally be used for replicating the source directory layout in the output directory. This can only be used in actions and it is an error to
diff --git a/tools/gn/substitution_writer.cc b/tools/gn/substitution_writer.cc index 7a3534e..50b1e2d 100644 --- a/tools/gn/substitution_writer.cc +++ b/tools/gn/substitution_writer.cc
@@ -98,7 +98,7 @@ build.gn file. "//foo/bar/baz.txt" => "obj/foo/bar" - {{source_target_relative}}\n" + {{source_target_relative}} The path to the source file relative to the target's directory. This will generally be used for replicating the source directory layout in the output directory. This can only be used in actions and it is an error to
diff --git a/tools/gn/xcode_object.cc b/tools/gn/xcode_object.cc index 039cb52..4f1dcbe 100644 --- a/tools/gn/xcode_object.cc +++ b/tools/gn/xcode_object.cc
@@ -365,8 +365,11 @@ // PBXBuildFile --------------------------------------------------------------- PBXBuildFile::PBXBuildFile(const PBXFileReference* file_reference, - const PBXSourcesBuildPhase* build_phase) - : file_reference_(file_reference), build_phase_(build_phase) { + const PBXSourcesBuildPhase* build_phase, + const CompilerFlags compiler_flag) + : file_reference_(file_reference), + build_phase_(build_phase), + compiler_flag_(compiler_flag) { DCHECK(file_reference_); DCHECK(build_phase_); } @@ -387,6 +390,12 @@ out << indent_str << Reference() << " = {"; PrintProperty(out, rules, "isa", ToString(Class())); PrintProperty(out, rules, "fileRef", file_reference_); + if (compiler_flag_ == CompilerFlags::HELP) { + std::map<std::string, std::string> settings = { + {"COMPILER_FLAGS", "--help"}, + }; + PrintProperty(out, rules, "settings", settings); + } out << "};\n"; } @@ -563,11 +572,11 @@ PBXNativeTarget::~PBXNativeTarget() {} -void PBXNativeTarget::AddFileForIndexing( - const PBXFileReference* file_reference) { +void PBXNativeTarget::AddFileForIndexing(const PBXFileReference* file_reference, + const CompilerFlags compiler_flag) { DCHECK(file_reference); - source_build_phase_->AddBuildFile( - base::MakeUnique<PBXBuildFile>(file_reference, source_build_phase_)); + source_build_phase_->AddBuildFile(base::MakeUnique<PBXBuildFile>( + file_reference, source_build_phase_, compiler_flag)); } PBXObjectClass PBXNativeTarget::Class() const { @@ -612,33 +621,29 @@ PBXProject::~PBXProject() {} +void PBXProject::AddSourceFileToIndexingTarget( + const std::string& navigator_path, + const std::string& source_path, + const CompilerFlags compiler_flag) { + if (!target_for_indexing_) { + AddIndexingTarget(); + } + AddSourceFile(navigator_path, source_path, compiler_flag, + target_for_indexing_); +} + void PBXProject::AddSourceFile(const std::string& navigator_path, - const std::string& source_path) { + const std::string& source_path, + const CompilerFlags compiler_flag, + PBXNativeTarget* target) { PBXFileReference* file_reference = sources_->AddSourceFile(navigator_path, source_path); base::StringPiece ext = FindExtension(&source_path); if (!IsSourceFileForIndexing(ext)) return; - if (!target_for_indexing_) { - PBXAttributes attributes; - attributes["EXECUTABLE_PREFIX"] = ""; - attributes["HEADER_SEARCH_PATHS"] = sources_->path(); - attributes["PRODUCT_NAME"] = name_; - - PBXFileReference* product_reference = static_cast<PBXFileReference*>( - products_->AddChild(base::MakeUnique<PBXFileReference>( - std::string(), name_, "compiled.mach-o.executable"))); - - const char product_type[] = "com.apple.product-type.tool"; - targets_.push_back(base::MakeUnique<PBXNativeTarget>( - name_, std::string(), config_name_, attributes, product_type, name_, - product_reference)); - target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); - } - - DCHECK(target_for_indexing_); - target_for_indexing_->AddFileForIndexing(file_reference); + DCHECK(target); + target->AddFileForIndexing(file_reference, compiler_flag); } void PBXProject::AddAggregateTarget(const std::string& name, @@ -652,6 +657,24 @@ name, shell_script, config_name_, attributes)); } +void PBXProject::AddIndexingTarget() { + DCHECK(!target_for_indexing_); + PBXAttributes attributes; + attributes["EXECUTABLE_PREFIX"] = ""; + attributes["HEADER_SEARCH_PATHS"] = sources_->path(); + attributes["PRODUCT_NAME"] = name_; + + PBXFileReference* product_reference = static_cast<PBXFileReference*>( + products_->AddChild(base::MakeUnique<PBXFileReference>( + std::string(), name_, "compiled.mach-o.executable"))); + + const char product_type[] = "com.apple.product-type.tool"; + targets_.push_back(base::MakeUnique<PBXNativeTarget>( + name_, std::string(), config_name_, attributes, product_type, name_, + product_reference)); + target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); +} + void PBXProject::AddNativeTarget(const std::string& name, const std::string& type, const std::string& output_name,
diff --git a/tools/gn/xcode_object.h b/tools/gn/xcode_object.h index 83a776a..22be61e 100644 --- a/tools/gn/xcode_object.h +++ b/tools/gn/xcode_object.h
@@ -22,6 +22,11 @@ // See https://chromium.googlesource.com/external/gyp/+/master/pylib/gyp/xcodeproj_file.py // for more information on Xcode project file format. +enum class CompilerFlags { + NONE, + HELP, +}; + // PBXObjectClass ------------------------------------------------------------- enum PBXObjectClass { @@ -154,7 +159,8 @@ class PBXBuildFile : public PBXObject { public: PBXBuildFile(const PBXFileReference* file_reference, - const PBXSourcesBuildPhase* build_phase); + const PBXSourcesBuildPhase* build_phase, + const CompilerFlags compiler_flag); ~PBXBuildFile() override; // PXBObject implementation. @@ -165,6 +171,7 @@ private: const PBXFileReference* file_reference_; const PBXSourcesBuildPhase* build_phase_; + const CompilerFlags compiler_flag_; DISALLOW_COPY_AND_ASSIGN(PBXBuildFile); }; @@ -251,7 +258,8 @@ const PBXFileReference* product_reference); ~PBXNativeTarget() override; - void AddFileForIndexing(const PBXFileReference* file_reference); + void AddFileForIndexing(const PBXFileReference* file_reference, + const CompilerFlags compiler_flag); // PBXObject implementation. PBXObjectClass Class() const override; @@ -275,10 +283,16 @@ const PBXAttributes& attributes); ~PBXProject() override; + void AddSourceFileToIndexingTarget(const std::string& navigator_path, + const std::string& source_path, + const CompilerFlags compiler_flag); void AddSourceFile(const std::string& navigator_path, - const std::string& source_path); + const std::string& source_path, + const CompilerFlags compiler_flag, + PBXNativeTarget* target); void AddAggregateTarget(const std::string& name, const std::string& shell_script); + void AddIndexingTarget(); void AddNativeTarget(const std::string& name, const std::string& type, const std::string& output_name,
diff --git a/tools/gn/xcode_writer.cc b/tools/gn/xcode_writer.cc index 07b50e4b..b35cb44 100644 --- a/tools/gn/xcode_writer.cc +++ b/tools/gn/xcode_writer.cc
@@ -353,7 +353,8 @@ for (const SourceFile& source : sources) { std::string source_file = RebasePath(source.value(), source_dir, absolute_source_path); - sources_for_indexing->AddSourceFile(source_file, source_file); + sources_for_indexing->AddSourceFileToIndexingTarget( + source_file, source_file, CompilerFlags::NONE); } projects_.push_back(std::move(sources_for_indexing));
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index bc086e69..3475875 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -12412,6 +12412,15 @@ </summary> </histogram> +<histogram name="Download.ResultsRenderedTime" units="ms"> + <owner>dbeam@chromium.org</owner> + <summary> + Records the time taken to load the downloads Web UI and render (at least) a + screen full of items. This is roughly equivalent to 'time to first + meaningful paint' for the downloads page. + </summary> +</histogram> + <histogram name="Download.SavePackage" enum="DownloadSavePackageEvent"> <owner>asanka@chromium.org</owner> <summary> @@ -71801,7 +71810,7 @@ <histogram name="WebController.ExternalURLRequestBlocking" enum="IOSExternalURLRequestStatus"> - <owner>jyquinn@chromium.org</owner> + <owner>mrefaat@chromium.org</owner> <summary> [iOS] Measures the proportion of external URL requests that originate from a subframe without any user interaction (e.g. an advertisement contains an @@ -73187,6 +73196,30 @@ </summary> </histogram> +<histogram name="WebRTC.Audio.ApmCaptureOutputLevelAverageRms" + units="dBFS (negated)"> + <owner>peah@chromium.org</owner> + <summary> + This histogram reports the average RMS of the signal in the output of + WebRTC's Audio Processing Module, after all audio WebRTC processing. A new + value is reported every 10 seconds, and the average is over the latest + interval. The metric is negated dBFS, meaning that 0 is a full-scale signal, + while 127 corresponds to -127 dBFS (very faint). + </summary> +</histogram> + +<histogram name="WebRTC.Audio.ApmCaptureOutputLevelPeakRms" + units="dBFS (negated)"> + <owner>peah@chromium.org</owner> + <summary> + This histogram reports the peak RMS of the signal in the output of WebRTC's + Audio Processing Module, after all WebRTC audio processing. A new value is + reported every 10 seconds, and the peak is the RMS of the strongest 10 ms + block over the latest interval. The metric is negated dBFS, meaning that 0 + is a full-scale signal, while 127 corresponds to -127 dBFS (very faint). + </summary> +</histogram> + <histogram name="WebRTC.Audio.AverageExcessBufferDelayMs" units="ms"> <owner>hlundin@chromium.org</owner> <summary> @@ -73677,6 +73710,11 @@ <histogram name="WebRTC.PeerConnection.SelectedRtcpMuxPolicy" enum="PeerConnectionRtcpMuxPolicy"> + <obsolete> + Deprecated on Dec 2016. This histogram is used to gauge the risk of making + the change for issue 6030. The decision has been made and this is not needed + any more. + </obsolete> <owner>zhihuang@chromium.org</owner> <summary> Whether the application specified a value for RTCP-mux policy, and if so, @@ -88001,6 +88039,27 @@ <int value="1700" label="AppInstalledEventAddListener"/> <int value="1701" label="AudioContextGetOutputTimestamp"/> <int value="1702" label="V8MediaStreamAudioDestinationNode_Constructor"/> + <int value="1703" label="V8AnalyserNode_Constructor"/> + <int value="1704" label="V8AudioBuffer_Constructor"/> + <int value="1705" label="V8AudioBufferSourceNode_Constructor"/> + <int value="1706" label="V8AudioProcessingEvent_Constructor"/> + <int value="1707" label="V8BiquadFilterNode_Constructor"/> + <int value="1708" label="V8ChannelMergerNode_Constructor"/> + <int value="1709" label="V8ChannelSplitterNode_Constructor"/> + <int value="1710" label="V8ConstantSourceNode_Constructor"/> + <int value="1711" label="V8ConvolverNode_Constructor"/> + <int value="1712" label="V8DelayNode_Constructor"/> + <int value="1713" label="V8DynamicsCompressorNode_Constructor"/> + <int value="1714" label="V8GainNode_Constructor"/> + <int value="1715" label="V8IIRFilterNode_Constructor"/> + <int value="1716" label="V8MediaElementAudioSourceNode_Constructor"/> + <int value="1717" label="V8MediaStreamAudioSourceNode_Constructor"/> + <int value="1718" label="V8OfflineAudioCompletionEvent_Constructor"/> + <int value="1719" label="V8OscillatorNode_Constructor"/> + <int value="1720" label="V8PannerNode_Constructor"/> + <int value="1721" label="V8PeriodicWave_Constructor"/> + <int value="1722" label="V8StereoPannerNode_Constructor"/> + <int value="1723" label="V8WaveShaperNode_Constructor"/> </enum> <enum name="FetchRequestMode" type="int"> @@ -94473,6 +94532,7 @@ <int value="14" label="Animating scroll on main thread"/> <int value="15" label="Has sticky position objects"/> <int value="16" label="Requires hit testing on custom scrollbars"/> + <int value="17" label="Has opacity"/> </enum> <enum name="MakeChromeDefaultResult" type="int"> @@ -99741,6 +99801,7 @@ <int value="1" label="Infobar 'Load original' clicked"/> <int value="2" label="Infobar dismissed by user"/> <int value="3" label="Infobar dismissed by navigation"/> + <int value="4" label="Infobar dismissed by reload"/> </enum> <enum name="PreviewsUserOptedOut" type="int">
diff --git a/ui/ozone/platform/drm/BUILD.gn b/ui/ozone/platform/drm/BUILD.gn index a0d9781..28e335d 100644 --- a/ui/ozone/platform/drm/BUILD.gn +++ b/ui/ozone/platform/drm/BUILD.gn
@@ -11,10 +11,6 @@ visibility = [ "//ui/ozone/*" ] -pkg_config("libdrm") { - packages = [ "libdrm" ] -} - config("drm_atomic") { if (use_drm_atomic) { defines = [ "USE_DRM_ATOMIC" ] @@ -129,6 +125,7 @@ "//services/service_manager/public/cpp:sources", "//services/ui/public/interfaces:constants", "//skia", + "//third_party/libdrm", "//third_party/minigbm", "//ui/base", "//ui/display", @@ -150,8 +147,6 @@ "//ui/platform_window", ] - configs += [ ":libdrm" ] - public_configs = [ "//third_party/khronos:khronos_headers" ] defines = [ "OZONE_IMPLEMENTATION" ] @@ -194,10 +189,9 @@ ":gbm", "//skia", "//testing/gtest", + "//third_party/libdrm", "//ui/gfx", "//ui/ozone:platform", "//ui/ozone/common", ] - - public_configs = [ ":libdrm" ] }
diff --git a/ui/views/view.cc b/ui/views/view.cc index 9222315..3023a1b 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc
@@ -11,6 +11,7 @@ #include <memory> #include <utility> +#include "base/containers/adapters.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" @@ -554,8 +555,7 @@ // weren't changed by the layout manager. If there is no layout manager, we // just propagate the Layout() call down the hierarchy, so whoever receives // the call can take appropriate action. - for (int i = 0, count = child_count(); i < count; ++i) { - View* child = child_at(i); + for (auto* child : children_) { if (child->needs_layout_ || !layout_manager_.get()) { TRACE_EVENT1("views", "View::Layout", "class", child->GetClassName()); child->needs_layout_ = false; @@ -621,8 +621,8 @@ if (id == id_) return const_cast<View*>(this); - for (int i = 0, count = child_count(); i < count; ++i) { - const View* view = child_at(i)->GetViewByID(id); + for (auto* child : children_) { + const View* view = child->GetViewByID(id); if (view) return view; } @@ -651,8 +651,8 @@ if (group_ == group) views->push_back(this); - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->GetViewsInGroup(group, views); + for (auto* child : children_) + child->GetViewsInGroup(group, views); } View* View::GetSelectedViewForGroup(int group) { @@ -917,8 +917,7 @@ // Walk the child Views recursively looking for the View that most // tightly encloses the specified point. - for (int i = child_count() - 1; i >= 0; --i) { - View* child = child_at(i); + for (auto* child : base::Reversed(children_)) { if (!child->visible()) continue; @@ -1437,9 +1436,10 @@ void View::PaintChildren(const ui::PaintContext& context) { TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); - for (int i = 0, count = child_count(); i < count; ++i) - if (!child_at(i)->layer()) - child_at(i)->Paint(context); + for (auto* child : children_) { + if (!child->layer()) + child->Paint(context); + } } void View::OnPaint(gfx::Canvas* canvas) { @@ -1505,8 +1505,8 @@ SetLayerBounds(gfx::Rect(local_point.x(), local_point.y(), width(), height())); } else { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->MoveLayerToParent(parent_layer, local_point); + for (auto* child : children_) + child->MoveLayerToParent(parent_layer, local_point); } } @@ -1522,8 +1522,8 @@ if (layer()) { layer()->SetVisible(ancestor_visible && visible_); } else { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->UpdateChildLayerVisibility(ancestor_visible && visible_); + for (auto* child : children_) + child->UpdateChildLayerVisibility(ancestor_visible && visible_); } } @@ -1531,8 +1531,7 @@ if (layer()) { SetLayerBounds(GetLocalBounds() + offset); } else { - for (int i = 0, count = child_count(); i < count; ++i) { - View* child = child_at(i); + for (auto* child : children_) { child->UpdateChildLayerBounds( offset + gfx::Vector2d(child->GetMirroredX(), child->y())); } @@ -1765,8 +1764,8 @@ } // Children. - for (int i = 0, count = view_with_children->child_count(); i < count; ++i) - result.append(view_with_children->child_at(i)->PrintViewGraph(false)); + for (auto* child : view_with_children->children_) + result.append(child->PrintViewGraph(false)); if (first) result.append("}\n"); @@ -1875,8 +1874,8 @@ } void View::PropagateRemoveNotifications(View* old_parent, View* new_parent) { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->PropagateRemoveNotifications(old_parent, new_parent); + for (auto* child : children_) + child->PropagateRemoveNotifications(old_parent, new_parent); ViewHierarchyChangedDetails details(false, old_parent, this, new_parent); for (View* v = this; v; v = v->parent_) @@ -1885,14 +1884,14 @@ void View::PropagateAddNotifications( const ViewHierarchyChangedDetails& details) { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->PropagateAddNotifications(details); + for (auto* child : children_) + child->PropagateAddNotifications(details); ViewHierarchyChangedImpl(true, details); } void View::PropagateNativeViewHierarchyChanged() { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->PropagateNativeViewHierarchyChanged(); + for (auto* child : children_) + child->PropagateNativeViewHierarchyChanged(); NativeViewHierarchyChanged(); } @@ -1916,16 +1915,16 @@ } void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->PropagateNativeThemeChanged(theme); + for (auto* child : children_) + child->PropagateNativeThemeChanged(theme); OnNativeThemeChanged(theme); } // Size and disposition -------------------------------------------------------- void View::PropagateVisibilityNotifications(View* start, bool is_visible) { - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->PropagateVisibilityNotifications(start, is_visible); + for (auto* child : children_) + child->PropagateVisibilityNotifications(start, is_visible); VisibilityChangedImpl(start, is_visible); } @@ -2106,8 +2105,8 @@ void View::CreateLayer() { // A new layer is being created for the view. So all the layers of the // sub-tree can inherit the visibility of the corresponding view. - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->UpdateChildLayerVisibility(true); + for (auto* child : children_) + child->UpdateChildLayerVisibility(true); SetLayer(base::MakeUnique<ui::Layer>()); layer()->set_delegate(this); @@ -2145,8 +2144,8 @@ return false; } bool result = false; - for (int i = 0, count = child_count(); i < count; ++i) { - if (child_at(i)->UpdateParentLayers()) + for (auto* child : children_) { + if (child->UpdateParentLayers()) result = true; } return result; @@ -2161,8 +2160,8 @@ // necessary to orphan the child layers. return; } - for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->OrphanLayers(); + for (auto* child : children_) + child->OrphanLayers(); } void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) { @@ -2391,20 +2390,20 @@ // System events --------------------------------------------------------------- void View::PropagateThemeChanged() { - for (int i = child_count() - 1; i >= 0; --i) - child_at(i)->PropagateThemeChanged(); + for (auto* child : base::Reversed(children_)) + child->PropagateThemeChanged(); OnThemeChanged(); } void View::PropagateLocaleChanged() { - for (int i = child_count() - 1; i >= 0; --i) - child_at(i)->PropagateLocaleChanged(); + for (auto* child : base::Reversed(children_)) + child->PropagateLocaleChanged(); OnLocaleChanged(); } void View::PropagateDeviceScaleFactorChanged(float device_scale_factor) { - for (int i = child_count() - 1; i >= 0; --i) - child_at(i)->PropagateDeviceScaleFactorChanged(device_scale_factor); + for (auto* child : base::Reversed(children_)) + child->PropagateDeviceScaleFactorChanged(device_scale_factor); // If the view is drawing to the layer, OnDeviceScaleFactorChanged() is called // through LayerDelegate callback.
diff --git a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp index 3ce09e9..72c9f0d 100644 --- a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp +++ b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp
@@ -16,6 +16,7 @@ 'dependencies': [ '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/compiled_resources2.gyp:iron-menubar-behavior-extracted', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], },
diff --git a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.html b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.html index 215b73c..6a6be810 100644 --- a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.html +++ b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.html
@@ -42,7 +42,8 @@ } </style> <cr-profile-avatar-selector-grid id="avatar-grid" - selected="{{selectedAvatarUrl}}" attr-for-selected="data-avatar-url"> + selected="{{selectedAvatarUrl}}" attr-for-selected="data-avatar-url" + ignore-modified-key-events="[[ignoreModifiedKeyEvents]]"> <template is="dom-repeat" items="[[avatars]]"> <paper-button class="avatar" data-avatar-url$="[[item.url]]" title="[[item.label]]"
diff --git a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.js b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.js index c650ff3..9f6f9da 100644 --- a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.js +++ b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.js
@@ -15,6 +15,15 @@ properties: { /** + * The list of profile avatar URLs and labels. + * @type {!Array<!AvatarIcon>} + */ + avatars: { + type: Array, + value: function() { return []; } + }, + + /** * The currently selected profile avatar URL. May be a data URI. * @type {string} */ @@ -23,14 +32,10 @@ notify: true }, - /** - * The list of profile avatar URLs and labels. - * @type {!Array<!AvatarIcon>} - */ - avatars: { - type: Array, - value: function() { return []; } - } + ignoreModifiedKeyEvents: { + type: Boolean, + value: false, + }, }, /**
diff --git a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.html b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.html index ecbbcd7..d915114 100644 --- a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.html +++ b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.html
@@ -1,4 +1,5 @@ <link rel="import" href="chrome://resources/html/assert.html"> +<link rel="import" href="chrome://resources/html/util.html"> <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-menu-behavior/iron-menubar-behavior.html">
diff --git a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js index 8d75dd5..6db2af2 100644 --- a/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js +++ b/ui/webui/resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector_grid.js
@@ -14,6 +14,39 @@ Polymer.IronMenubarBehavior, ], + properties: { + ignoreModifiedKeyEvents: { + type: Boolean, + value: false, + }, + }, + + /** + * Handler that is called when left arrow key is pressed. Overrides + * IronMenubarBehaviorImpl#_onLeftKey and ignores keys likely to be browser + * shortcuts (like Alt+Left for back). + * @param {!CustomEvent} event + * @private + */ + _onLeftKey: function(event) { + if (this.ignoreModifiedKeyEvents && this.hasKeyModifiers_(event)) + return; + Polymer.IronMenubarBehaviorImpl._onLeftKey.call(this, event); + }, + + /** + * Handler that is called when right arrow key is pressed. Overrides + * IronMenubarBehaviorImpl#_onRightKey and ignores keys likely to be browser + * shortcuts (like Alt+Right for forward). + * @param {!CustomEvent} event + * @private + */ + _onRightKey: function(event) { + if (this.ignoreModifiedKeyEvents && this.hasKeyModifiers_(event)) + return; + Polymer.IronMenubarBehaviorImpl._onRightKey.call(this, event); + }, + /** * Handler that is called when the up arrow key is pressed. * @param {CustomEvent} event A key combination event. @@ -44,6 +77,14 @@ }, /** + * @param {!CustomEvent} event + * @return {boolean} Whether the key event has modifier keys pressed. + */ + hasKeyModifiers_: function(event) { + return hasKeyModifiers(assertInstanceof(event.detail.keyboardEvent, Event)); + }, + + /** * Focuses an item on the same column as the currently focused item and on a * row below or above the focus row by the given offset. Focus wraps if * necessary.
diff --git a/ui/webui/resources/js/cr/ui/focus_row.js b/ui/webui/resources/js/cr/ui/focus_row.js index 432c8a6..415c1ea9 100644 --- a/ui/webui/resources/js/cr/ui/focus_row.js +++ b/ui/webui/resources/js/cr/ui/focus_row.js
@@ -254,7 +254,7 @@ }, /** - * @param {Event} e The keydown event. + * @param {!Event} e The keydown event. * @private */ onKeydown_: function(e) { @@ -266,7 +266,7 @@ if (this.delegate && this.delegate.onKeydown(this, e)) return; - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) + if (hasKeyModifiers(e)) return; var index = -1;
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js index 9f29967..75ea9da6 100644 --- a/ui/webui/resources/js/util.js +++ b/ui/webui/resources/js/util.js
@@ -500,3 +500,11 @@ }); }); } + +/** + * @param {!Event} e + * @return {boolean} Whether a modifier key was down when processing |e|. + */ +function hasKeyModifiers(e) { + return !!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey); +}