diff --git a/BUILD.gn b/BUILD.gn index 7903e89..50ca993 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -434,7 +434,7 @@ ] } - if (is_android || is_win || (is_linux && !is_chromeos)) { + if (is_android || is_win || is_linux) { deps += [ "//base:build_utf8_validator_tables", "//base:check_example", @@ -468,8 +468,6 @@ "//courgette:courgette_fuzz", "//courgette:courgette_minimal_tool", "//courgette:courgette_unittests", - "//media/cast:generate_barcode_video", - "//media/cast:generate_timecode_audio", "//net:crash_cache", "//net:crl_set_dump", "//net:dns_fuzz_stub", @@ -485,6 +483,12 @@ "//third_party/leveldatabase:env_chromium_unittests", "//third_party/libaddressinput:libaddressinput_unittests", ] + if (!is_chromeos) { + deps += [ + "//media/cast:generate_barcode_video", + "//media/cast:generate_timecode_audio", + ] + } } if (!is_android && !is_linux) { # TODO(dpranke): Re-enable this once @@ -663,7 +667,7 @@ ] } - if (is_linux && !is_chromeos && !is_chromecast) { + if (is_linux && !is_chromecast) { # TODO(GYP): Figure out if any of these should be in gn_all # and figure out how cross-platform they are deps += [ @@ -679,7 +683,6 @@ "//components/rappor:unit_tests", "//components/sessions:unit_tests", "//media/blink:media_blink_unittests", - "//media/cast:udp_proxy", "//native_client/src/trusted/debug_stub:gdb_rsp_unittest", "//storage/browser:dump_file_system", "//third_party/angle:libANGLE", @@ -731,6 +734,9 @@ "//ui/views/examples:views_examples_exe", ] + if (!is_chromeos) { + deps += [ "//media/cast:udp_proxy" ] + } if (target_cpu == "x86" || target_cpu == "x64") { if (!is_android) { deps += [ "//chrome/test:load_library_perf_tests" ]
diff --git a/DEPS b/DEPS index aa05d1f..8287135a 100644 --- a/DEPS +++ b/DEPS
@@ -39,11 +39,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': '4803f9715ff02b54a8ebae24167c490181d7cc3f', + 'skia_revision': 'aebd0fd32f8fde610de03b4f1e6d11ce24bfb73d', # 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': 'bcf6e72360119316c0d158caf4b743a7c62ac6ba', + 'v8_revision': '3bae05ec251a080f4967cdeeb2082a7e787a9345', # 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. @@ -83,7 +83,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling NaCl # and whatever else without interference from each other. - 'nacl_revision': '4eebc9bc011b2ea84c225a4b47068cb98790646e', + 'nacl_revision': 'dfb29536c5d4e8e8c26074b7bf9f982798bb97de', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling dEQP # and whatever else without interference from each other. @@ -225,7 +225,7 @@ Var('chromium_git') + '/native_client/src/third_party/scons-2.0.1.git' + '@' + '1c1550e17fc26355d08627fbdec13d8291227067', 'src/third_party/webrtc': - Var('chromium_git') + '/external/webrtc/trunk/webrtc.git' + '@' + '495f1ae055d27cfe096a2f7e47ff4a1f57724b5f', # commit position 12784 + Var('chromium_git') + '/external/webrtc/trunk/webrtc.git' + '@' + '26d5d92cd58ea625f10a61ba6dfa4473a05c8128', # commit position 12795 'src/third_party/openmax_dl': Var('chromium_git') + '/external/webrtc/deps/third_party/openmax.git' + '@' + Var('openmax_dl_revision'),
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 7672a57e..10f1fd00 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -1132,6 +1132,7 @@ r"notification_event_dispatcher_impl\.cc$", r"^content[\\\/]common[\\\/]gpu[\\\/]client[\\\/]" r"gl_helper_benchmark\.cc$", + r"^courgette[\\\/]courgette_minimal_tool\.cc$", r"^courgette[\\\/]courgette_tool\.cc$", r"^extensions[\\\/]renderer[\\\/]logging_native_handler\.cc$", r"^ipc[\\\/]ipc_logging\.cc$",
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc index 584122e..a717f12c6 100644 --- a/android_webview/browser/aw_content_browser_client.cc +++ b/android_webview/browser/aw_content_browser_client.cc
@@ -481,6 +481,13 @@ return false; } +bool AwContentBrowserClient::IsPepperVpnProviderAPIAllowed( + content::BrowserContext* browser_context, + const GURL& url) { + NOTREACHED() << "Android WebView does not support plugins"; + return false; +} + void AwContentBrowserClient::GetAdditionalMappedFilesForChildProcess( const base::CommandLine& command_line, int child_process_id,
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h index 414de96..c0648d2 100644 --- a/android_webview/browser/aw_content_browser_client.h +++ b/android_webview/browser/aw_content_browser_client.h
@@ -120,6 +120,8 @@ const GURL& url, bool private_api, const content::SocketPermissionRequest* params) override; + bool IsPepperVpnProviderAPIAllowed(content::BrowserContext* browser_context, + const GURL& url) override; void GetAdditionalMappedFilesForChildProcess( const base::CommandLine& command_line, int child_process_id,
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc index 933b28c..5b652b2 100644 --- a/android_webview/browser/browser_view_renderer.cc +++ b/android_webview/browser/browser_view_renderer.cc
@@ -92,7 +92,7 @@ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) : client_(client), ui_task_runner_(ui_task_runner), - compositor_frame_consumer_(nullptr), + current_compositor_frame_consumer_(nullptr), compositor_(NULL), is_paused_(false), view_visible_(false), @@ -110,24 +110,22 @@ BrowserViewRenderer::~BrowserViewRenderer() { DCHECK(compositor_map_.empty()); - SetCompositorFrameConsumer(nullptr); + SetCurrentCompositorFrameConsumer(nullptr); + while (compositor_frame_consumers_.size()) { + RemoveCompositorFrameConsumer(*compositor_frame_consumers_.begin()); + } } -void BrowserViewRenderer::SetCompositorFrameConsumer( +void BrowserViewRenderer::SetCurrentCompositorFrameConsumer( CompositorFrameConsumer* compositor_frame_consumer) { - if (compositor_frame_consumer == compositor_frame_consumer_) { + if (compositor_frame_consumer == current_compositor_frame_consumer_) { return; } - if (compositor_frame_consumer_) { - compositor_frame_consumer_->DeleteHardwareRendererOnUI(); - ReturnUnusedResource( - compositor_frame_consumer_->PassUncommittedFrameOnUI()); - ReturnResourceFromParent(compositor_frame_consumer_); - compositor_frame_consumer_->SetCompositorFrameProducer(nullptr); - } - compositor_frame_consumer_ = compositor_frame_consumer; - if (compositor_frame_consumer_) { - compositor_frame_consumer_->SetCompositorFrameProducer(this); + current_compositor_frame_consumer_ = compositor_frame_consumer; + if (current_compositor_frame_consumer_) { + compositor_frame_consumers_.insert(current_compositor_frame_consumer_); + current_compositor_frame_consumer_->SetCompositorFrameProducer(this); + OnParentDrawConstraintsUpdated(current_compositor_frame_consumer_); } } @@ -200,22 +198,23 @@ } bool BrowserViewRenderer::OnDrawHardware() { - DCHECK(compositor_frame_consumer_); + DCHECK(current_compositor_frame_consumer_); TRACE_EVENT0("android_webview", "BrowserViewRenderer::OnDrawHardware"); - compositor_frame_consumer_->InitializeHardwareDrawIfNeededOnUI(); + current_compositor_frame_consumer_->InitializeHardwareDrawIfNeededOnUI(); if (!CanOnDraw()) { return false; } - compositor_frame_consumer_->SetScrollOffsetOnUI(last_on_draw_scroll_offset_); + current_compositor_frame_consumer_->SetScrollOffsetOnUI( + last_on_draw_scroll_offset_); hardware_enabled_ = true; external_draw_constraints_ = - compositor_frame_consumer_->GetParentDrawConstraintsOnUI(); + current_compositor_frame_consumer_->GetParentDrawConstraintsOnUI(); - ReturnResourceFromParent(compositor_frame_consumer_); + ReturnResourceFromParent(current_compositor_frame_consumer_); UpdateMemoryPolicy(); gfx::Size surface_size(size_); @@ -244,7 +243,7 @@ if (!frame.frame.get()) { TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", TRACE_EVENT_SCOPE_THREAD); - return compositor_frame_consumer_->HasFrameOnUI(); + return current_compositor_frame_consumer_->HasFrameOnUI(); } std::unique_ptr<ChildFrame> child_frame = base::WrapUnique(new ChildFrame( @@ -253,22 +252,37 @@ transform_for_tile_priority, offscreen_pre_raster_, external_draw_constraints_.is_layer)); - ReturnUnusedResource(compositor_frame_consumer_->PassUncommittedFrameOnUI()); - compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame)); + ReturnUnusedResource( + current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); + current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame)); return true; } -void BrowserViewRenderer::OnParentDrawConstraintsUpdated() { - DCHECK(compositor_frame_consumer_); +void BrowserViewRenderer::OnParentDrawConstraintsUpdated( + CompositorFrameConsumer* compositor_frame_consumer) { + DCHECK(compositor_frame_consumer); + if (compositor_frame_consumer != current_compositor_frame_consumer_) + return; PostInvalidate(); external_draw_constraints_ = - compositor_frame_consumer_->GetParentDrawConstraintsOnUI(); + current_compositor_frame_consumer_->GetParentDrawConstraintsOnUI(); UpdateMemoryPolicy(); } -void BrowserViewRenderer::OnCompositorFrameConsumerWillDestroy() { - DCHECK(compositor_frame_consumer_); - SetCompositorFrameConsumer(nullptr); +void BrowserViewRenderer::RemoveCompositorFrameConsumer( + CompositorFrameConsumer* compositor_frame_consumer) { + DCHECK(compositor_frame_consumers_.count(compositor_frame_consumer)); + compositor_frame_consumers_.erase(compositor_frame_consumer); + if (current_compositor_frame_consumer_ == compositor_frame_consumer) { + SetCurrentCompositorFrameConsumer(nullptr); + } + + // At this point the compositor frame consumer has to hand back all resources + // to the child compositor. + compositor_frame_consumer->DeleteHardwareRendererOnUI(); + ReturnUnusedResource(compositor_frame_consumer->PassUncommittedFrameOnUI()); + ReturnResourceFromParent(compositor_frame_consumer); + compositor_frame_consumer->SetCompositorFrameProducer(nullptr); } void BrowserViewRenderer::ReturnUnusedResource( @@ -435,11 +449,10 @@ } void BrowserViewRenderer::ReleaseHardware() { - if (compositor_frame_consumer_) { - ReturnUnusedResource( - compositor_frame_consumer_->PassUncommittedFrameOnUI()); - ReturnResourceFromParent(compositor_frame_consumer_); - DCHECK(compositor_frame_consumer_->ReturnedResourcesEmptyOnUI()); + for (auto compositor_frame_consumer : compositor_frame_consumers_) { + ReturnUnusedResource(compositor_frame_consumer->PassUncommittedFrameOnUI()); + ReturnResourceFromParent(compositor_frame_consumer); + DCHECK(compositor_frame_consumer->ReturnedResourcesEmptyOnUI()); } hardware_enabled_ = false; UpdateMemoryPolicy();
diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h index d367c46..acc7888 100644 --- a/android_webview/browser/browser_view_renderer.h +++ b/android_webview/browser/browser_view_renderer.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <map> +#include <set> #include "android_webview/browser/compositor_frame_producer.h" #include "android_webview/browser/parent_compositor_draw_constraints.h" @@ -52,9 +53,11 @@ void RegisterWithWebContents(content::WebContents* web_contents); - // The BrowserViewRenderer client is responsible for ensuring that the - // CompositorFrameConsumer has been set correctly via this method. - void SetCompositorFrameConsumer( + // The BrowserViewRenderer client is responsible for ensuring that + // the current compositor frame consumer has been set correctly via + // this method. The consumer is added to the set of registered + // consumers if it is not already registered. + void SetCurrentCompositorFrameConsumer( CompositorFrameConsumer* compositor_frame_consumer); // Called before either OnDrawHardware or OnDrawSoftware to set the view @@ -123,8 +126,10 @@ const gfx::Vector2dF& current_fling_velocity) override; // CompositorFrameProducer overrides - void OnParentDrawConstraintsUpdated() override; - void OnCompositorFrameConsumerWillDestroy() override; + void OnParentDrawConstraintsUpdated( + CompositorFrameConsumer* compositor_frame_consumer) override; + void RemoveCompositorFrameConsumer( + CompositorFrameConsumer* compositor_frame_consumer) override; private: void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); @@ -151,7 +156,8 @@ BrowserViewRendererClient* const client_; const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; - CompositorFrameConsumer* compositor_frame_consumer_; + CompositorFrameConsumer* current_compositor_frame_consumer_; + std::set<CompositorFrameConsumer*> compositor_frame_consumers_; // The current compositor that's owned by the current RVH. content::SynchronousCompositor* compositor_;
diff --git a/android_webview/browser/browser_view_renderer_unittest.cc b/android_webview/browser/browser_view_renderer_unittest.cc index 0eba0a8..1bcfd0f 100644 --- a/android_webview/browser/browser_view_renderer_unittest.cc +++ b/android_webview/browser/browser_view_renderer_unittest.cc
@@ -13,6 +13,7 @@ #include "android_webview/browser/test/rendering_test.h" #include "base/location.h" #include "base/single_thread_task_runner.h" +#include "base/threading/thread_task_runner_handle.h" #include "cc/output/compositor_frame.h" #include "content/public/test/test_synchronous_compositor_android.h" @@ -123,6 +124,10 @@ ParentCompositorDrawConstraints constraints = GetCompositorFrameConsumer()->GetParentDrawConstraintsOnUI(); switch (on_draw_count_) { + case 0u: + // This OnParentDrawConstraintsUpdated is generated by + // connecting the compositor frame consumer to the producer. + break; case 1u: EXPECT_TRUE(DrawConstraintsEquals(constraints, new_constraints_)); break; @@ -257,21 +262,9 @@ int frame_number) override { static const FrameInfo infos[] = { // First output surface. - {0u, 1u}, - {0u, 1u}, - {0u, 2u}, - {0u, 2u}, - {0u, 3u}, - {0u, 3u}, - {0u, 4u}, + {0u, 1u}, {0u, 1u}, {0u, 2u}, {0u, 2u}, {0u, 3u}, {0u, 3u}, {0u, 4u}, // Second output surface. - {1u, 1u}, - {1u, 1u}, - {1u, 2u}, - {1u, 2u}, - {1u, 3u}, - {1u, 3u}, - {1u, 4u}, + {1u, 1u}, {1u, 1u}, {1u, 2u}, {1u, 2u}, {1u, 3u}, {1u, 3u}, {1u, 4u}, }; if (frame_number >= static_cast<int>(arraysize(infos))) { return nullptr; @@ -334,7 +327,7 @@ void CheckResults() override { OutputSurfaceResourceCountMap resource_counts; - render_thread_manager_.reset(); + functor_.reset(); // Make sure resources for the last frame are returned. EXPECT_EQ(expected_return_count_, GetReturnedResourceCounts()); EndTest(); @@ -346,4 +339,67 @@ RENDERING_TEST_F(RenderThreadManagerDeletionTest); +class RenderThreadManagerSwitchTest : public ResourceRenderingTest { + std::unique_ptr<content::SynchronousCompositor::Frame> GetFrame( + int frame_number) override { + switch (frame_number) { + case 0: { + // Draw a frame with initial RTM. + break; + } + case 1: { + // Switch to new RTM. + std::unique_ptr<FakeFunctor> functor(new FakeFunctor); + functor->Init(window_.get(), + base::WrapUnique(new RenderThreadManager( + functor.get(), base::ThreadTaskRunnerHandle::Get()))); + browser_view_renderer_->SetCurrentCompositorFrameConsumer( + functor->GetCompositorFrameConsumer()); + saved_functor_ = std::move(functor_); + functor_ = std::move(functor); + break; + } + case 2: { + // Draw a frame with the new RTM, but also redraw the initial RTM. + window_->RequestDrawGL(saved_functor_.get()); + break; + } + case 3: { + // Switch back to the initial RTM, allowing the new RTM to be destroyed. + functor_ = std::move(saved_functor_); + browser_view_renderer_->SetCurrentCompositorFrameConsumer( + functor_->GetCompositorFrameConsumer()); + break; + } + default: + return nullptr; + } + + const uint32_t output_surface_id = 0u; + const cc::ResourceId resource_id = + static_cast<cc::ResourceId>(frame_number); + + std::unique_ptr<content::SynchronousCompositor::Frame> frame( + new content::SynchronousCompositor::Frame); + frame->output_surface_id = output_surface_id; + frame->frame = ConstructFrame(resource_id); + ++expected_return_count_[output_surface_id][resource_id]; + return frame; + } + + void CheckResults() override { + OutputSurfaceResourceCountMap resource_counts; + functor_.reset(); + // Make sure resources for all frames are returned. + EXPECT_EQ(expected_return_count_, GetReturnedResourceCounts()); + EndTest(); + } + + private: + std::unique_ptr<FakeFunctor> saved_functor_; + OutputSurfaceResourceCountMap expected_return_count_; +}; + +RENDERING_TEST_F(RenderThreadManagerSwitchTest); + } // namespace android_webview
diff --git a/android_webview/browser/compositor_frame_consumer.h b/android_webview/browser/compositor_frame_consumer.h index 4542d2aa..31118680 100644 --- a/android_webview/browser/compositor_frame_consumer.h +++ b/android_webview/browser/compositor_frame_consumer.h
@@ -27,6 +27,13 @@ }; using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; + // A CompositorFrameConsumer may be registered with at most one + // CompositorFrameProducer. + // The producer is responsible for managing the relationship with its + // consumers. The only exception to this is when a consumer is explicitly + // destroyed, at which point it needs to inform its producer. + // In order to register a consumer with a new producer, the current producer + // must unregister the consumer, and call SetCompositorProducer(nullptr). virtual void SetCompositorFrameProducer( CompositorFrameProducer* compositor_frame_producer) = 0; virtual void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset) = 0;
diff --git a/android_webview/browser/compositor_frame_producer.h b/android_webview/browser/compositor_frame_producer.h index b27b611a..8defed5 100644 --- a/android_webview/browser/compositor_frame_producer.h +++ b/android_webview/browser/compositor_frame_producer.h
@@ -11,8 +11,10 @@ class CompositorFrameProducer { public: - virtual void OnParentDrawConstraintsUpdated() = 0; - virtual void OnCompositorFrameConsumerWillDestroy() = 0; + virtual void OnParentDrawConstraintsUpdated( + CompositorFrameConsumer* compositor_frame_consumer) = 0; + virtual void RemoveCompositorFrameConsumer( + CompositorFrameConsumer* compositor_frame_consumer) = 0; protected: virtual ~CompositorFrameProducer() {}
diff --git a/android_webview/browser/render_thread_manager.cc b/android_webview/browser/render_thread_manager.cc index c2c9c6e0..1bb44aa7 100644 --- a/android_webview/browser/render_thread_manager.cc +++ b/android_webview/browser/render_thread_manager.cc
@@ -106,7 +106,7 @@ RenderThreadManager::~RenderThreadManager() { DCHECK(ui_loop_->BelongsToCurrentThread()); if (compositor_frame_producer_) { - compositor_frame_producer_->OnCompositorFrameConsumerWillDestroy(); + compositor_frame_producer_->RemoveCompositorFrameConsumer(this); } DCHECK(!hardware_renderer_.get()); } @@ -158,7 +158,7 @@ void RenderThreadManager::UpdateParentDrawConstraintsOnUI() { DCHECK(ui_loop_->BelongsToCurrentThread()); if (compositor_frame_producer_) { - compositor_frame_producer_->OnParentDrawConstraintsUpdated(); + compositor_frame_producer_->OnParentDrawConstraintsUpdated(this); } } @@ -362,6 +362,9 @@ void RenderThreadManager::SetCompositorFrameProducer( CompositorFrameProducer* compositor_frame_producer) { + DCHECK(compositor_frame_producer == compositor_frame_producer_ || + compositor_frame_producer_ == nullptr || + compositor_frame_producer == nullptr); compositor_frame_producer_ = compositor_frame_producer; }
diff --git a/android_webview/browser/test/fake_window.cc b/android_webview/browser/test/fake_window.cc index 4b63f74..855a5a12 100644 --- a/android_webview/browser/test/fake_window.cc +++ b/android_webview/browser/test/fake_window.cc
@@ -42,7 +42,6 @@ }; FakeWindow::FakeWindow(BrowserViewRenderer* view, - const DrawGLCallback& draw_gl, WindowHooks* hooks, gfx::Rect location) : view_(view), @@ -50,7 +49,6 @@ surface_size_(100, 100), location_(location), on_draw_hardware_pending_(false), - draw_gl_(draw_gl), context_current_(false), weak_ptr_factory_(this) { CheckCurrentlyOnUIThread(); @@ -78,34 +76,34 @@ view_->OnDetachedFromWindow(); } -void FakeWindow::RequestInvokeGL(bool wait_for_completion) { +void FakeWindow::RequestInvokeGL(FakeFunctor* functor, + bool wait_for_completion) { CheckCurrentlyOnUIThread(); base::WaitableEvent completion(true, false); render_thread_loop_->PostTask( FROM_HERE, - base::Bind(&FakeWindow::ProcessFunctorOnRT, base::Unretained(this), - wait_for_completion ? &completion : nullptr)); + base::Bind(&FakeWindow::InvokeFunctorOnRT, base::Unretained(this), + functor, wait_for_completion ? &completion : nullptr)); if (wait_for_completion) completion.Wait(); } -void FakeWindow::ProcessFunctorOnRT(base::WaitableEvent* sync) { +void FakeWindow::InvokeFunctorOnRT(FakeFunctor* functor, + base::WaitableEvent* sync) { CheckCurrentlyOnRT(); - AwDrawGLInfo process_info; - process_info.version = kAwDrawGLInfoVersion; - process_info.mode = AwDrawGLInfo::kModeProcess; - - hooks_->WillProcessOnRT(); - { - ScopedMakeCurrent make_current(this); - draw_gl_.Run(&process_info); - } - hooks_->DidProcessOnRT(); - + ScopedMakeCurrent make_current(this); + functor->Invoke(hooks_); if (sync) sync->Signal(); } +void FakeWindow::RequestDrawGL(FakeFunctor* functor) { + CheckCurrentlyOnUIThread(); + render_thread_loop_->PostTask(FROM_HERE, + base::Bind(&FakeWindow::ProcessDrawOnRT, + base::Unretained(this), functor)); +} + void FakeWindow::PostInvalidate() { CheckCurrentlyOnUIThread(); if (on_draw_hardware_pending_) @@ -125,48 +123,35 @@ hooks_->WillOnDraw(); bool success = view_->OnDrawHardware(); hooks_->DidOnDraw(success); - if (success) { + FakeFunctor* functor = hooks_->GetFunctor(); + if (success && functor) { CreateRenderThreadIfNeeded(); base::WaitableEvent completion(true, false); render_thread_loop_->PostTask( FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, - base::Unretained(this), &completion)); + base::Unretained(this), functor, &completion)); completion.Wait(); } } -void FakeWindow::DrawFunctorOnRT(base::WaitableEvent* sync) { +void FakeWindow::ProcessSyncOnRT(FakeFunctor* functor, + base::WaitableEvent* sync) { CheckCurrentlyOnRT(); - // Ok to access UI functions until sync is signalled. - gfx::Rect location = location_; - { - AwDrawGLInfo process_info; - process_info.version = kAwDrawGLInfoVersion; - process_info.mode = AwDrawGLInfo::kModeSync; - - hooks_->WillSyncOnRT(); - draw_gl_.Run(&process_info); - hooks_->DidSyncOnRT(); - } + functor->Sync(location_, hooks_); sync->Signal(); +} - AwDrawGLInfo draw_info; - draw_info.version = kAwDrawGLInfoVersion; - draw_info.mode = AwDrawGLInfo::kModeDraw; - draw_info.clip_left = location.x(); - draw_info.clip_top = location.y(); - draw_info.clip_right = location.x() + location.width(); - draw_info.clip_bottom = location.y() + location.height(); +void FakeWindow::ProcessDrawOnRT(FakeFunctor* functor) { + CheckCurrentlyOnRT(); + ScopedMakeCurrent make_current(this); + functor->Draw(hooks_); +} - if (!hooks_->WillDrawOnRT(&draw_info)) - return; - - { - ScopedMakeCurrent make_current(this); - draw_gl_.Run(&draw_info); - } - hooks_->DidDrawOnRT(); +void FakeWindow::DrawFunctorOnRT(FakeFunctor* functor, + base::WaitableEvent* sync) { + ProcessSyncOnRT(functor, sync); + ProcessDrawOnRT(functor); } void FakeWindow::CheckCurrentlyOnUIThread() { @@ -216,4 +201,69 @@ DCHECK(rt_checker_.CalledOnValidSequencedThread()); } +FakeFunctor::FakeFunctor() : window_(nullptr) {} + +FakeFunctor::~FakeFunctor() { + render_thread_manager_.reset(); +} + +void FakeFunctor::Init( + FakeWindow* window, + std::unique_ptr<RenderThreadManager> render_thread_manager) { + window_ = window; + render_thread_manager_ = std::move(render_thread_manager); + callback_ = base::Bind(&RenderThreadManager::DrawGL, + base::Unretained(render_thread_manager_.get())); +} + +void FakeFunctor::Sync(const gfx::Rect& location, + WindowHooks* hooks) { + DCHECK(!callback_.is_null()); + committed_location_ = location; + AwDrawGLInfo sync_info; + sync_info.version = kAwDrawGLInfoVersion; + sync_info.mode = AwDrawGLInfo::kModeSync; + hooks->WillSyncOnRT(); + callback_.Run(&sync_info); + hooks->DidSyncOnRT(); +} + +void FakeFunctor::Draw(WindowHooks* hooks) { + DCHECK(!callback_.is_null()); + AwDrawGLInfo draw_info; + draw_info.version = kAwDrawGLInfoVersion; + draw_info.mode = AwDrawGLInfo::kModeDraw; + draw_info.clip_left = committed_location_.x(); + draw_info.clip_top = committed_location_.y(); + draw_info.clip_right = committed_location_.x() + committed_location_.width(); + draw_info.clip_bottom = + committed_location_.y() + committed_location_.height(); + if (!hooks->WillDrawOnRT(&draw_info)) + return; + callback_.Run(&draw_info); + hooks->DidDrawOnRT(); +} + +CompositorFrameConsumer* FakeFunctor::GetCompositorFrameConsumer() { + return render_thread_manager_.get(); +} + +void FakeFunctor::Invoke(WindowHooks* hooks) { + DCHECK(!callback_.is_null()); + AwDrawGLInfo invoke_info; + invoke_info.version = kAwDrawGLInfoVersion; + invoke_info.mode = AwDrawGLInfo::kModeProcess; + hooks->WillProcessOnRT(); + callback_.Run(&invoke_info); + hooks->DidProcessOnRT(); +} + +bool FakeFunctor::RequestInvokeGL(bool wait_for_completion) { + DCHECK(window_); + window_->RequestInvokeGL(this, wait_for_completion); + return true; +} + +void FakeFunctor::DetachFunctorFromView() {} + } // namespace android_webview
diff --git a/android_webview/browser/test/fake_window.h b/android_webview/browser/test/fake_window.h index 5302f60..603d5531 100644 --- a/android_webview/browser/test/fake_window.h +++ b/android_webview/browser/test/fake_window.h
@@ -7,6 +7,7 @@ #include <map> +#include "android_webview/browser/render_thread_manager_client.h" #include "android_webview/public/browser/draw_gl.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" @@ -24,6 +25,9 @@ namespace android_webview { class BrowserViewRenderer; +class CompositorFrameConsumer; +class FakeFunctor; +class RenderThreadManager; class WindowHooks { public: @@ -31,6 +35,7 @@ virtual void WillOnDraw() = 0; virtual void DidOnDraw(bool success) = 0; + virtual FakeFunctor* GetFunctor() = 0; virtual void WillSyncOnRT() = 0; virtual void DidSyncOnRT() = 0; @@ -42,21 +47,17 @@ class FakeWindow { public: - using DrawGLCallback = base::Callback<void(AwDrawGLInfo*)>; - - FakeWindow(BrowserViewRenderer* view, - const DrawGLCallback& draw_gl, - WindowHooks* hooks, - gfx::Rect location); + FakeWindow(BrowserViewRenderer* view, WindowHooks* hooks, gfx::Rect location); ~FakeWindow(); void Detach(); - // BrowserViewRendererClient methods. - void RequestInvokeGL(bool wait_for_completion); + void RequestInvokeGL(FakeFunctor* functor, bool wait_for_completion); void PostInvalidate(); const gfx::Size& surface_size() { return surface_size_; } + void RequestDrawGL(FakeFunctor* functor); + private: class ScopedMakeCurrent; @@ -66,8 +67,10 @@ void InitializeOnRT(base::WaitableEvent* sync); void DestroyOnRT(base::WaitableEvent* sync); - void ProcessFunctorOnRT(base::WaitableEvent* sync); - void DrawFunctorOnRT(base::WaitableEvent* sync); + void InvokeFunctorOnRT(FakeFunctor* functor, base::WaitableEvent* sync); + void ProcessSyncOnRT(FakeFunctor* functor, base::WaitableEvent* sync); + void ProcessDrawOnRT(FakeFunctor* functor); + void DrawFunctorOnRT(FakeFunctor* functor, base::WaitableEvent* sync); void CheckCurrentlyOnRT(); // const so can be used on both threads. @@ -83,7 +86,6 @@ // Render thread members. std::unique_ptr<base::Thread> render_thread_; base::SequenceChecker rt_checker_; - DrawGLCallback draw_gl_; scoped_refptr<base::SingleThreadTaskRunner> render_thread_loop_; scoped_refptr<gfx::GLSurface> surface_; scoped_refptr<gfx::GLContext> context_; @@ -94,6 +96,32 @@ DISALLOW_COPY_AND_ASSIGN(FakeWindow); }; +class FakeFunctor : public RenderThreadManagerClient { + public: + using DrawGLCallback = base::Callback<void(AwDrawGLInfo*)>; + + FakeFunctor(); + ~FakeFunctor() override; + + void Init(FakeWindow* window, + std::unique_ptr<RenderThreadManager> render_thread_manager); + void Sync(const gfx::Rect& location, WindowHooks* hooks); + void Draw(WindowHooks* hooks); + void Invoke(WindowHooks* hooks); + + CompositorFrameConsumer* GetCompositorFrameConsumer(); + + // RenderThreadManagerClient overrides + bool RequestInvokeGL(bool wait_for_completion) override; + void DetachFunctorFromView() override; + + private: + FakeWindow* window_; + DrawGLCallback callback_; + std::unique_ptr<RenderThreadManager> render_thread_manager_; + gfx::Rect committed_location_; +}; + } // namespace android_webview #endif // ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_
diff --git a/android_webview/browser/test/rendering_test.cc b/android_webview/browser/test/rendering_test.cc index a3b78aac..1c92f34e 100644 --- a/android_webview/browser/test/rendering_test.cc +++ b/android_webview/browser/test/rendering_test.cc
@@ -29,8 +29,10 @@ ~TestBrowserViewRenderer() override {} - void OnParentDrawConstraintsUpdated() override { - BrowserViewRenderer::OnParentDrawConstraintsUpdated(); + void OnParentDrawConstraintsUpdated( + CompositorFrameConsumer* compositor_frame_consumer) override { + BrowserViewRenderer::OnParentDrawConstraintsUpdated( + compositor_frame_consumer); rendering_test_->OnParentDrawConstraintsUpdated(); } @@ -51,19 +53,23 @@ void RenderingTest::SetUpTestHarness() { DCHECK(!browser_view_renderer_.get()); - DCHECK(!render_thread_manager_.get()); - render_thread_manager_.reset( - new RenderThreadManager(this, base::ThreadTaskRunnerHandle::Get())); - browser_view_renderer_.reset(new TestBrowserViewRenderer( - this, base::ThreadTaskRunnerHandle::Get())); - browser_view_renderer_->SetCompositorFrameConsumer( - render_thread_manager_.get()); + DCHECK(!functor_.get()); + browser_view_renderer_.reset( + new TestBrowserViewRenderer(this, base::ThreadTaskRunnerHandle::Get())); InitializeCompositor(); - Attach(); + std::unique_ptr<FakeWindow> window( + new FakeWindow(browser_view_renderer_.get(), this, gfx::Rect(100, 100))); + functor_.reset(new FakeFunctor); + functor_->Init(window.get(), + base::WrapUnique(new RenderThreadManager( + functor_.get(), base::ThreadTaskRunnerHandle::Get()))); + browser_view_renderer_->SetCurrentCompositorFrameConsumer( + functor_->GetCompositorFrameConsumer()); + window_ = std::move(window); } CompositorFrameConsumer* RenderingTest::GetCompositorFrameConsumer() { - return render_thread_manager_.get(); + return functor_->GetCompositorFrameConsumer(); } CompositorFrameProducer* RenderingTest::GetCompositorFrameProducer() { @@ -77,14 +83,6 @@ compositor_->SetClient(browser_view_renderer_.get()); } -void RenderingTest::Attach() { - window_.reset( - new FakeWindow(browser_view_renderer_.get(), - base::Bind(&RenderThreadManager::DrawGL, - base::Unretained(render_thread_manager_.get())), - this, gfx::Rect(100, 100))); -} - void RenderingTest::RunTest() { SetUpTestHarness(); @@ -130,16 +128,15 @@ return compositor_frame; } +FakeFunctor* RenderingTest::GetFunctor() { + return functor_.get(); +} + void RenderingTest::WillOnDraw() { DCHECK(compositor_); compositor_->SetHardwareFrame(0u, ConstructEmptyFrame()); } -bool RenderingTest::RequestInvokeGL(bool wait_for_completion) { - window_->RequestInvokeGL(wait_for_completion); - return true; -} - bool RenderingTest::WillDrawOnRT(AwDrawGLInfo* draw_info) { draw_info->width = window_->surface_size().width(); draw_info->height = window_->surface_size().height(); @@ -156,8 +153,6 @@ window_->PostInvalidate(); } -void RenderingTest::DetachFunctorFromView() {} - gfx::Point RenderingTest::GetLocationOnScreen() { return gfx::Point(); }
diff --git a/android_webview/browser/test/rendering_test.h b/android_webview/browser/test/rendering_test.h index 8fa5501..5b369d4 100644 --- a/android_webview/browser/test/rendering_test.h +++ b/android_webview/browser/test/rendering_test.h
@@ -38,7 +38,6 @@ class RenderingTest : public testing::Test, public BrowserViewRendererClient, - public RenderThreadManagerClient, public WindowHooks { public: // BrowserViewRendererClient overrides. @@ -54,13 +53,10 @@ void DidOverscroll(const gfx::Vector2d& overscroll_delta, const gfx::Vector2dF& overscroll_velocity) override {} - // RenderThreadManagerClient overrides. - bool RequestInvokeGL(bool wait_for_completion) override; - void DetachFunctorFromView() override; - // WindowHooks overrides. void WillOnDraw() override; void DidOnDraw(bool success) override {} + FakeFunctor* GetFunctor() override; void WillSyncOnRT() override {} void DidSyncOnRT() override {} void WillProcessOnRT() override {} @@ -83,14 +79,13 @@ void RunTest(); void InitializeCompositor(); - void Attach(); void EndTest(); std::unique_ptr<cc::CompositorFrame> ConstructEmptyFrame(); std::unique_ptr<cc::CompositorFrame> ConstructFrame( cc::ResourceId resource_id); scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; std::unique_ptr<FakeWindow> window_; - std::unique_ptr<RenderThreadManager> render_thread_manager_; + std::unique_ptr<FakeFunctor> functor_; std::unique_ptr<BrowserViewRenderer> browser_view_renderer_; std::unique_ptr<content::TestSynchronousCompositor> compositor_;
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 164f6db..9b45833 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -256,8 +256,11 @@ private long mNativeAwContents; private final AwBrowserContext mBrowserContext; + // mContainerView and mCurrentFunctor form a pair that needs to stay in sync. private ViewGroup mContainerView; - private AwGLFunctor mAwGLFunctor; + private AwGLFunctor mCurrentFunctor; + private AwGLFunctor mInitialFunctor; + private AwGLFunctor mFullScreenFunctor; // Only non-null when in fullscreen mode. private final Context mContext; private final int mAppTargetSdkVersion; private ContentViewCore mContentViewCore; @@ -351,19 +354,18 @@ private static String sCurrentLocale = ""; - private static final class DestroyRunnable implements Runnable { + private static final class AwContentsDestroyRunnable implements Runnable { private final long mNativeAwContents; // Hold onto a reference to the window (via its wrapper), so that it is not destroyed // until we are done here. private final WindowAndroidWrapper mWindowAndroid; - private final Object mAwGLFunctorNativeLifetimeObject; - private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid, - AwGLFunctor awGLFunctor) { + private AwContentsDestroyRunnable( + long nativeAwContents, WindowAndroidWrapper windowAndroid) { mNativeAwContents = nativeAwContents; mWindowAndroid = windowAndroid; - mAwGLFunctorNativeLifetimeObject = awGLFunctor.getNativeLifetimeObject(); } + @Override public void run() { nativeDestroy(mNativeAwContents); @@ -679,7 +681,10 @@ @Override public void run() { if (level >= TRIM_MEMORY_MODERATE) { - mAwGLFunctor.deleteHardwareRenderer(); + mInitialFunctor.deleteHardwareRenderer(); + if (mFullScreenFunctor != null) { + mFullScreenFunctor.deleteHardwareRenderer(); + } } nativeTrimMemory(mNativeAwContents, level, visible); } @@ -743,6 +748,8 @@ mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; mInternalAccessAdapter = internalAccessAdapter; mNativeDrawGLFunctorFactory = nativeDrawGLFunctorFactory; + mInitialFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContainerView); + mCurrentFunctor = mInitialFunctor; mContentsClient = contentsClient; mAwViewMethods = new AwViewMethodsImpl(); mFullScreenTransitionsState = new FullScreenTransitionsState( @@ -838,12 +845,13 @@ if (wasInitialContainerViewFocused) { fullScreenView.requestFocus(); } + mFullScreenFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, fullScreenView); mFullScreenTransitionsState.enterFullScreen(fullScreenView, wasInitialContainerViewFocused); mAwViewMethods = new NullAwViewMethods(this, mInternalAccessAdapter, mContainerView); // Associate this AwContents with the FullScreenView. setInternalAccessAdapter(fullScreenView.getInternalAccessAdapter()); - setContainerView(fullScreenView); + setContainerView(fullScreenView, mFullScreenFunctor); return fullScreenView; } @@ -884,13 +892,15 @@ // Re-associate this AwContents with the WebView. setInternalAccessAdapter(mFullScreenTransitionsState.getInitialInternalAccessDelegate()); - setContainerView(initialContainerView); + setContainerView(initialContainerView, mInitialFunctor); // Return focus to the WebView. if (mFullScreenTransitionsState.wasInitialContainerViewFocused()) { mContainerView.requestFocus(); } mFullScreenTransitionsState.exitFullScreen(); + // Drop AwContents last reference to this functor. AwGLFunctor is responsible for cleanup. + mFullScreenFunctor = null; } private void setInternalAccessAdapter(InternalAccessDelegate internalAccessAdapter) { @@ -898,11 +908,13 @@ mContentViewCore.setContainerViewInternals(mInternalAccessAdapter); } - private void setContainerView(ViewGroup newContainerView) { + private void setContainerView(ViewGroup newContainerView, AwGLFunctor currentFunctor) { // setWillNotDraw(false) is required since WebView draws it's own contents using it's // container view. If this is ever not the case we should remove this, as it removes // Android's gatherTransparentRegion optimization for the view. mContainerView = newContainerView; + mCurrentFunctor = currentFunctor; + updateNativeAwGLFunctor(); mContainerView.setWillNotDraw(false); mContentViewCore.setContainerView(mContainerView); @@ -994,6 +1006,11 @@ } } + private void updateNativeAwGLFunctor() { + nativeSetAwGLFunctor(mNativeAwContents, + mCurrentFunctor != null ? mCurrentFunctor.getNativeAwGLFunctor() : 0); + } + /* Common initialization routine for adopting a native AwContents instance into this * java instance. * @@ -1011,6 +1028,8 @@ assert mNativeAwContents == 0 && mCleanupReference == null && mContentViewCore == null; mNativeAwContents = newAwContentsPtr; + nativeSetAwGLFunctor(mNativeAwContents, mInitialFunctor.getNativeAwGLFunctor()); + updateNativeAwGLFunctor(); // TODO(joth): when the native and java counterparts of AwBrowserContext are hooked up to // each other, we should update |mBrowserContext| according to the newly received native // WebContent's browser context. @@ -1021,8 +1040,6 @@ mContentViewCore = createAndInitializeContentViewCore(mContainerView, mContext, mInternalAccessAdapter, webContents, new AwGestureStateListener(), mContentViewClient, mZoomControls, mWindowAndroid.getWindowAndroid()); - mAwGLFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContainerView); - nativeSetAwGLFunctor(mNativeAwContents, mAwGLFunctor.getNativeAwGLFunctor()); nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge, mIoThreadClient, mInterceptNavigationDelegate); mWebContents = mContentViewCore.getWebContents(); @@ -1035,7 +1052,7 @@ // The native side object has been bound to this java instance, so now is the time to // bind all the native->java relationships. mCleanupReference = new CleanupReference( - this, new DestroyRunnable(mNativeAwContents, mWindowAndroid, mAwGLFunctor)); + this, new AwContentsDestroyRunnable(mNativeAwContents, mWindowAndroid)); } private void installWebContentsObserver() { @@ -1141,7 +1158,6 @@ // hardware resources. if (mIsAttachedToWindow) { Log.w(TAG, "WebView.destroy() called while WebView is still attached to window."); - mAwGLFunctor.deleteHardwareRenderer(); nativeOnDetachedFromWindow(mNativeAwContents); } mIsDestroyed = true; @@ -1269,13 +1285,6 @@ return nativeGetNativeInstanceCount(); } - public long getAwDrawGLViewContext() { - // Only called during early construction, so client should not have had a chance to - // call destroy yet. - assert !isDestroyed(NO_WARN); - return mAwGLFunctor.getAwDrawGLViewContext(); - } - // This is only to avoid heap allocations inside getGlobalVisibleRect. It should treated // as a local variable in the function and not used anywhere else. private static final Rect sLocalGlobalVisibleRect = new Rect(); @@ -2966,7 +2975,7 @@ canvas.isHardwareAccelerated(), scrollX, scrollY, globalVisibleRect.left, globalVisibleRect.top, globalVisibleRect.right, globalVisibleRect.bottom); if (did_draw && canvas.isHardwareAccelerated() && !FORCE_AUXILIARY_BITMAP_RENDERING) { - did_draw = mAwGLFunctor.requestDrawGLForCanvas(canvas); + did_draw = mCurrentFunctor.requestDrawGL(canvas); } if (did_draw) { int scrollXDiff = mContainerView.getScrollX() - scrollX; @@ -3116,6 +3125,7 @@ mContainerView.getHeight()); updateHardwareAcceleratedFeaturesToggle(); postUpdateContentViewCoreVisibility(); + mCurrentFunctor.onAttachedToWindow(); setLocale(LocaleUtils.getDefaultLocale()); mSettings.updateAcceptLanguages(); @@ -3134,12 +3144,12 @@ } mIsAttachedToWindow = false; hideAutofillPopup(); - mAwGLFunctor.deleteHardwareRenderer(); nativeOnDetachedFromWindow(mNativeAwContents); mContentViewCore.onDetachedFromWindow(); updateHardwareAcceleratedFeaturesToggle(); postUpdateContentViewCoreVisibility(); + mCurrentFunctor.onDetachedFromWindow(); if (mComponentCallbacks != null) { mContext.unregisterComponentCallbacks(mComponentCallbacks);
diff --git a/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java b/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java index e5092837..702e5da5 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java +++ b/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java
@@ -44,6 +44,8 @@ private final AwContents.NativeDrawGLFunctor mNativeDrawGLFunctor; private final ViewGroup mContainerView; private final Runnable mFunctorReleasedCallback; + // Counts outstanding requestDrawGL calls as well as window attach count. + private int mRefCount; public AwGLFunctor(AwContents.NativeDrawGLFunctorFactory nativeDrawGLFunctorFactory, ViewGroup containerView) { @@ -57,8 +59,7 @@ mFunctorReleasedCallback = new Runnable() { @Override public void run() { - // Deliberate no-op. This Runnable is holding a strong reference back to the - // AwGLFunctor, which serves its purpose for now. + removeReference(); } }; } else { @@ -66,6 +67,14 @@ } } + public void onAttachedToWindow() { + addReference(); + } + + public void onDetachedFromWindow() { + removeReference(); + } + public static long getAwDrawGLFunction() { return nativeGetAwDrawGLFunction(); } @@ -74,12 +83,25 @@ return mNativeAwGLFunctor; } - public Object getNativeLifetimeObject() { - return mLifetimeObject; + public boolean requestDrawGL(Canvas canvas) { + boolean success = mNativeDrawGLFunctor.requestDrawGL(canvas, mFunctorReleasedCallback); + if (success && mFunctorReleasedCallback != null) { + addReference(); + } + return success; } - public boolean requestDrawGLForCanvas(Canvas canvas) { - return mNativeDrawGLFunctor.requestDrawGL(canvas, mFunctorReleasedCallback); + private void addReference() { + ++mRefCount; + } + + private void removeReference() { + if (--mRefCount == 0) { + // When |mRefCount| decreases to zero, the functor is neither attached to a view, nor + // referenced from the render tree, and so it is safe to delete the HardwareRenderer + // instance to free up resources because the current state will not be drawn again. + deleteHardwareRenderer(); + } } @CalledByNative
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 0da570e..1c05e59 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc
@@ -310,10 +310,10 @@ } functor_ = functor; if (functor_) { - browser_view_renderer_.SetCompositorFrameConsumer( + browser_view_renderer_.SetCurrentCompositorFrameConsumer( functor_->GetCompositorFrameConsumer()); } else { - browser_view_renderer_.SetCompositorFrameConsumer(nullptr); + browser_view_renderer_.SetCurrentCompositorFrameConsumer(nullptr); } }
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java index da0009eb..916c58e3 100644 --- a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java +++ b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java
@@ -57,6 +57,8 @@ private int mLastScrollX = 0; private int mLastScrollY = 0; + // Only used by drawGL on render thread to store the value of scroll offsets at most recent + // sync for subsequent draws. private int mCommittedScrollX = 0; private int mCommittedScrollY = 0; @@ -146,7 +148,6 @@ public void requestRender(long viewContext, Canvas canvas, boolean waitForCompletion) { synchronized (mSyncLock) { assert viewContext != 0; - assert mViewContext == 0 || mViewContext == viewContext; mViewContext = viewContext; super.requestRender(); mFunctorAttached = true; @@ -183,6 +184,7 @@ final boolean draw; final boolean process; final boolean waitForCompletion; + final long viewContext; synchronized (mSyncLock) { if (!mFunctorAttached) { @@ -193,9 +195,9 @@ draw = mNeedsDrawGL; process = mNeedsProcessGL; waitForCompletion = mWaitForCompletion; - + viewContext = mViewContext; if (draw) { - DrawGL.drawGL(mDrawGL, mViewContext, width, height, 0, 0, MODE_SYNC); + DrawGL.drawGL(mDrawGL, viewContext, width, height, 0, 0, MODE_SYNC); mCommittedScrollX = mLastScrollX; mCommittedScrollY = mLastScrollY; } @@ -206,11 +208,11 @@ } } if (process) { - DrawGL.drawGL(mDrawGL, mViewContext, width, height, 0, 0, MODE_PROCESS); + DrawGL.drawGL(mDrawGL, viewContext, width, height, 0, 0, MODE_PROCESS); } if (process || draw) { - DrawGL.drawGL(mDrawGL, mViewContext, width, height, - mCommittedScrollX, mCommittedScrollY, MODE_DRAW); + DrawGL.drawGL(mDrawGL, viewContext, width, height, mCommittedScrollX, + mCommittedScrollY, MODE_DRAW); } if (waitForCompletion) {
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.cc b/base/trace_event/heap_profiler_allocation_context_tracker.cc index fd4e21a..fac4a8a7 100644 --- a/base/trace_event/heap_profiler_allocation_context_tracker.cc +++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
@@ -8,9 +8,15 @@ #include <iterator> #include "base/atomicops.h" +#include "base/debug/leak_annotations.h" +#include "base/threading/platform_thread.h" #include "base/threading/thread_local_storage.h" #include "base/trace_event/heap_profiler_allocation_context.h" +#if defined(OS_LINUX) || defined(OS_ANDROID) +#include <sys/prctl.h> +#endif + namespace base { namespace trace_event { @@ -33,6 +39,29 @@ delete static_cast<AllocationContextTracker*>(alloc_ctx_tracker); } +// Cannot call ThreadIdNameManager::GetName because it holds a lock and causes +// deadlock when lock is already held by ThreadIdNameManager before the current +// allocation. Gets the thread name from kernel if available or returns a string +// with id. This function intenionally leaks the allocated strings since they +// are used to tag allocations even after the thread dies. +const char* GetAndLeakThreadName() { + char name[16]; +#if defined(OS_LINUX) || defined(OS_ANDROID) + // If the thread name is not set, try to get it from prctl. Thread name might + // not be set in cases where the thread started before heap profiling was + // enabled. + int err = prctl(PR_GET_NAME, name); + if (!err) { + return strdup(name); + } +#endif // defined(OS_LINUX) || defined(OS_ANDROID) + + // Use tid if we don't have a thread name. + snprintf(name, sizeof(name), "%lu", + static_cast<unsigned long>(PlatformThread::CurrentId())); + return strdup(name); +} + } // namespace // static @@ -142,7 +171,17 @@ auto backtrace = std::begin(ctx.backtrace.frames); auto backtrace_end = std::end(ctx.backtrace.frames); - // Add the thread name as the first entry + if (!thread_name_) { + // Ignore the string allocation made by GetAndLeakThreadName to avoid + // reentrancy. + ignore_scope_depth_++; + thread_name_ = GetAndLeakThreadName(); + ANNOTATE_LEAKING_OBJECT_PTR(thread_name_); + DCHECK(thread_name_); + ignore_scope_depth_--; + } + + // Add the thread name as the first entry in pseudo stack. if (thread_name_) { *backtrace++ = StackFrame::FromThreadName(thread_name_); }
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc index 436f754..07d5f25 100644 --- a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc +++ b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
@@ -19,6 +19,7 @@ // Define all strings once, because the pseudo stack requires pointer equality, // and string interning is unreliable. +const char kThreadName[] = "TestThread"; const char kCupcake[] = "Cupcake"; const char kDonut[] = "Donut"; const char kEclair[] = "Eclair"; @@ -49,12 +50,14 @@ ASSERT_EQ(expected, expected_bottom); } -void AssertBacktraceEmpty() { +void AssertBacktraceContainsOnlyThreadName() { + StackFrame t = StackFrame::FromThreadName(kThreadName); AllocationContext ctx = AllocationContextTracker::GetInstanceForCurrentThread() ->GetContextSnapshot(); - ASSERT_EQ(0u, ctx.backtrace.frame_count); + ASSERT_EQ(1u, ctx.backtrace.frame_count); + ASSERT_EQ(t, ctx.backtrace.frames[0]); } class AllocationContextTrackerTest : public testing::Test { @@ -64,6 +67,7 @@ TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); AllocationContextTracker::SetCaptureMode( AllocationContextTracker::CaptureMode::PSEUDO_STACK); + AllocationContextTracker::SetCurrentThreadName(kThreadName); } void TearDown() override { @@ -75,21 +79,22 @@ // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { + StackFrame t = StackFrame::FromThreadName(kThreadName); StackFrame c = StackFrame::FromTraceEventName(kCupcake); StackFrame d = StackFrame::FromTraceEventName(kDonut); StackFrame e = StackFrame::FromTraceEventName(kEclair); StackFrame f = StackFrame::FromTraceEventName(kFroyo); - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); { TRACE_EVENT0("Testing", kCupcake); - StackFrame frame_c[] = {c}; + StackFrame frame_c[] = {t, c}; AssertBacktraceEquals(frame_c); { TRACE_EVENT0("Testing", kDonut); - StackFrame frame_cd[] = {c, d}; + StackFrame frame_cd[] = {t, c, d}; AssertBacktraceEquals(frame_cd); } @@ -97,38 +102,39 @@ { TRACE_EVENT0("Testing", kEclair); - StackFrame frame_ce[] = {c, e}; + StackFrame frame_ce[] = {t, c, e}; AssertBacktraceEquals(frame_ce); } AssertBacktraceEquals(frame_c); } - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); { TRACE_EVENT0("Testing", kFroyo); - StackFrame frame_f[] = {f}; + StackFrame frame_f[] = {t, f}; AssertBacktraceEquals(frame_f); } - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); } // Same as |PseudoStackScopedTrace|, but now test the |TRACE_EVENT_BEGIN| and // |TRACE_EVENT_END| macros. TEST_F(AllocationContextTrackerTest, PseudoStackBeginEndTrace) { + StackFrame t = StackFrame::FromThreadName(kThreadName); StackFrame c = StackFrame::FromTraceEventName(kCupcake); StackFrame d = StackFrame::FromTraceEventName(kDonut); StackFrame e = StackFrame::FromTraceEventName(kEclair); StackFrame f = StackFrame::FromTraceEventName(kFroyo); - StackFrame frame_c[] = {c}; - StackFrame frame_cd[] = {c, d}; - StackFrame frame_ce[] = {c, e}; - StackFrame frame_f[] = {f}; + StackFrame frame_c[] = {t, c}; + StackFrame frame_cd[] = {t, c, d}; + StackFrame frame_ce[] = {t, c, e}; + StackFrame frame_f[] = {t, f}; - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); TRACE_EVENT_BEGIN0("Testing", kCupcake); AssertBacktraceEquals(frame_c); @@ -146,27 +152,28 @@ AssertBacktraceEquals(frame_c); TRACE_EVENT_END0("Testing", kCupcake); - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); TRACE_EVENT_BEGIN0("Testing", kFroyo); AssertBacktraceEquals(frame_f); TRACE_EVENT_END0("Testing", kFroyo); - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); } TEST_F(AllocationContextTrackerTest, PseudoStackMixedTrace) { + StackFrame t = StackFrame::FromThreadName(kThreadName); StackFrame c = StackFrame::FromTraceEventName(kCupcake); StackFrame d = StackFrame::FromTraceEventName(kDonut); StackFrame e = StackFrame::FromTraceEventName(kEclair); StackFrame f = StackFrame::FromTraceEventName(kFroyo); - StackFrame frame_c[] = {c}; - StackFrame frame_cd[] = {c, d}; - StackFrame frame_e[] = {e}; - StackFrame frame_ef[] = {e, f}; + StackFrame frame_c[] = {t, c}; + StackFrame frame_cd[] = {t, c, d}; + StackFrame frame_e[] = {t, e}; + StackFrame frame_ef[] = {t, e, f}; - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); TRACE_EVENT_BEGIN0("Testing", kCupcake); AssertBacktraceEquals(frame_c); @@ -178,7 +185,7 @@ AssertBacktraceEquals(frame_c); TRACE_EVENT_END0("Testing", kCupcake); - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); { TRACE_EVENT0("Testing", kEclair); @@ -190,15 +197,15 @@ AssertBacktraceEquals(frame_e); } - AssertBacktraceEmpty(); + AssertBacktraceContainsOnlyThreadName(); } TEST_F(AllocationContextTrackerTest, BacktraceTakesTop) { + StackFrame t = StackFrame::FromThreadName(kThreadName); StackFrame c = StackFrame::FromTraceEventName(kCupcake); StackFrame f = StackFrame::FromTraceEventName(kFroyo); - // Push 12 events onto the pseudo stack. - TRACE_EVENT0("Testing", kCupcake); + // Push 11 events onto the pseudo stack. TRACE_EVENT0("Testing", kCupcake); TRACE_EVENT0("Testing", kCupcake); TRACE_EVENT0("Testing", kCupcake); @@ -220,7 +227,8 @@ ->GetContextSnapshot(); // The pseudo stack relies on pointer equality, not deep string comparisons. - ASSERT_EQ(c, ctx.backtrace.frames[0]); + ASSERT_EQ(t, ctx.backtrace.frames[0]); + ASSERT_EQ(c, ctx.backtrace.frames[1]); ASSERT_EQ(f, ctx.backtrace.frames[11]); } @@ -228,33 +236,12 @@ AllocationContext ctx = AllocationContextTracker::GetInstanceForCurrentThread() ->GetContextSnapshot(); - ASSERT_EQ(c, ctx.backtrace.frames[0]); + ASSERT_EQ(t, ctx.backtrace.frames[0]); + ASSERT_EQ(c, ctx.backtrace.frames[1]); ASSERT_EQ(f, ctx.backtrace.frames[11]); } } -TEST_F(AllocationContextTrackerTest, SetCurrentThreadName) { - TRACE_EVENT0("Testing", kCupcake); - - // Test if the thread name is inserted into backtrace. - const char kThread1[] = "thread1"; - AllocationContextTracker::SetCurrentThreadName(kThread1); - AllocationContext ctx1 = - AllocationContextTracker::GetInstanceForCurrentThread() - ->GetContextSnapshot(); - ASSERT_EQ(StackFrame::FromThreadName(kThread1), ctx1.backtrace.frames[0]); - ASSERT_EQ(StackFrame::FromTraceEventName(kCupcake), ctx1.backtrace.frames[1]); - - // Test if the thread name is reset. - const char kThread2[] = "thread2"; - AllocationContextTracker::SetCurrentThreadName(kThread2); - AllocationContext ctx2 = - AllocationContextTracker::GetInstanceForCurrentThread() - ->GetContextSnapshot(); - ASSERT_EQ(StackFrame::FromThreadName(kThread2), ctx2.backtrace.frames[0]); - ASSERT_EQ(StackFrame::FromTraceEventName(kCupcake), ctx2.backtrace.frames[1]); -} - TEST_F(AllocationContextTrackerTest, TrackTaskContext) { const char kContext1[] = "context1"; const char kContext2[] = "context2";
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpApplication.java b/blimp/client/app/android/java/src/org/chromium/blimp/BlimpApplication.java index 17fd5fd..e9a4b1a 100644 --- a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpApplication.java +++ b/blimp/client/app/android/java/src/org/chromium/blimp/BlimpApplication.java
@@ -8,6 +8,7 @@ import org.chromium.base.BaseChromiumApplication; import org.chromium.base.CommandLineInitUtil; +import org.chromium.base.ContextUtils; import org.chromium.base.PathUtils; import org.chromium.base.ResourceExtractor; @@ -22,6 +23,7 @@ @Override public void onCreate() { super.onCreate(); + ContextUtils.initApplicationContext(this); ResourceExtractor.setResourcesToExtract(new ResourceExtractor.ResourceEntry[0]); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this); initCommandLine();
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/auth/TokenSourceImpl.java b/blimp/client/app/android/java/src/org/chromium/blimp/auth/TokenSourceImpl.java index a21c9c0d..a20d798 100644 --- a/blimp/client/app/android/java/src/org/chromium/blimp/auth/TokenSourceImpl.java +++ b/blimp/client/app/android/java/src/org/chromium/blimp/auth/TokenSourceImpl.java
@@ -10,7 +10,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; -import android.preference.PreferenceManager; import com.google.android.gms.auth.GoogleAuthException; import com.google.android.gms.auth.GoogleAuthUtil; @@ -18,6 +17,7 @@ import com.google.android.gms.auth.UserRecoverableNotifiedException; import com.google.android.gms.common.ConnectionResult; +import org.chromium.base.ContextUtils; import org.chromium.base.Log; import org.chromium.base.ThreadUtils; import org.chromium.blimp.R; @@ -82,7 +82,7 @@ if (mCallback == null) return; // Find the current account tracked by settings. - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mAppContext); + SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); String accountName = preferences.getString(ACCOUNT_NAME_PREF, null); if (accountName == null || !doesAccountExist(accountName)) { @@ -129,7 +129,7 @@ ThreadUtils.assertOnUiThread(); String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mAppContext); + SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); preferences.edit().putString(ACCOUNT_NAME_PREF, accountName).apply(); }
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/preferences/PreferencesUtil.java b/blimp/client/app/android/java/src/org/chromium/blimp/preferences/PreferencesUtil.java index fb6a9eb..8882aa8 100644 --- a/blimp/client/app/android/java/src/org/chromium/blimp/preferences/PreferencesUtil.java +++ b/blimp/client/app/android/java/src/org/chromium/blimp/preferences/PreferencesUtil.java
@@ -5,9 +5,8 @@ package org.chromium.blimp.preferences; import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; +import org.chromium.base.ContextUtils; import org.chromium.blimp.R; /** @@ -20,24 +19,19 @@ private static final String PREF_LAST_USED_ASSIGNER = "last_known_assigner"; private static final String DEFAULT_EMPTY_STRING = ""; - private static SharedPreferences getPreferences(Context context) { - return PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); - } - /** * Finds the assigner to be used from user's last preference. If the app is being used for the * first time, the first entry from the assigner array would be used. * @return assigner to use. */ public static String findAssignerUrl(Context context) { - String lastAssigner = getPreferences(context).getString(PREF_LAST_USED_ASSIGNER, ""); + String lastAssigner = getLastUsedAssigner(context); if (lastAssigner.isEmpty()) { String[] assignerUrls = context.getResources().getStringArray(R.array.assigner_urls); assert assignerUrls != null && assignerUrls.length > 0; lastAssigner = assignerUrls[0]; - writeString(context, PREF_LAST_USED_ASSIGNER, lastAssigner); + setLastUsedAssigner(context, lastAssigner); } - return lastAssigner; } @@ -66,7 +60,7 @@ * @return The current value of the preference or a default value */ private static String readString(Context context, String key) { - return getPreferences(context).getString(key, DEFAULT_EMPTY_STRING); + return ContextUtils.getAppSharedPreferences().getString(key, DEFAULT_EMPTY_STRING); } /** @@ -76,8 +70,6 @@ * @param value The new value for the preference */ private static void writeString(Context context, String key, String value) { - SharedPreferences.Editor editor = getPreferences(context).edit(); - editor.putString(key, value); - editor.apply(); + ContextUtils.getAppSharedPreferences().edit().putString(key, value).apply(); } }
diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni index 44ded33e..c01403a 100644 --- a/build/config/sysroot.gni +++ b/build/config/sysroot.gni
@@ -29,7 +29,7 @@ sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" } else if (current_cpu == "arm64") { sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" - } else if (current_cpu == "mips64") { + } else if (current_cpu == "mips64el") { sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" } else { sysroot = ""
diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn index 2e47b2d..52ac0a7 100644 --- a/build/toolchain/android/BUILD.gn +++ b/build/toolchain/android/BUILD.gn
@@ -110,5 +110,5 @@ android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" android_ndk_lib_dir = "usr/lib64" - toolchain_cpu = "mipsel64el" + toolchain_cpu = "mips64el" }
diff --git a/build/toolchain/get_concurrent_links.py b/build/toolchain/get_concurrent_links.py index c1fbc8b..4a66dd3 100644 --- a/build/toolchain/get_concurrent_links.py +++ b/build/toolchain/get_concurrent_links.py
@@ -55,7 +55,7 @@ if is_lto: mem_total_gb -= 10 # Reserve # For LTO builds the RAM requirements are even higher - mem_per_link_gb = 16 + mem_per_link_gb = 24 return int(max(1, mem_total_gb / mem_per_link_gb)) return 1 elif sys.platform == 'darwin':
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index b305bc1e..4219f2ed 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn
@@ -716,8 +716,6 @@ "test/test_image_factory.h", "test/test_in_process_context_provider.cc", "test/test_in_process_context_provider.h", - "test/test_layer_tree_host_base.cc", - "test/test_layer_tree_host_base.h", "test/test_occlusion_tracker.h", "test/test_shared_bitmap_manager.cc", "test/test_shared_bitmap_manager.h", @@ -795,6 +793,7 @@ "input/scrollbar_animation_controller_linear_fade_unittest.cc", "input/scrollbar_animation_controller_thinning_unittest.cc", "input/top_controls_manager_unittest.cc", + "ipc/cc_param_traits_unittest.cc", "layers/heads_up_display_layer_impl_unittest.cc", "layers/heads_up_display_unittest.cc", "layers/layer_impl_unittest.cc", @@ -943,6 +942,7 @@ ":cc", ":test_support", "//base/test:test_support", + "//cc/ipc", "//cc/proto", "//cc/surfaces", "//cc/surfaces:surface_id", @@ -969,6 +969,7 @@ test("cc_perftests") { sources = [ "animation/animation_host_perftest.cc", + "ipc/cc_param_traits_perftest.cc", "layers/layer_perftest.cc", "layers/picture_layer_impl_perftest.cc", "quads/draw_quad_perftest.cc", @@ -989,6 +990,7 @@ ":test_support", "//base", "//base/test:test_support", + "//cc/ipc", "//cc/surfaces", "//cc/surfaces:surface_id", "//gpu",
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index d6c21d2..888ab8f 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp
@@ -35,6 +35,7 @@ 'input/scrollbar_animation_controller_linear_fade_unittest.cc', 'input/scrollbar_animation_controller_thinning_unittest.cc', 'input/top_controls_manager_unittest.cc', + 'ipc/cc_param_traits_unittest.cc', 'layers/heads_up_display_layer_impl_unittest.cc', 'layers/heads_up_display_unittest.cc', 'layers/layer_impl_unittest.cc', @@ -305,8 +306,6 @@ 'test/test_image_factory.h', 'test/test_in_process_context_provider.cc', 'test/test_in_process_context_provider.h', - 'test/test_layer_tree_host_base.cc', - 'test/test_layer_tree_host_base.h', 'test/test_occlusion_tracker.h', 'test/test_shared_bitmap_manager.cc', 'test/test_shared_bitmap_manager.h', @@ -331,6 +330,7 @@ '../gpu/command_buffer/command_buffer.gyp:gles2_utils', '../gpu/gpu.gyp:gpu', '../gpu/gpu.gyp:gpu_unittest_utils', + '../ipc/ipc.gyp:ipc', '../media/media.gyp:media', '../skia/skia.gyp:skia', '../testing/gmock.gyp:gmock', @@ -343,6 +343,7 @@ 'cc.gyp:cc_proto', 'cc.gyp:cc_surfaces', 'cc_test_support', + 'ipc/cc_ipc.gyp:cc_ipc', ], 'sources': [ 'test/cc_test_suite.cc', @@ -369,6 +370,7 @@ '../gpu/command_buffer/command_buffer.gyp:gles2_utils', '../gpu/gpu.gyp:gpu', '../gpu/gpu.gyp:gpu_unittest_utils', + '../ipc/ipc.gyp:ipc', '../media/media.gyp:media', '../skia/skia.gyp:skia', '../testing/gmock.gyp:gmock', @@ -379,10 +381,12 @@ 'cc.gyp:cc', 'cc.gyp:cc_surfaces', 'cc_test_support', + 'ipc/cc_ipc.gyp:cc_ipc', ], 'sources': [ # Note: sources list duplicated in GN build. 'animation/animation_host_perftest.cc', + 'ipc/cc_param_traits_perftest.cc', 'layers/layer_perftest.cc', 'layers/picture_layer_impl_perftest.cc', 'quads/draw_quad_perftest.cc',
diff --git a/cc/ipc/BUILD.gn b/cc/ipc/BUILD.gn index 97e2338..ce2bd1d 100644 --- a/cc/ipc/BUILD.gn +++ b/cc/ipc/BUILD.gn
@@ -14,8 +14,6 @@ "cc_param_traits_macros.h", ] - configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] - public_deps = [ "//cc", "//cc/surfaces",
diff --git a/cc/ipc/cc_ipc.gyp b/cc/ipc/cc_ipc.gyp index e116fda..9a7645d 100644 --- a/cc/ipc/cc_ipc.gyp +++ b/cc/ipc/cc_ipc.gyp
@@ -33,8 +33,6 @@ 'cc_param_traits.h', 'cc_param_traits_macros.h', ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], }, ], }
diff --git a/cc/ipc/cc_param_traits.cc b/cc/ipc/cc_param_traits.cc index fe7ccd6..50a473c1 100644 --- a/cc/ipc/cc_param_traits.cc +++ b/cc/ipc/cc_param_traits.cc
@@ -278,7 +278,7 @@ SkImageFilter* filter = p.get(); if (filter) { sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter)); - s->AddData(data->size()); + s->AddData(base::checked_cast<int>(data->size())); } else { s->AddData(0); } @@ -289,7 +289,8 @@ SkImageFilter* filter = p.get(); if (filter) { sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter)); - m->WriteData(static_cast<const char*>(data->data()), data->size()); + m->WriteData(static_cast<const char*>(data->data()), + base::checked_cast<int>(data->size())); } else { m->WriteData(0, 0); }
diff --git a/content/common/cc_messages_perftest.cc b/cc/ipc/cc_param_traits_perftest.cc similarity index 89% rename from content/common/cc_messages_perftest.cc rename to cc/ipc/cc_param_traits_perftest.cc index 7914b1a..1cf40f1a 100644 --- a/content/common/cc_messages_perftest.cc +++ b/cc/ipc/cc_param_traits_perftest.cc
@@ -27,7 +27,7 @@ static const int kNumWarmupRuns = 20; static const int kTimeCheckInterval = 10; -class CCMessagesPerfTest : public testing::Test { +class CCParamTraitsPerfTest : public testing::Test { protected: static void RunTest(const std::string& test_name, const CompositorFrame& frame) { @@ -55,16 +55,12 @@ } perf_test::PrintResult( - "min_frame_serialization_time", - "", - test_name, - min_time.InMillisecondsF() / kTimeCheckInterval * 1000, - "us", - true); + "min_frame_serialization_time", "", test_name, + min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true); } }; -TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_1_4000) { +TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_1_4000) { std::unique_ptr<CompositorFrame> frame(new CompositorFrame); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); @@ -82,7 +78,7 @@ RunTest("DelegatedFrame_ManyQuads_1_4000", *frame); } -TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_1_100000) { +TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_1_100000) { std::unique_ptr<CompositorFrame> frame(new CompositorFrame); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); @@ -100,7 +96,7 @@ RunTest("DelegatedFrame_ManyQuads_1_100000", *frame); } -TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_4000_4000) { +TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_4000_4000) { std::unique_ptr<CompositorFrame> frame(new CompositorFrame); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); @@ -118,7 +114,7 @@ RunTest("DelegatedFrame_ManyQuads_4000_4000", *frame); } -TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_100000_100000) { +TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_100000_100000) { std::unique_ptr<CompositorFrame> frame(new CompositorFrame); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); @@ -136,8 +132,7 @@ RunTest("DelegatedFrame_ManyQuads_100000_100000", *frame); } -TEST_F(CCMessagesPerfTest, - DelegatedFrame_ManyRenderPasses_10000_100) { +TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) { std::unique_ptr<CompositorFrame> frame(new CompositorFrame); frame->delegated_frame_data.reset(new DelegatedFrameData);
diff --git a/content/common/cc_messages_unittest.cc b/cc/ipc/cc_param_traits_unittest.cc similarity index 83% rename from content/common/cc_messages_unittest.cc rename to cc/ipc/cc_param_traits_unittest.cc index b2134db..8886a14 100644 --- a/content/common/cc_messages_unittest.cc +++ b/cc/ipc/cc_param_traits_unittest.cc
@@ -13,7 +13,6 @@ #include "cc/output/compositor_frame.h" #include "cc/quads/picture_draw_quad.h" #include "cc/quads/render_pass_draw_quad.h" -#include "content/public/common/common_param_traits.h" #include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/effects/SkBlurImageFilter.h" @@ -47,7 +46,7 @@ namespace content { namespace { -class CCMessagesTest : public testing::Test { +class CCParamTraitsTest : public testing::Test { protected: void Compare(const RenderPass* a, const RenderPass* b) { EXPECT_EQ(a->id, b->id); @@ -100,8 +99,7 @@ TextureDrawQuad::MaterialCast(b)); break; case DrawQuad::TILED_CONTENT: - Compare(TileDrawQuad::MaterialCast(a), - TileDrawQuad::MaterialCast(b)); + Compare(TileDrawQuad::MaterialCast(a), TileDrawQuad::MaterialCast(b)); break; case DrawQuad::SOLID_COLOR: Compare(SolidColorDrawQuad::MaterialCast(a), @@ -219,7 +217,7 @@ } }; -TEST_F(CCMessagesTest, AllQuads) { +TEST_F(CCParamTraitsTest, AllQuads) { IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); Transform arbitrary_matrix1; @@ -280,15 +278,14 @@ RenderPassId root_id(10, 14); FilterOperations arbitrary_filters1; - arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter( - arbitrary_float1)); arbitrary_filters1.Append( - cc::FilterOperation::CreateReferenceFilter( - SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); + FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); + arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( + SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); FilterOperations arbitrary_filters2; - arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter( - arbitrary_float2)); + arbitrary_filters2.Append( + FilterOperation::CreateBrightnessFilter(arbitrary_float2)); std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, @@ -317,26 +314,19 @@ DebugBorderDrawQuad* debugborder_in = pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); - debugborder_in->SetAll(shared_state1_in, - arbitrary_rect3, + debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, arbitrary_rect1_inside_rect3, - arbitrary_rect2_inside_rect3, - arbitrary_bool1, - arbitrary_color, - arbitrary_int); + arbitrary_rect2_inside_rect3, arbitrary_bool1, + arbitrary_color, arbitrary_int); pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, debugborder_in->shared_quad_state); IOSurfaceDrawQuad* iosurface_in = pass_in->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>(); - iosurface_in->SetAll(shared_state1_in, - arbitrary_rect2, - arbitrary_rect2_inside_rect2, - arbitrary_rect1_inside_rect2, - arbitrary_bool1, - arbitrary_size1, - arbitrary_resourceid3, - arbitrary_orientation); + iosurface_in->SetAll( + shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, + arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_size1, + arbitrary_resourceid3, arbitrary_orientation); pass_cmp->CopyFromAndAppendDrawQuad(iosurface_in, iosurface_in->shared_quad_state); @@ -356,8 +346,7 @@ arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1, arbitrary_filters1, arbitrary_vector2df2, arbitrary_filters2); pass_cmp->CopyFromAndAppendRenderPassDrawQuad( - renderpass_in, - renderpass_in->shared_quad_state, + renderpass_in, renderpass_in->shared_quad_state, renderpass_in->render_pass_id); SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); @@ -370,13 +359,10 @@ SolidColorDrawQuad* solidcolor_in = pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); - solidcolor_in->SetAll(shared_state3_in, - arbitrary_rect3, + solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3, arbitrary_rect1_inside_rect3, - arbitrary_rect2_inside_rect3, - arbitrary_bool1, - arbitrary_color, - arbitrary_bool2); + arbitrary_rect2_inside_rect3, arbitrary_bool1, + arbitrary_color, arbitrary_bool2); pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in, solidcolor_in->shared_quad_state); @@ -392,37 +378,27 @@ cc::SurfaceId arbitrary_surface_id(3); SurfaceDrawQuad* surface_in = pass_in->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); - surface_in->SetAll(shared_state3_in, - arbitrary_rect2, - arbitrary_rect2_inside_rect2, - arbitrary_rect1_inside_rect2, - arbitrary_bool1, - arbitrary_surface_id); + surface_in->SetAll(shared_state3_in, arbitrary_rect2, + arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, + arbitrary_bool1, arbitrary_surface_id); pass_cmp->CopyFromAndAppendDrawQuad(surface_in, surface_in->shared_quad_state); TextureDrawQuad* texture_in = pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); - texture_in->SetAll(shared_state3_in, arbitrary_rect2, - arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, - arbitrary_bool1, arbitrary_resourceid1, arbitrary_size1, - arbitrary_bool2, arbitrary_pointf1, - arbitrary_pointf2, arbitrary_color, arbitrary_float_array, - arbitrary_bool4, arbitrary_bool5); + texture_in->SetAll( + shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, + arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid1, + arbitrary_size1, arbitrary_bool2, arbitrary_pointf1, arbitrary_pointf2, + arbitrary_color, arbitrary_float_array, arbitrary_bool4, arbitrary_bool5); pass_cmp->CopyFromAndAppendDrawQuad(texture_in, texture_in->shared_quad_state); TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>(); - tile_in->SetAll(shared_state3_in, - arbitrary_rect2, - arbitrary_rect2_inside_rect2, - arbitrary_rect1_inside_rect2, - arbitrary_bool1, - arbitrary_resourceid3, - arbitrary_rectf1, - arbitrary_size1, - arbitrary_bool2, - arbitrary_bool3); + tile_in->SetAll(shared_state3_in, arbitrary_rect2, + arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, + arbitrary_bool1, arbitrary_resourceid3, arbitrary_rectf1, + arbitrary_size1, arbitrary_bool2, arbitrary_bool3); pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state); YUVVideoDrawQuad* yuvvideo_in = @@ -452,8 +428,7 @@ } for (auto in_iter = pass_in->quad_list.cbegin(), cmp_iter = pass_cmp->quad_list.cbegin(); - in_iter != pass_in->quad_list.cend(); - ++in_iter, ++cmp_iter) + in_iter != pass_in->quad_list.cend(); ++in_iter, ++cmp_iter) Compare(*cmp_iter, *in_iter); for (size_t i = 1; i < pass_in->quad_list.size(); ++i) { @@ -474,8 +449,8 @@ DelegatedFrameData frame_out; base::PickleIterator iter(msg); - EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, - &iter, &frame_out)); + EXPECT_TRUE( + IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); // Make sure the out and cmp RenderPasses match. std::unique_ptr<RenderPass> child_pass_out = @@ -497,8 +472,7 @@ } for (auto out_iter = pass_out->quad_list.cbegin(), cmp_iter = pass_cmp->quad_list.cbegin(); - out_iter != pass_out->quad_list.cend(); - ++out_iter, ++cmp_iter) + out_iter != pass_out->quad_list.cend(); ++out_iter, ++cmp_iter) Compare(*cmp_iter, *out_iter); for (size_t i = 1; i < pass_out->quad_list.size(); ++i) { @@ -512,23 +486,15 @@ } } -TEST_F(CCMessagesTest, UnusedSharedQuadStates) { +TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); - pass_in->SetAll(RenderPassId(1, 1), - gfx::Rect(100, 100), - gfx::Rect(), - gfx::Transform(), - false); + pass_in->SetAll(RenderPassId(1, 1), gfx::Rect(100, 100), gfx::Rect(), + gfx::Transform(), false); // The first SharedQuadState is used. SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); - shared_state1_in->SetAll(gfx::Transform(), - gfx::Size(1, 1), - gfx::Rect(), - gfx::Rect(), - false, - 1.f, - SkXfermode::kSrcOver_Mode, + shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), + gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, 0); SolidColorDrawQuad* quad1 = @@ -538,34 +504,19 @@ // The second and third SharedQuadStates are not used. SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); - shared_state2_in->SetAll(gfx::Transform(), - gfx::Size(2, 2), - gfx::Rect(), - gfx::Rect(), - false, - 1.f, - SkXfermode::kSrcOver_Mode, + shared_state2_in->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(), + gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, 0); SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); - shared_state3_in->SetAll(gfx::Transform(), - gfx::Size(3, 3), - gfx::Rect(), - gfx::Rect(), - false, - 1.f, - SkXfermode::kSrcOver_Mode, + shared_state3_in->SetAll(gfx::Transform(), gfx::Size(3, 3), gfx::Rect(), + gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, 0); // The fourth SharedQuadState is used. SharedQuadState* shared_state4_in = pass_in->CreateAndAppendSharedQuadState(); - shared_state4_in->SetAll(gfx::Transform(), - gfx::Size(4, 4), - gfx::Rect(), - gfx::Rect(), - false, - 1.f, - SkXfermode::kSrcOver_Mode, + shared_state4_in->SetAll(gfx::Transform(), gfx::Size(4, 4), gfx::Rect(), + gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, 0); SolidColorDrawQuad* quad2 = @@ -575,13 +526,8 @@ // The fifth is not used again. SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState(); - shared_state5_in->SetAll(gfx::Transform(), - gfx::Size(5, 5), - gfx::Rect(), - gfx::Rect(), - false, - 1.f, - SkXfermode::kSrcOver_Mode, + shared_state5_in->SetAll(gfx::Transform(), gfx::Size(5, 5), gfx::Rect(), + gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, 0); // 5 SharedQuadStates go in. @@ -615,7 +561,7 @@ ->quad_layer_bounds.ToString()); } -TEST_F(CCMessagesTest, Resources) { +TEST_F(CCParamTraitsTest, Resources) { IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); gfx::Size arbitrary_size(757, 1281); gpu::SyncToken arbitrary_token1(gpu::CommandBufferNamespace::GPU_IO, 0, @@ -658,8 +604,8 @@ arbitrary_resource2.is_overlay_candidate = false; std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create(); - renderpass_in->SetNew( - RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), gfx::Transform()); + renderpass_in->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), + gfx::Transform()); DelegatedFrameData frame_in; frame_in.resource_list.push_back(arbitrary_resource1); @@ -670,8 +616,8 @@ DelegatedFrameData frame_out; base::PickleIterator iter(msg); - EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, - &iter, &frame_out)); + EXPECT_TRUE( + IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); ASSERT_EQ(2u, frame_out.resource_list.size()); Compare(arbitrary_resource1, frame_out.resource_list[0]);
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index f9eea01f..4bd0a3f0 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -30,7 +30,6 @@ #include "cc/test/geometry_test_utils.h" #include "cc/test/gpu_rasterization_enabled_settings.h" #include "cc/test/layer_test_common.h" -#include "cc/test/test_layer_tree_host_base.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/test/test_task_graph_runner.h" #include "cc/test/test_web_graphics_context_3d.h" @@ -44,28 +43,28 @@ namespace cc { namespace { -#define EXPECT_BOTH_EQ(expression, x) \ - do { \ - EXPECT_EQ(x, pending_layer()->expression); \ - EXPECT_EQ(x, active_layer()->expression); \ - } while (false) - -#define EXPECT_BOTH_NE(expression, x) \ - do { \ - EXPECT_NE(x, pending_layer()->expression); \ - EXPECT_NE(x, active_layer()->expression); \ - } while (false) - -#define EXPECT_BOTH_TRUE(expression) \ +#define EXPECT_BOTH_EQ(expression, x) \ do { \ - EXPECT_TRUE(pending_layer()->expression); \ - EXPECT_TRUE(active_layer()->expression); \ + EXPECT_EQ(x, pending_layer_->expression); \ + EXPECT_EQ(x, active_layer_->expression); \ } while (false) -#define EXPECT_BOTH_FALSE(expression) \ - do { \ - EXPECT_FALSE(pending_layer()->expression); \ - EXPECT_FALSE(active_layer()->expression); \ +#define EXPECT_BOTH_NE(expression, x) \ + do { \ + EXPECT_NE(x, pending_layer_->expression); \ + EXPECT_NE(x, active_layer_->expression); \ + } while (false) + +#define EXPECT_BOTH_TRUE(expression) \ + do { \ + EXPECT_TRUE(pending_layer_->expression); \ + EXPECT_TRUE(active_layer_->expression); \ + } while (false) + +#define EXPECT_BOTH_FALSE(expression) \ + do { \ + EXPECT_FALSE(pending_layer_->expression); \ + EXPECT_FALSE(active_layer_->expression); \ } while (false) class MockCanvas : public SkCanvas { @@ -80,20 +79,86 @@ std::vector<SkRect> rects_; }; -class PictureLayerImplTest : public TestLayerTreeHostBase { +class PictureLayerImplTestSettings : public GpuRasterizationEnabledSettings { public: - void SetUp() override { - TestLayerTreeHostBase::SetUp(); - host_impl()->SetViewportSize(gfx::Size(10000, 10000)); + PictureLayerImplTestSettings() { + layer_transforms_should_scale_layer_contents = true; + verify_clip_tree_calculations = true; + } +}; + +class NoLowResTilingsSettings : public PictureLayerImplTestSettings {}; + +class LowResTilingsSettings : public PictureLayerImplTestSettings { + public: + LowResTilingsSettings() { create_low_res_tiling = true; } +}; + +class PictureLayerImplTest : public testing::Test { + public: + explicit PictureLayerImplTest(const LayerTreeSettings& settings) + : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), + output_surface_(FakeOutputSurface::Create3d()), + host_impl_(settings, + &task_runner_provider_, + &shared_bitmap_manager_, + &task_graph_runner_), + root_id_(6), + id_(7), + pending_layer_(nullptr), + old_pending_layer_(nullptr), + active_layer_(nullptr) { + host_impl_.SetViewportSize(gfx::Size(10000, 10000)); } - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings; - settings.gpu_rasterization_enabled = true; - settings.layer_transforms_should_scale_layer_contents = true; - settings.create_low_res_tiling = true; - settings.verify_clip_tree_calculations = true; - return settings; + PictureLayerImplTest() : PictureLayerImplTest(LowResTilingsSettings()) {} + + ~PictureLayerImplTest() override {} + + void SetUp() override { InitializeRenderer(); } + + virtual void InitializeRenderer() { + host_impl_.SetVisible(true); + host_impl_.InitializeRenderer(output_surface_.get()); + } + + void SetupDefaultTrees(const gfx::Size& layer_bounds) { + scoped_refptr<FakeRasterSource> pending_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + scoped_refptr<FakeRasterSource> active_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + + SetupTrees(pending_raster_source, active_raster_source); + } + + void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds, + const Region& invalidation) { + scoped_refptr<FakeRasterSource> pending_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + scoped_refptr<FakeRasterSource> active_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + + SetupTreesWithInvalidation(pending_raster_source, active_raster_source, + invalidation); + } + + void RebuildPropertyTreesOnPendingTree() { + host_impl_.pending_tree()->property_trees()->needs_rebuild = true; + host_impl_.pending_tree()->BuildPropertyTreesForTesting(); + } + + void ActivateTree() { + RebuildPropertyTreesOnPendingTree(); + host_impl_.ActivateSyncTree(); + CHECK(!host_impl_.pending_tree()); + CHECK(host_impl_.recycle_tree()); + old_pending_layer_ = pending_layer_; + pending_layer_ = nullptr; + active_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.active_tree()->LayerById(id_)); + + bool update_lcd_text = false; + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); } void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, @@ -104,9 +169,25 @@ scoped_refptr<FakeRasterSource> active_raster_source = FakeRasterSource::CreateFilled(layer_bounds); - SetupTreesWithFixedTileSize(std::move(pending_raster_source), - std::move(active_raster_source), tile_size, - invalidation); + SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, + tile_size, invalidation); + } + + void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, + scoped_refptr<RasterSource> active_raster_source) { + SetupPendingTree(active_raster_source); + ActivateTree(); + SetupPendingTreeInternal(pending_raster_source, gfx::Size(), Region()); + } + + void SetupTreesWithInvalidation( + scoped_refptr<RasterSource> pending_raster_source, + scoped_refptr<RasterSource> active_raster_source, + const Region& pending_invalidation) { + SetupPendingTreeInternal(active_raster_source, gfx::Size(), Region()); + ActivateTree(); + SetupPendingTreeInternal(pending_raster_source, gfx::Size(), + pending_invalidation); } void SetupTreesWithFixedTileSize( @@ -114,44 +195,77 @@ scoped_refptr<RasterSource> active_raster_source, const gfx::Size& tile_size, const Region& pending_invalidation) { - SetupPendingTree(std::move(active_raster_source), tile_size, Region()); + SetupPendingTreeInternal(active_raster_source, tile_size, Region()); ActivateTree(); - SetupPendingTree(std::move(pending_raster_source), tile_size, - pending_invalidation); + SetupPendingTreeInternal(pending_raster_source, tile_size, + pending_invalidation); } - void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds, - const Region& invalidation) { - scoped_refptr<FakeRasterSource> pending_raster_source = - FakeRasterSource::CreateFilled(layer_bounds); - scoped_refptr<FakeRasterSource> active_raster_source = - FakeRasterSource::CreateFilled(layer_bounds); - - SetupTreesWithInvalidation(std::move(pending_raster_source), - std::move(active_raster_source), invalidation); - } - - void SetupTreesWithInvalidation( - scoped_refptr<RasterSource> pending_raster_source, - scoped_refptr<RasterSource> active_raster_source, - const Region& pending_invalidation) { - SetupPendingTree(std::move(active_raster_source), gfx::Size(), Region()); - ActivateTree(); - SetupPendingTree(std::move(pending_raster_source), gfx::Size(), - pending_invalidation); + void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { + SetupPendingTreeInternal(raster_source, gfx::Size(), Region()); } void SetupPendingTreeWithInvalidation( scoped_refptr<RasterSource> raster_source, const Region& invalidation) { - SetupPendingTree(std::move(raster_source), gfx::Size(), invalidation); + SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation); } void SetupPendingTreeWithFixedTileSize( scoped_refptr<RasterSource> raster_source, const gfx::Size& tile_size, const Region& invalidation) { - SetupPendingTree(std::move(raster_source), tile_size, invalidation); + SetupPendingTreeInternal(raster_source, tile_size, invalidation); + } + + void SetupPendingTreeInternal(scoped_refptr<RasterSource> raster_source, + const gfx::Size& tile_size, + const Region& invalidation) { + host_impl_.CreatePendingTree(); + host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, + 100000.f); + LayerTreeImpl* pending_tree = host_impl_.pending_tree(); + pending_tree->SetDeviceScaleFactor( + host_impl_.active_tree()->device_scale_factor()); + + // Steal from the recycled tree if possible. + LayerImpl* pending_root = pending_tree->root_layer(); + std::unique_ptr<FakePictureLayerImpl> pending_layer; + DCHECK(!pending_root || pending_root->id() == root_id_); + if (!pending_root) { + std::unique_ptr<LayerImpl> new_pending_root = + LayerImpl::Create(pending_tree, root_id_); + pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); + if (!tile_size.IsEmpty()) + pending_layer->set_fixed_tile_size(tile_size); + pending_layer->SetDrawsContent(true); + pending_layer->SetScrollClipLayer(new_pending_root->id()); + pending_root = new_pending_root.get(); + pending_tree->SetRootLayer(std::move(new_pending_root)); + } else { + pending_layer.reset(static_cast<FakePictureLayerImpl*>( + pending_root->RemoveChildForTesting(pending_root->children()[0]) + .release())); + if (!tile_size.IsEmpty()) + pending_layer->set_fixed_tile_size(tile_size); + } + pending_root->test_properties()->force_render_surface = true; + // The bounds() just mirror the raster source size. + pending_layer->SetBounds(raster_source->GetSize()); + pending_layer->SetRasterSourceOnPending(raster_source, invalidation); + + pending_root->AddChild(std::move(pending_layer)); + pending_tree->SetViewportLayersFromIds( + Layer::INVALID_ID, pending_tree->root_layer()->id(), Layer::INVALID_ID, + Layer::INVALID_ID); + + pending_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.pending_tree()->LayerById(id_)); + + // Add tilings/tiles for the layer. + bool update_lcd_text = false; + RebuildPropertyTreesOnPendingTree(); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); } void SetupDrawProperties(FakePictureLayerImpl* layer, @@ -162,7 +276,7 @@ float starting_animation_contents_scale, bool animating_transform_to_screen) { layer->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); - host_impl()->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); + host_impl_.active_tree()->SetPageScaleOnActiveTree(page_scale_factor); gfx::Transform scale_transform; scale_transform.Scale(ideal_contents_scale, ideal_contents_scale); @@ -215,29 +329,29 @@ float starting_animation_contents_scale, bool animating_transform) { SetupDrawPropertiesAndUpdateTiles( - pending_layer(), contents_scale, device_scale_factor, page_scale_factor, + pending_layer_, contents_scale, device_scale_factor, page_scale_factor, maximum_animation_contents_scale, starting_animation_contents_scale, animating_transform); SetupDrawPropertiesAndUpdateTiles( - active_layer(), contents_scale, device_scale_factor, page_scale_factor, + active_layer_, contents_scale, device_scale_factor, page_scale_factor, maximum_animation_contents_scale, starting_animation_contents_scale, animating_transform); } void ResetTilingsAndRasterScales() { - if (pending_layer()) { - pending_layer()->ReleaseResources(); - EXPECT_FALSE(pending_layer()->tilings()); - pending_layer()->RecreateResources(); - EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); + if (pending_layer_) { + pending_layer_->ReleaseResources(); + EXPECT_FALSE(pending_layer_->tilings()); + pending_layer_->RecreateResources(); + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); } - if (active_layer()) { - active_layer()->ReleaseResources(); - EXPECT_FALSE(active_layer()->tilings()); - active_layer()->RecreateResources(); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + if (active_layer_) { + active_layer_->ReleaseResources(); + EXPECT_FALSE(active_layer_->tilings()); + active_layer_->RecreateResources(); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); } } @@ -268,23 +382,35 @@ void SetInitialDeviceScaleFactor(float device_scale_factor) { // Device scale factor is a per-tree property. However, tests can't directly // set the pending tree's device scale factor before the pending tree is - // created, and setting it after SetupPendingTreeis too late, since + // created, and setting it after SetupPendingTreeInternal is too late, since // draw properties will already have been updated on the tree. To handle // this, we initially set only the active tree's device scale factor, and we - // copy this over to the pending tree inside SetupPendingTree. - host_impl()->active_tree()->SetDeviceScaleFactor(device_scale_factor); + // copy this over to the pending tree inside SetupPendingTreeInternal. + host_impl_.active_tree()->SetDeviceScaleFactor(device_scale_factor); } + protected: void TestQuadsForSolidColor(bool test_for_solid); + + FakeImplTaskRunnerProvider task_runner_provider_; + TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; + std::unique_ptr<OutputSurface> output_surface_; + FakeLayerTreeHostImpl host_impl_; + int root_id_; + int id_; + FakePictureLayerImpl* pending_layer_; + FakePictureLayerImpl* old_pending_layer_; + FakePictureLayerImpl* active_layer_; + + private: + DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); }; class NoLowResPictureLayerImplTest : public PictureLayerImplTest { public: - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings = PictureLayerImplTest::CreateSettings(); - settings.create_low_res_tiling = false; - return settings; - } + NoLowResPictureLayerImplTest() + : PictureLayerImplTest(NoLowResTilingsSettings()) {} }; TEST_F(PictureLayerImplTest, TileGridAlignment) { @@ -312,9 +438,9 @@ // Add 1x1 rects at the centers of each tile, then re-record recording source // contents. - active_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); + active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); std::vector<Tile*> tiles = - active_layer()->tilings()->tiling_at(0)->AllTilesForTesting(); + active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); EXPECT_EQ(16u, tiles.size()); std::vector<SkRect> rects; std::vector<Tile*>::const_iterator tile_iter; @@ -356,42 +482,42 @@ gfx::Size layer_bounds(400, 400); SetupDefaultTrees(layer_bounds); - EXPECT_EQ(pending_layer()->tilings()->num_tilings(), - active_layer()->tilings()->num_tilings()); + EXPECT_EQ(pending_layer_->tilings()->num_tilings(), + active_layer_->tilings()->num_tilings()); - const PictureLayerTilingSet* tilings = pending_layer()->tilings(); + const PictureLayerTilingSet* tilings = pending_layer_->tilings(); EXPECT_GT(tilings->num_tilings(), 0u); for (size_t i = 0; i < tilings->num_tilings(); ++i) EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty()); } TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(400, 400); SetupDefaultTrees(layer_bounds); - SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the // identify transform for tile priority. gfx::Rect viewport_rect_for_tile_priority = gfx::Rect(0, 0, 100, 100); gfx::Transform transform, transform_for_tile_priority; - host_impl()->SetExternalTilePriorityConstraints( - viewport_rect_for_tile_priority, transform_for_tile_priority); + host_impl_.SetExternalTilePriorityConstraints(viewport_rect_for_tile_priority, + transform_for_tile_priority); bool update_lcd_text = false; - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); gfx::Rect viewport_rect_for_tile_priority_in_view_space = viewport_rect_for_tile_priority; // Verify the viewport rect for tile priority is used in picture layer tiling. EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, - active_layer()->viewport_rect_for_tile_priority_in_content_space()); - PictureLayerTilingSet* tilings = active_layer()->tilings(); + active_layer_->viewport_rect_for_tile_priority_in_content_space()); + PictureLayerTilingSet* tilings = active_layer_->tilings(); for (size_t i = 0; i < tilings->num_tilings(); i++) { PictureLayerTiling* tiling = tilings->tiling_at(i); EXPECT_EQ( @@ -404,14 +530,14 @@ // screen space and the transform for tile priority is translated and // rotated. The actual viewport for tile priority used by PictureLayerImpl // should be (200, 200, 100, 100) applied with the said transform. - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); transform_for_tile_priority.Translate(100, 100); transform_for_tile_priority.Rotate(45); - host_impl()->SetExternalTilePriorityConstraints( - viewport_rect_for_tile_priority, transform_for_tile_priority); - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.SetExternalTilePriorityConstraints(viewport_rect_for_tile_priority, + transform_for_tile_priority); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); gfx::Transform screen_to_view(gfx::Transform::kSkipInitialization); bool success = transform_for_tile_priority.GetInverse(&screen_to_view); @@ -426,8 +552,8 @@ viewport_rect_for_tile_priority); EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, - active_layer()->viewport_rect_for_tile_priority_in_content_space()); - tilings = active_layer()->tilings(); + active_layer_->viewport_rect_for_tile_priority_in_content_space()); + tilings = active_layer_->tilings(); for (size_t i = 0; i < tilings->num_tilings(); i++) { PictureLayerTiling* tiling = tilings->tiling_at(i); EXPECT_EQ( @@ -438,42 +564,42 @@ } TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(400, 400); SetupDefaultTrees(layer_bounds); - SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); gfx::Transform transform_for_tile_priority; - host_impl()->SetExternalTilePriorityConstraints( - viewport_rect_for_tile_priority, transform_for_tile_priority); + host_impl_.SetExternalTilePriorityConstraints(viewport_rect_for_tile_priority, + transform_for_tile_priority); bool update_lcd_text = false; - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); EXPECT_EQ(viewport_rect_for_tile_priority, - active_layer()->viewport_rect_for_tile_priority_in_content_space()); + active_layer_->viewport_rect_for_tile_priority_in_content_space()); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); gfx::Rect another_viewport_rect_for_tile_priority(11, 11, 50, 50); - host_impl()->SetExternalTilePriorityConstraints( + host_impl_.SetExternalTilePriorityConstraints( another_viewport_rect_for_tile_priority, transform_for_tile_priority); // Didn't call UpdateDrawProperties yet. The viewport rect for tile priority // should remain to be the previously cached value. EXPECT_EQ(viewport_rect_for_tile_priority, - active_layer()->viewport_rect_for_tile_priority_in_content_space()); - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); + active_layer_->viewport_rect_for_tile_priority_in_content_space()); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); // Now the UpdateDrawProperties is called. The viewport rect for tile // priority should be the latest value. EXPECT_EQ(another_viewport_rect_for_tile_priority, - active_layer()->viewport_rect_for_tile_priority_in_content_space()); + active_layer_->viewport_rect_for_tile_priority_in_content_space()); } TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { @@ -491,21 +617,21 @@ Region()); ActivateTree(); // Add a unique tiling on the active tree. - PictureLayerTiling* tiling = active_layer()->AddTiling(3.f); + PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); tiling->set_resolution(HIGH_RESOLUTION); tiling->CreateAllTilesForTesting(); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Then setup a new pending tree and activate it. SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, gfx::Size(50, 50), layer_invalidation); - EXPECT_EQ(1u, pending_layer()->num_tilings()); - EXPECT_EQ(3u, active_layer()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); + EXPECT_EQ(3u, active_layer_->num_tilings()); - const PictureLayerTilingSet* tilings = pending_layer()->tilings(); + const PictureLayerTilingSet* tilings = pending_layer_->tilings(); EXPECT_GT(tilings->num_tilings(), 0u); for (size_t i = 0; i < tilings->num_tilings(); ++i) { const PictureLayerTiling* tiling = tilings->tiling_at(i); @@ -534,7 +660,7 @@ } } - tilings = active_layer()->tilings(); + tilings = active_layer_->tilings(); EXPECT_GT(tilings->num_tilings(), 0u); for (size_t i = 0; i < tilings->num_tilings(); ++i) { const PictureLayerTiling* tiling = tilings->tiling_at(i); @@ -568,10 +694,10 @@ SetupTreesWithInvalidation(pending_raster_source, active_raster_source, gfx::Rect(layer_bounds)); - EXPECT_EQ(pending_layer()->tilings()->num_tilings(), - active_layer()->tilings()->num_tilings()); + EXPECT_EQ(pending_layer_->tilings()->num_tilings(), + active_layer_->tilings()->num_tilings()); - const PictureLayerTilingSet* tilings = pending_layer()->tilings(); + const PictureLayerTilingSet* tilings = pending_layer_->tilings(); EXPECT_GT(tilings->num_tilings(), 0u); for (size_t i = 0; i < tilings->num_tilings(); ++i) { VerifyAllPrioritizedTilesExistAndHaveRasterSource( @@ -583,130 +709,130 @@ gfx::Size layer_bounds(1300, 1900); SetupDefaultTrees(layer_bounds); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - active_layer()->ReleaseResources(); - EXPECT_FALSE(active_layer()->tilings()); - active_layer()->RecreateResources(); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + active_layer_->ReleaseResources(); + EXPECT_FALSE(active_layer_->tilings()); + active_layer_->RecreateResources(); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 6.f, // ideal contents scale 3.f, // device scale 2.f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(6.f * low_res_factor, - active_layer()->tilings()->tiling_at(1)->contents_scale()); + active_layer_->tilings()->tiling_at(1)->contents_scale()); // If we change the page scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 6.6f, // ideal contents scale 3.f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.6f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(6.6f * low_res_factor, - active_layer()->tilings()->tiling_at(2)->contents_scale()); + active_layer_->tilings()->tiling_at(2)->contents_scale()); // If we change the device scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 7.26f, // ideal contents scale 3.3f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(7.26f * low_res_factor, - active_layer()->tilings()->tiling_at(3)->contents_scale()); + active_layer_->tilings()->tiling_at(3)->contents_scale()); // If we change the device scale factor, but end up at the same total scale // factor somehow, then we don't get new tilings. - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 7.26f, // ideal contents scale 2.2f, // device scale 3.3f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(7.26f * low_res_factor, - active_layer()->tilings()->tiling_at(3)->contents_scale()); + active_layer_->tilings()->tiling_at(3)->contents_scale()); } TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { gfx::Size layer_bounds(1300, 1900); SetupDefaultTrees(layer_bounds); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); - pending_layer()->ReleaseResources(); - EXPECT_FALSE(pending_layer()->tilings()); - pending_layer()->RecreateResources(); - EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); + pending_layer_->ReleaseResources(); + EXPECT_FALSE(pending_layer_->tilings()); + pending_layer_->RecreateResources(); + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 6.f, // ideal contents scale 3.f, // device scale 2.f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the page scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 6.6f, // ideal contents scale 3.f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.6f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 7.26f, // ideal contents scale 3.3f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, but end up at the same total scale // factor somehow, then we don't get new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 7.26f, // ideal contents scale 2.2f, // device scale 3.3f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); } TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { @@ -721,21 +847,21 @@ FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(valid_raster_source); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); ActivateTree(); SetupPendingTree(empty_raster_source); - EXPECT_FALSE(pending_layer()->CanHaveTilings()); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); - ASSERT_EQ(0u, pending_layer()->tilings()->num_tilings()); + EXPECT_FALSE(pending_layer_->CanHaveTilings()); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); + ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); ActivateTree(); - EXPECT_FALSE(active_layer()->CanHaveTilings()); - ASSERT_EQ(0u, active_layer()->tilings()->num_tilings()); + EXPECT_FALSE(active_layer_->CanHaveTilings()); + ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); SetupPendingTree(valid_raster_source); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); - ASSERT_EQ(0u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); + ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, LowResTilingStaysOnActiveTree) { @@ -747,20 +873,20 @@ FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(valid_raster_source); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); ActivateTree(); SetupPendingTree(other_valid_raster_source); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); auto* low_res_tiling = - active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION); + active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION); EXPECT_TRUE(low_res_tiling); ActivateTree(); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); auto* other_low_res_tiling = - active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION); + active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION); EXPECT_TRUE(other_low_res_tiling); EXPECT_EQ(low_res_tiling, other_low_res_tiling); } @@ -771,93 +897,93 @@ // Set up the high and low res tilings before pinch zoom. SetupDefaultTrees(layer_bounds); ResetTilingsAndRasterScales(); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); - EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale()); - host_impl()->PinchGestureBegin(); + EXPECT_EQ(32.f, active_layer_->HighResTiling()->contents_scale()); + host_impl_.PinchGestureBegin(); SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); - EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1); + EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); } TEST_F(PictureLayerImplTest, PinchGestureTilings) { gfx::Size layer_bounds(1300, 1900); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; // Set up the high and low res tilings before pinch zoom. SetupDefaultTrees(layer_bounds); ResetTilingsAndRasterScales(); SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); - EXPECT_EQ(active_layer()->num_tilings(), 2u); - EXPECT_EQ(pending_layer()->num_tilings(), 1u); - EXPECT_EQ(active_layer()->tilings()->tiling_at(0)->contents_scale(), 2.f); - EXPECT_EQ(active_layer()->tilings()->tiling_at(1)->contents_scale(), + EXPECT_EQ(active_layer_->num_tilings(), 2u); + EXPECT_EQ(pending_layer_->num_tilings(), 1u); + EXPECT_EQ(active_layer_->tilings()->tiling_at(0)->contents_scale(), 2.f); + EXPECT_EQ(active_layer_->tilings()->tiling_at(1)->contents_scale(), 2.f * low_res_factor); // One of the tilings has to be a low resolution one. EXPECT_EQ(LOW_RESOLUTION, - active_layer()->tilings()->tiling_at(1)->resolution()); + active_layer_->tilings()->tiling_at(1)->resolution()); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Start a pinch gesture. - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); // Zoom out by a small amount. We should create a tiling at half // the scale (2/kMaxScaleRatioDuringPinch). SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, 0.f, false); - EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(2.0f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(1.0f, - active_layer()->tilings()->tiling_at(1)->contents_scale()); + active_layer_->tilings()->tiling_at(1)->contents_scale()); EXPECT_FLOAT_EQ(2.0f * low_res_factor, - active_layer()->tilings()->tiling_at(2)->contents_scale()); + active_layer_->tilings()->tiling_at(2)->contents_scale()); // Since we're pinching, we shouldn't create a low resolution tiling. EXPECT_FALSE( - active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); + active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Zoom out further, close to our low-res scale factor. We should // use that tiling as high-res, and not create a new tiling. SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, low_res_factor * 2.1f, 1.0f, 0.f, false); - EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); EXPECT_FALSE( - active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); + active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); // Zoom in a lot now. Since we increase by increments of // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, 0.f, false); - EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(4.0f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); // Although one of the tilings matches the low resolution scale, it still // shouldn't be marked as low resolution since we're pinching. auto* low_res_tiling = - active_layer()->tilings()->FindTilingWithScale(4.f * low_res_factor); + active_layer_->tilings()->FindTilingWithScale(4.f * low_res_factor); EXPECT_TRUE(low_res_tiling); EXPECT_NE(LOW_RESOLUTION, low_res_tiling->resolution()); // Stop a pinch gesture. - host_impl()->PinchGestureEnd(); + host_impl_.PinchGestureEnd(); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // After pinch ends, set the scale to what the raster scale was updated to // (checked above). SetContentsScaleOnBothLayers(4.0f, 1.0f, 4.0f, 1.f, 0.f, false); - EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(4.0f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); // Now that we stopped pinching, the low resolution tiling that existed should // now be marked as low resolution. low_res_tiling = - active_layer()->tilings()->FindTilingWithScale(4.f * low_res_factor); + active_layer_->tilings()->FindTilingWithScale(4.f * low_res_factor); EXPECT_TRUE(low_res_tiling); EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); } @@ -867,52 +993,52 @@ SetupDefaultTrees(layer_bounds); ResetTilingsAndRasterScales(); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); // Set up the high and low res tilings before pinch zoom. SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); - EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(0.24f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(0.0625f, - active_layer()->tilings()->tiling_at(1)->contents_scale()); + active_layer_->tilings()->tiling_at(1)->contents_scale()); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Start a pinch gesture. - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); // Zoom out by a small amount. We should create a tiling at half // the scale (1/kMaxScaleRatioDuringPinch). SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, 0.f, false); - EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(0.24f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); EXPECT_FLOAT_EQ(0.12f, - active_layer()->tilings()->tiling_at(1)->contents_scale()); + active_layer_->tilings()->tiling_at(1)->contents_scale()); EXPECT_FLOAT_EQ(0.0625, - active_layer()->tilings()->tiling_at(2)->contents_scale()); + active_layer_->tilings()->tiling_at(2)->contents_scale()); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Zoom out further, close to our low-res scale factor. We should // use that tiling as high-res, and not create a new tiling. SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, 0.f, false); - EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in // because 0.25(desired_scale) is within the ratio(1.2). SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, 0.f, false); - EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); // Zoom in a lot. Since we move in factors of two, we should get a scale that // is a power of 2 times 0.24. SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); - EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(1.92f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); } TEST_F(PictureLayerImplTest, CleanUpTilings) { @@ -920,60 +1046,62 @@ std::vector<PictureLayerTiling*> used_tilings; - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); float scale = 1.f; float page_scale = 1.f; SetupDefaultTrees(layer_bounds); - EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); - EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale()); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); + EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to - // |used_tilings| variable, and it's here only to ensure that active_layer() + // |used_tilings| variable, and it's here only to ensure that active_layer_ // won't remove tilings before the test has a chance to verify behavior. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // We only have ideal tilings, so they aren't removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); // Changing the ideal but not creating new tilings. scale = 1.5f; page_scale = 1.5f; SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, 0.f, false); - EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); // The tilings are still our target scale, so they aren't removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); - host_impl()->PinchGestureEnd(); + host_impl_.PinchGestureEnd(); // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. scale = 1.2f; page_scale = 1.2f; SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, 0.f, false); - ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); - EXPECT_FLOAT_EQ(1.f, - active_layer()->tilings()->tiling_at(1)->contents_scale()); - EXPECT_FLOAT_EQ(1.f * low_res_factor, - active_layer()->tilings()->tiling_at(3)->contents_scale()); + ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); + EXPECT_FLOAT_EQ( + 1.f, + active_layer_->tilings()->tiling_at(1)->contents_scale()); + EXPECT_FLOAT_EQ( + 1.f * low_res_factor, + active_layer_->tilings()->tiling_at(3)->contents_scale()); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Mark the non-ideal tilings as used. They won't be removed. used_tilings.clear(); - used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); - used_tilings.push_back(active_layer()->tilings()->tiling_at(3)); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); + used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); + used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 0.5. Our target stays 1.2. SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); @@ -981,8 +1109,8 @@ // The high resolution tiling is between target and ideal, so is not // removed. The low res tiling for the old ideal=1.0 scale is removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 1.0. Our target stays 1.2. SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); @@ -990,48 +1118,48 @@ // All the tilings are between are target and the ideal, so they are not // removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. - SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.1f, 1.f, page_scale, 1.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, 1.f, page_scale, 1.f, 0.f, false); // Because the pending layer's ideal scale is still 1.0, our tilings fall // in the range [1.0,1.2] and are kept. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); // Move the ideal scale on the pending layer to 1.1 as well. Our target stays // 1.2 still. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.1f, 1.f, page_scale, 1.f, + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, 1.f, page_scale, 1.f, 0.f, false); // Our 1.0 tiling now falls outside the range between our ideal scale and our // target raster scale. But it is in our used tilings set, so nothing is // deleted. used_tilings.clear(); - used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); + used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); // If we remove it from our used tilings set, it is outside the range to keep // so it is deleted. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { // Make sure this layer covers multiple tiles, since otherwise low // res won't get created because it is too small. - gfx::Size tile_size(host_impl()->settings().default_tile_size); + gfx::Size tile_size(host_impl_.settings().default_tile_size); // Avoid max untiled layer size heuristics via fixed tile size. gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; float contents_scale = 1.f; float device_scale = 1.f; float page_scale = 1.f; @@ -1054,12 +1182,12 @@ maximum_animation_scale, starting_animation_scale, animating_transform); EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); - EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), low_res_factor); - EXPECT_EQ(active_layer()->num_tilings(), 2u); - EXPECT_EQ(pending_layer()->num_tilings(), 1u); + EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), low_res_factor); + EXPECT_EQ(active_layer_->num_tilings(), 2u); + EXPECT_EQ(pending_layer_->num_tilings(), 1u); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Page scale animation, new high res, but no low res. We still have // a tiling at the previous scale, it's just not marked as low res on the @@ -1072,10 +1200,10 @@ maximum_animation_scale, starting_animation_scale, animating_transform); EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); - EXPECT_FALSE(active_layer()->LowResTiling()); - EXPECT_FALSE(pending_layer()->LowResTiling()); - EXPECT_EQ(3u, active_layer()->num_tilings()); - EXPECT_EQ(1u, pending_layer()->num_tilings()); + EXPECT_FALSE(active_layer_->LowResTiling()); + EXPECT_FALSE(pending_layer_->LowResTiling()); + EXPECT_EQ(3u, active_layer_->num_tilings()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); // Stop animating, new low res gets created for final page scale. animating_transform = false; @@ -1083,14 +1211,14 @@ maximum_animation_scale, starting_animation_scale, animating_transform); EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); - EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), + EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), 2.f * low_res_factor); - EXPECT_EQ(4u, active_layer()->num_tilings()); - EXPECT_EQ(1u, pending_layer()->num_tilings()); + EXPECT_EQ(4u, active_layer_->num_tilings()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); } TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { - gfx::Size layer_bounds(host_impl()->settings().default_tile_size); + gfx::Size layer_bounds(host_impl_.settings().default_tile_size); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); @@ -1099,7 +1227,7 @@ SetupTrees(pending_raster_source, active_raster_source); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; float device_scale = 1.f; float page_scale = 1.f; float maximum_animation_scale = 1.f; @@ -1134,25 +1262,25 @@ maximum_animation_scale, starting_animation_scale, animating_transform); EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); - EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), + EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), contents_scale * low_res_factor); - EXPECT_FALSE(pending_layer()->LowResTiling()); - EXPECT_EQ(active_layer()->num_tilings(), 2u); - EXPECT_EQ(pending_layer()->num_tilings(), 1u); + EXPECT_FALSE(pending_layer_->LowResTiling()); + EXPECT_EQ(active_layer_->num_tilings(), 2u); + EXPECT_EQ(pending_layer_->num_tilings(), 1u); // Mask layers dont create low res since they always fit on one tile. std::unique_ptr<FakePictureLayerImpl> mask = FakePictureLayerImpl::CreateMaskWithRasterSource( - host_impl()->pending_tree(), 3, pending_raster_source); + host_impl_.pending_tree(), 3, pending_raster_source); mask->SetBounds(layer_bounds); mask->SetDrawsContent(true); - pending_layer()->SetMaskLayer(std::move(mask)); - pending_layer()->SetHasRenderSurface(true); + pending_layer_->SetMaskLayer(std::move(mask)); + pending_layer_->SetHasRenderSurface(true); RebuildPropertyTreesOnPendingTree(); - host_impl()->pending_tree()->UpdateDrawProperties(false); + host_impl_.pending_tree()->UpdateDrawProperties(false); FakePictureLayerImpl* mask_raw = - static_cast<FakePictureLayerImpl*>(pending_layer()->mask_layer()); + static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); // We did an UpdateDrawProperties above, which will set a contents scale on // the mask layer, so allow us to reset the contents scale. mask_raw->ReleaseResources(); @@ -1166,7 +1294,7 @@ } TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(1000, 1000); @@ -1176,30 +1304,30 @@ std::unique_ptr<FakePictureLayerImpl> mask_ptr = FakePictureLayerImpl::CreateMaskWithRasterSource( - host_impl()->pending_tree(), 3, valid_raster_source); + host_impl_.pending_tree(), 3, valid_raster_source); mask_ptr->SetBounds(layer_bounds); mask_ptr->SetDrawsContent(true); - pending_layer()->SetMaskLayer(std::move(mask_ptr)); - pending_layer()->test_properties()->force_render_surface = true; + pending_layer_->SetMaskLayer(std::move(mask_ptr)); + pending_layer_->test_properties()->force_render_surface = true; RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); FakePictureLayerImpl* pending_mask = - static_cast<FakePictureLayerImpl*>(pending_layer()->mask_layer()); + static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); EXPECT_EQ(1u, pending_mask->num_tilings()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( pending_mask->HighResTiling()->AllTilesForTesting()); ActivateTree(); FakePictureLayerImpl* active_mask = - static_cast<FakePictureLayerImpl*>(active_layer()->mask_layer()); + static_cast<FakePictureLayerImpl*>(active_layer_->mask_layer()); // Mask layers have a tiling with a single tile in it. EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); @@ -1223,8 +1351,7 @@ EXPECT_EQ(active_mask->bounds(), mask_texture_size); // Resize larger than the max texture size. - int max_texture_size = - host_impl()->GetRendererCapabilities().max_texture_size; + int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; gfx::Size huge_bounds(max_texture_size + 1, 10); scoped_refptr<FakeRasterSource> huge_raster_source = FakeRasterSource::CreateFilled(huge_bounds); @@ -1233,14 +1360,14 @@ pending_mask->SetBounds(huge_bounds); pending_mask->SetRasterSourceOnPending(huge_raster_source, Region()); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); // The mask tiling gets scaled down. EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); EXPECT_EQ(1u, pending_mask->num_tilings()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( pending_mask->HighResTiling()->AllTilesForTesting()); ActivateTree(); @@ -1270,13 +1397,13 @@ SetupPendingTree(huge_raster_source); ActivateTree(); EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); - active_layer()->GetContentsResourceId(&mask_resource_id, &mask_texture_size); + active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); EXPECT_EQ(expected_size, mask_texture_size); EXPECT_EQ(0u, mask_resource_id); // Resize even larger, so that the scale would be smaller than the minimum // contents scale. Then the layer should no longer have any tiling. - float min_contents_scale = host_impl()->settings().minimum_contents_scale; + float min_contents_scale = host_impl_.settings().minimum_contents_scale; gfx::Size extra_huge_bounds(max_texture_size / min_contents_scale + 1, 10); scoped_refptr<FakeRasterSource> extra_huge_raster_source = FakeRasterSource::CreateFilled(extra_huge_bounds); @@ -1287,14 +1414,14 @@ EXPECT_FALSE(pending_mask->CanHaveTilings()); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); EXPECT_EQ(0u, pending_mask->num_tilings()); } TEST_F(PictureLayerImplTest, ScaledMaskLayer) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(1000, 1000); @@ -1306,31 +1433,31 @@ std::unique_ptr<FakePictureLayerImpl> mask_ptr = FakePictureLayerImpl::CreateMaskWithRasterSource( - host_impl()->pending_tree(), 3, valid_raster_source); + host_impl_.pending_tree(), 3, valid_raster_source); mask_ptr->SetBounds(layer_bounds); mask_ptr->SetDrawsContent(true); - pending_layer()->SetMaskLayer(std::move(mask_ptr)); - pending_layer()->test_properties()->force_render_surface = true; + pending_layer_->SetMaskLayer(std::move(mask_ptr)); + pending_layer_->test_properties()->force_render_surface = true; RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); FakePictureLayerImpl* pending_mask = - static_cast<FakePictureLayerImpl*>(pending_layer()->mask_layer()); + static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); // Masks are scaled, and do not have a low res tiling. EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); EXPECT_EQ(1u, pending_mask->num_tilings()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( pending_mask->HighResTiling()->AllTilesForTesting()); ActivateTree(); FakePictureLayerImpl* active_mask = - static_cast<FakePictureLayerImpl*>(active_layer()->mask_layer()); + static_cast<FakePictureLayerImpl*>(active_layer_->mask_layer()); // Mask layers have a tiling with a single tile in it. EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); @@ -1347,27 +1474,27 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { gfx::Size layer_bounds(1300, 1900); SetupDefaultTrees(layer_bounds); - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); // All tilings should be removed when losing output surface. - active_layer()->ReleaseResources(); - EXPECT_FALSE(active_layer()->tilings()); - active_layer()->RecreateResources(); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); - pending_layer()->ReleaseResources(); - EXPECT_FALSE(pending_layer()->tilings()); - pending_layer()->RecreateResources(); - EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); + active_layer_->ReleaseResources(); + EXPECT_FALSE(active_layer_->tilings()); + active_layer_->RecreateResources(); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); + pending_layer_->ReleaseResources(); + EXPECT_FALSE(pending_layer_->tilings()); + pending_layer_->RecreateResources(); + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); // This should create new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, // ideal contents scale 1.f, // device scale 1.f, // page scale 1.f, // maximum animation scale 0.f, // starting animation_scale false); - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { @@ -1377,16 +1504,15 @@ FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(pending_raster_source); - EXPECT_GE(pending_layer()->tilings()->num_tilings(), 1u); + EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); - pending_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); + pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); // The default value. EXPECT_EQ(gfx::Size(256, 256).ToString(), - host_impl()->settings().default_tile_size.ToString()); + host_impl_.settings().default_tile_size.ToString()); - Tile* tile = - pending_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; + Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; EXPECT_EQ(gfx::Size(256, 256).ToString(), tile->content_rect().size().ToString()); @@ -1396,16 +1522,21 @@ std::unique_ptr<TestWebGraphicsContext3D> context = TestWebGraphicsContext3D::Create(); context->set_max_texture_size(140); - ResetOutputSurface(FakeOutputSurface::Create3d(std::move(context))); + host_impl_.DidLoseOutputSurface(); + std::unique_ptr<OutputSurface> new_output_surface = + FakeOutputSurface::Create3d(std::move(context)); + host_impl_.SetVisible(true); + host_impl_.InitializeRenderer(new_output_surface.get()); + output_surface_ = std::move(new_output_surface); - SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); - pending_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); + pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); // Verify the tiles are not larger than the context's max texture size. - tile = pending_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; + tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; EXPECT_GE(140, tile->content_rect().width()); EXPECT_GE(140, tile->content_rect().height()); } @@ -1413,16 +1544,16 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { gfx::Size layer_bounds(500, 500); SetupDefaultTrees(layer_bounds); - EXPECT_GE(active_layer()->tilings()->num_tilings(), 1u); + EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u); - active_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); + active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); // The default value. The layer is smaller than this. EXPECT_EQ(gfx::Size(512, 512).ToString(), - host_impl()->settings().max_untiled_layer_size.ToString()); + host_impl_.settings().max_untiled_layer_size.ToString()); // There should be a single tile since the layer is small. - PictureLayerTiling* high_res_tiling = active_layer()->tilings()->tiling_at(0); + PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); ResetTilingsAndRasterScales(); @@ -1431,21 +1562,26 @@ std::unique_ptr<TestWebGraphicsContext3D> context = TestWebGraphicsContext3D::Create(); context->set_max_texture_size(140); - ResetOutputSurface(FakeOutputSurface::Create3d(std::move(context))); + host_impl_.DidLoseOutputSurface(); + std::unique_ptr<OutputSurface> new_output_surface = + FakeOutputSurface::Create3d(std::move(context)); + host_impl_.SetVisible(true); + host_impl_.InitializeRenderer(new_output_surface.get()); + output_surface_ = std::move(new_output_surface); - SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - ASSERT_LE(1u, active_layer()->tilings()->num_tilings()); + ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); - active_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); + active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); // There should be more than one tile since the max texture size won't cover // the layer. - high_res_tiling = active_layer()->tilings()->tiling_at(0); + high_res_tiling = active_layer_->tilings()->tiling_at(0); EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); // Verify the tiles are not larger than the context's max texture size. - Tile* tile = active_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; + Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; EXPECT_GE(140, tile->content_rect().width()); EXPECT_GE(140, tile->content_rect().height()); } @@ -1459,14 +1595,13 @@ gfx::Rect layer_invalidation(150, 200, 30, 180); SetupDefaultTreesWithInvalidation(layer_bounds, layer_invalidation); - active_layer()->SetContentsOpaque(true); - active_layer()->draw_properties().visible_layer_rect = - gfx::Rect(layer_bounds); + active_layer_->SetContentsOpaque(true); + active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); ASSERT_EQ(1u, render_pass->quad_list.size()); EXPECT_EQ(DrawQuad::PICTURE_CONTENT, @@ -1491,14 +1626,14 @@ SetupPendingTree(active_raster_source); ActivateTree(); - active_layer()->SetContentsOpaque(true); + active_layer_->SetContentsOpaque(true); gfx::Rect visible_rect(30, 35, 10, 5); - active_layer()->draw_properties().visible_layer_rect = visible_rect; + active_layer_->draw_properties().visible_layer_rect = visible_rect; AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); gfx::Rect scaled_visible = gfx::ScaleToEnclosingRect(visible_rect, 2.f); gfx::Rect scaled_recorded = gfx::ScaleToEnclosingRect(recorded_viewport, 2.f); @@ -1522,14 +1657,13 @@ SetupPendingTree(active_raster_source); ActivateTree(); - active_layer()->SetContentsOpaque(true); - active_layer()->draw_properties().visible_layer_rect = - gfx::Rect(layer_bounds); + active_layer_->SetContentsOpaque(true); + active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); EXPECT_EQ(0U, render_pass->quad_list.size()); } @@ -1547,12 +1681,12 @@ SetupTrees(pending_raster_source, active_raster_source); - active_layer()->draw_properties().visible_layer_rect = visible_rect; + active_layer_->draw_properties().visible_layer_rect = visible_rect; AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); Region remaining = visible_rect; for (const auto& quad : render_pass->quad_list) { @@ -1573,14 +1707,14 @@ SetupTrees(pending_raster_source, active_raster_source); // Solid color raster source should not allow tilings at any scale. - EXPECT_FALSE(active_layer()->CanHaveTilings()); - EXPECT_EQ(0.f, active_layer()->ideal_contents_scale()); + EXPECT_FALSE(active_layer_->CanHaveTilings()); + EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); // Activate non-solid-color pending raster source makes active layer can have // tilings. ActivateTree(); - EXPECT_TRUE(active_layer()->CanHaveTilings()); - EXPECT_GT(active_layer()->ideal_contents_scale(), 0.f); + EXPECT_TRUE(active_layer_->CanHaveTilings()); + EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); } TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) { @@ -1588,27 +1722,26 @@ gfx::Transform transform; gfx::Rect viewport(0, 0, 100, 200); - host_impl()->SetExternalTilePriorityConstraints(viewport, transform); + host_impl_.SetExternalTilePriorityConstraints(viewport, transform); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTreeWithFixedTileSize(pending_raster_source, gfx::Size(100, 100), Region()); - EXPECT_EQ(1u, pending_layer()->num_tilings()); - EXPECT_EQ( - viewport, - pending_layer()->viewport_rect_for_tile_priority_in_content_space()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); + EXPECT_EQ(viewport, + pending_layer_->viewport_rect_for_tile_priority_in_content_space()); base::TimeTicks time_ticks; - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); - pending_layer()->UpdateTiles(); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + pending_layer_->UpdateTiles(); int num_visible = 0; int num_offscreen = 0; std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), false)); + pending_layer_->picture_layer_tiling_set(), false)); for (; !queue->IsEmpty(); queue->Pop()) { const PrioritizedTile& prioritized_tile = queue->Top(); DCHECK(prioritized_tile.tile()); @@ -1627,7 +1760,7 @@ TEST_F(NoLowResPictureLayerImplTest, TileOutsideOfViewportForTilePriorityNotRequired) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(400, 400); @@ -1636,37 +1769,37 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); - ASSERT_EQ(1u, pending_layer()->num_tilings()); - ASSERT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); + ASSERT_EQ(1u, pending_layer_->num_tilings()); + ASSERT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); // Set external viewport for tile priority. gfx::Rect viewport = gfx::Rect(layer_bounds); gfx::Transform transform; gfx::Transform transform_for_tile_priority; - host_impl()->SetExternalTilePriorityConstraints( + host_impl_.SetExternalTilePriorityConstraints( external_viewport_for_tile_priority, transform_for_tile_priority); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); // Set visible content rect that is different from // external_viewport_for_tile_priority. - pending_layer()->draw_properties().visible_layer_rect = visible_layer_rect; - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); - pending_layer()->UpdateTiles(); + pending_layer_->draw_properties().visible_layer_rect = visible_layer_rect; + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + pending_layer_->UpdateTiles(); // Intersect the two rects. Any tile outside should not be required for // activation. gfx::Rect viewport_for_tile_priority = - pending_layer()->viewport_rect_for_tile_priority_in_content_space(); - viewport_for_tile_priority.Intersect(pending_layer()->visible_layer_rect()); + pending_layer_->viewport_rect_for_tile_priority_in_content_space(); + viewport_for_tile_priority.Intersect(pending_layer_->visible_layer_rect()); - EXPECT_TRUE(pending_layer()->HighResTiling()->AllTilesForTesting().empty()); + EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); int num_inside = 0; int num_outside = 0; - for (PictureLayerTiling::CoverageIterator iter( - active_layer()->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); + for (PictureLayerTiling::CoverageIterator iter(active_layer_->HighResTiling(), + 1.f, gfx::Rect(layer_bounds)); iter; ++iter) { if (!*iter) continue; @@ -1686,24 +1819,24 @@ EXPECT_GT(num_outside, 0); // Activate and draw active layer. - host_impl()->ActivateSyncTree(); - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); - active_layer()->draw_properties().visible_layer_rect = visible_layer_rect; + host_impl_.ActivateSyncTree(); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); + active_layer_->draw_properties().visible_layer_rect = visible_layer_rect; std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); // All tiles in activation rect is ready to draw. EXPECT_EQ(0u, data.num_missing_tiles); EXPECT_EQ(0u, data.num_incomplete_tiles); - EXPECT_FALSE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, HighResTileIsComplete) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -1716,24 +1849,24 @@ // All high res tiles have resources. std::vector<Tile*> tiles = - active_layer()->tilings()->tiling_at(0)->AllTilesForTesting(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); + active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); // All high res tiles drew, nothing was incomplete. EXPECT_EQ(9u, render_pass->quad_list.size()); EXPECT_EQ(0u, data.num_missing_tiles); EXPECT_EQ(0u, data.num_incomplete_tiles); - EXPECT_FALSE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -1745,18 +1878,18 @@ std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); EXPECT_EQ(1u, render_pass->quad_list.size()); EXPECT_EQ(1u, data.num_missing_tiles); EXPECT_EQ(0u, data.num_incomplete_tiles); - EXPECT_TRUE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -1767,24 +1900,23 @@ ActivateTree(); std::vector<Tile*> low_tiles = - active_layer()->tilings()->tiling_at(1)->AllTilesForTesting(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - low_tiles); + active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); EXPECT_EQ(1u, render_pass->quad_list.size()); EXPECT_EQ(0u, data.num_missing_tiles); EXPECT_EQ(1u, data.num_incomplete_tiles); - EXPECT_TRUE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -1796,76 +1928,73 @@ // All high res tiles have resources except one. std::vector<Tile*> high_tiles = - active_layer()->tilings()->tiling_at(0)->AllTilesForTesting(); + active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); high_tiles.erase(high_tiles.begin()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - high_tiles); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); // All low res tiles have resources. std::vector<Tile*> low_tiles = - active_layer()->tilings()->tiling_at(1)->AllTilesForTesting(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - low_tiles); + active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); // The missing high res tile was replaced by a low res tile. EXPECT_EQ(9u, render_pass->quad_list.size()); EXPECT_EQ(0u, data.num_missing_tiles); EXPECT_EQ(1u, data.num_incomplete_tiles); - EXPECT_FALSE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); gfx::Size viewport_size(400, 400); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetInitialDeviceScaleFactor(2.f); SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); // One ideal tile exists, this will get used when drawing. std::vector<Tile*> ideal_tiles; - EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale()); - ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( + EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); + ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( ideal_tiles); // Due to layer scale throttling, the raster contents scale is changed to 1, // while the ideal is still 2. - SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - SetupDrawPropertiesAndUpdateTiles(active_layer(), 2.f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.f, 1.f, 1.f, 1.f, 0.f, false); - EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale()); - EXPECT_EQ(1.f, active_layer()->raster_contents_scale()); - EXPECT_EQ(2.f, active_layer()->ideal_contents_scale()); + EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); + EXPECT_EQ(1.f, active_layer_->raster_contents_scale()); + EXPECT_EQ(2.f, active_layer_->ideal_contents_scale()); // Both tilings still exist. - EXPECT_EQ(2.f, active_layer()->tilings()->tiling_at(0)->contents_scale()); - EXPECT_EQ(1.f, active_layer()->tilings()->tiling_at(1)->contents_scale()); + EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); // All high res tiles have resources. std::vector<Tile*> high_tiles = - active_layer()->HighResTiling()->AllTilesForTesting(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - high_tiles); + active_layer_->HighResTiling()->AllTilesForTesting(); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); // All high res tiles drew, and the one ideal res tile drew. ASSERT_GT(render_pass->quad_list.size(), 9u); @@ -1879,11 +2008,11 @@ // Neither the high res nor the ideal tiles were considered as incomplete. EXPECT_EQ(0u, data.num_missing_tiles); EXPECT_EQ(0u, data.num_incomplete_tiles); - EXPECT_FALSE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, AppendQuadsDataForCheckerboard) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -1896,9 +2025,9 @@ std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); EXPECT_EQ(1u, render_pass->quad_list.size()); EXPECT_EQ(1u, data.num_missing_tiles); @@ -1906,7 +2035,7 @@ EXPECT_EQ(40000, data.checkerboarded_visible_content_area); EXPECT_EQ(17500, data.checkerboarded_no_recording_content_area); EXPECT_EQ(22500, data.checkerboarded_needs_raster_content_area); - EXPECT_TRUE(active_layer()->only_used_low_res_last_append_quads()); + EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); } TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveAllReady) { @@ -1916,14 +2045,14 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, gfx::Rect(layer_bounds)); - active_layer()->SetAllTilesReady(); + active_layer_->SetAllTilesReady(); // All active tiles ready, so pending can only activate with all high res // tiles. - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - EXPECT_FALSE(pending_layer()->LowResTiling()); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + EXPECT_FALSE(pending_layer_->LowResTiling()); - AssertAllTilesRequired(pending_layer()->HighResTiling()); + AssertAllTilesRequired(pending_layer_->HighResTiling()); } TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { @@ -1935,21 +2064,21 @@ // Verify active tree not ready. Tile* some_active_tile = - active_layer()->HighResTiling()->AllTilesForTesting()[0]; + active_layer_->HighResTiling()->AllTilesForTesting()[0]; EXPECT_FALSE(some_active_tile->draw_info().IsReadyToDraw()); // When high res are required, all tiles in active high res tiling should be // required for activation. - host_impl()->SetRequiresHighResToDraw(); + host_impl_.SetRequiresHighResToDraw(); - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - EXPECT_FALSE(pending_layer()->LowResTiling()); - active_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - active_layer()->LowResTiling()->UpdateAllRequiredStateForTesting(); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + EXPECT_FALSE(pending_layer_->LowResTiling()); + active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); - EXPECT_TRUE(pending_layer()->HighResTiling()->AllTilesForTesting().empty()); - AssertAllTilesRequired(active_layer()->HighResTiling()); - AssertNoTilesRequired(active_layer()->LowResTiling()); + EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); + AssertAllTilesRequired(active_layer_->HighResTiling()); + AssertNoTilesRequired(active_layer_->LowResTiling()); } TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { @@ -1959,18 +2088,18 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); Tile* some_active_tile = - active_layer()->HighResTiling()->AllTilesForTesting()[0]; + active_layer_->HighResTiling()->AllTilesForTesting()[0]; EXPECT_FALSE(some_active_tile->draw_info().IsReadyToDraw()); // Since there are no invalidations, pending tree should have no tiles. - EXPECT_TRUE(pending_layer()->HighResTiling()->AllTilesForTesting().empty()); - EXPECT_FALSE(pending_layer()->LowResTiling()); + EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); + EXPECT_FALSE(pending_layer_->LowResTiling()); - active_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - active_layer()->LowResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); - AssertAllTilesRequired(active_layer()->HighResTiling()); - AssertNoTilesRequired(active_layer()->LowResTiling()); + AssertAllTilesRequired(active_layer_->HighResTiling()); + AssertNoTilesRequired(active_layer_->LowResTiling()); } TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { @@ -1980,21 +2109,21 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); Tile* some_active_tile = - active_layer()->HighResTiling()->AllTilesForTesting()[0]; + active_layer_->HighResTiling()->AllTilesForTesting()[0]; EXPECT_FALSE(some_active_tile->draw_info().IsReadyToDraw()); - EXPECT_TRUE(pending_layer()->HighResTiling()->AllTilesForTesting().empty()); - EXPECT_FALSE(pending_layer()->LowResTiling()); - active_layer()->HighResTiling()->set_can_require_tiles_for_activation(false); - active_layer()->LowResTiling()->set_can_require_tiles_for_activation(false); - pending_layer()->HighResTiling()->set_can_require_tiles_for_activation(false); + EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); + EXPECT_FALSE(pending_layer_->LowResTiling()); + active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); + active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); + pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); // If we disallow required for activation, no tiles can be required. - active_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - active_layer()->LowResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); - AssertNoTilesRequired(active_layer()->HighResTiling()); - AssertNoTilesRequired(active_layer()->LowResTiling()); + AssertNoTilesRequired(active_layer_->HighResTiling()); + AssertNoTilesRequired(active_layer_->LowResTiling()); } TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { @@ -2014,16 +2143,16 @@ tile_size, Region()); // Active layer has tilings, but no tiles due to missing recordings. - EXPECT_TRUE(active_layer()->CanHaveTilings()); - EXPECT_EQ(active_layer()->tilings()->num_tilings(), 2u); - EXPECT_EQ(active_layer()->HighResTiling()->AllTilesForTesting().size(), 0u); + EXPECT_TRUE(active_layer_->CanHaveTilings()); + EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); + EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); // Since the active layer has no tiles at all, the pending layer doesn't // need content in order to activate. - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - EXPECT_FALSE(pending_layer()->LowResTiling()); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + EXPECT_FALSE(pending_layer_->LowResTiling()); - AssertNoTilesRequired(pending_layer()->HighResTiling()); + AssertNoTilesRequired(pending_layer_->HighResTiling()); } TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { @@ -2038,16 +2167,16 @@ tile_size, Region()); // Active layer can't have tiles. - EXPECT_FALSE(active_layer()->CanHaveTilings()); + EXPECT_FALSE(active_layer_->CanHaveTilings()); // All high res tiles required. This should be considered identical // to the case where there is no active layer, to avoid flashing content. // This can happen if a layer exists for a while and switches from // not being able to have content to having content. - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - EXPECT_FALSE(pending_layer()->LowResTiling()); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + EXPECT_FALSE(pending_layer_->LowResTiling()); - AssertAllTilesRequired(pending_layer()->HighResTiling()); + AssertAllTilesRequired(pending_layer_->HighResTiling()); } TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { @@ -2065,14 +2194,14 @@ // Since the active layer has different bounds, the pending layer needs all // high res tiles in order to activate. - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - EXPECT_FALSE(pending_layer()->LowResTiling()); - active_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - active_layer()->LowResTiling()->UpdateAllRequiredStateForTesting(); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + EXPECT_FALSE(pending_layer_->LowResTiling()); + active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); - AssertAllTilesRequired(pending_layer()->HighResTiling()); - AssertAllTilesRequired(active_layer()->HighResTiling()); - AssertNoTilesRequired(active_layer()->LowResTiling()); + AssertAllTilesRequired(pending_layer_->HighResTiling()); + AssertAllTilesRequired(active_layer_->HighResTiling()); + AssertNoTilesRequired(active_layer_->LowResTiling()); } TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { @@ -2080,32 +2209,32 @@ scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); - host_impl()->CreatePendingTree(); - LayerTreeImpl* pending_tree = host_impl()->pending_tree(); + host_impl_.CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl_.pending_tree(); std::unique_ptr<FakePictureLayerImpl> pending_layer = - FakePictureLayerImpl::CreateWithRasterSource(pending_tree, layer_id(), + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pending_raster_source); pending_layer->SetDrawsContent(true); pending_tree->SetRootLayer(std::move(pending_layer)); - FakePictureLayerImpl* raw_pending_layer = static_cast<FakePictureLayerImpl*>( - host_impl()->pending_tree()->LayerById(layer_id())); + pending_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.pending_tree()->LayerById(id_)); // Set some state on the pending layer, make sure it is not clobbered // by a sync from the active layer. This could happen because if the // pending layer has not been post-commit initialized it will attempt // to sync from the active layer. - float raster_page_scale = 10.f * raw_pending_layer->raster_page_scale(); - raw_pending_layer->set_raster_page_scale(raster_page_scale); + float raster_page_scale = 10.f * pending_layer_->raster_page_scale(); + pending_layer_->set_raster_page_scale(raster_page_scale); - host_impl()->ActivateSyncTree(); + host_impl_.ActivateSyncTree(); - FakePictureLayerImpl* raw_active_layer = static_cast<FakePictureLayerImpl*>( - host_impl()->active_tree()->LayerById(layer_id())); + active_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.active_tree()->LayerById(id_)); - EXPECT_EQ(0u, raw_active_layer->num_tilings()); - EXPECT_EQ(raster_page_scale, raw_active_layer->raster_page_scale()); + EXPECT_EQ(0u, active_layer_->num_tilings()); + EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); } TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) { @@ -2116,7 +2245,7 @@ SetupPendingTree(pending_raster_source); - PictureLayerTiling* tiling = pending_layer()->HighResTiling(); + PictureLayerTiling* tiling = pending_layer_->HighResTiling(); gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0); first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), tiling->TilingDataForTesting().border_texels()); @@ -2134,8 +2263,8 @@ SetupPendingTreeWithInvalidation(pending_raster_source, second_invalidate); - PictureLayerTiling* pending_tiling = pending_layer()->tilings()->tiling_at(0); - PictureLayerTiling* active_tiling = active_layer()->tilings()->tiling_at(0); + PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); + PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); // Tile 0,0 not exist on pending, but tile 1,1 should. EXPECT_TRUE(active_tiling->TileAt(0, 0)); @@ -2149,8 +2278,8 @@ EXPECT_TRUE(pending_tiling->TileAt(1, 1)); // Drop the tiles on the active tree and recreate them. - active_layer()->tilings()->UpdateTilePriorities(gfx::Rect(), 1.f, 1.0, - Occlusion(), true); + active_layer_->tilings()->UpdateTilePriorities(gfx::Rect(), 1.f, 1.0, + Occlusion(), true); EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); active_tiling->CreateAllTilesForTesting(); @@ -2169,12 +2298,12 @@ TEST_F(PictureLayerImplTest, PendingHasNoTilesWithNoInvalidation) { SetupDefaultTrees(gfx::Size(1500, 1500)); - EXPECT_GE(active_layer()->num_tilings(), 1u); - EXPECT_GE(pending_layer()->num_tilings(), 1u); + EXPECT_GE(active_layer_->num_tilings(), 1u); + EXPECT_GE(pending_layer_->num_tilings(), 1u); // No invalidation. - PictureLayerTiling* active_tiling = active_layer()->tilings()->tiling_at(0); - PictureLayerTiling* pending_tiling = pending_layer()->tilings()->tiling_at(0); + PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); + PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); ASSERT_TRUE(active_tiling); ASSERT_TRUE(pending_tiling); @@ -2205,12 +2334,12 @@ FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(pending_raster_source2); - EXPECT_GE(active_layer()->num_tilings(), 1u); - EXPECT_GE(pending_layer()->num_tilings(), 1u); + EXPECT_GE(active_layer_->num_tilings(), 1u); + EXPECT_GE(pending_layer_->num_tilings(), 1u); // The active tree invalidation was handled by the active tiles. - PictureLayerTiling* active_tiling = active_layer()->tilings()->tiling_at(0); - PictureLayerTiling* pending_tiling = pending_layer()->tilings()->tiling_at(0); + PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); + PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); ASSERT_TRUE(active_tiling); ASSERT_TRUE(pending_tiling); @@ -2230,12 +2359,12 @@ // that touch this. SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); - EXPECT_GE(active_layer()->num_tilings(), 1u); - EXPECT_GE(pending_layer()->num_tilings(), 1u); + EXPECT_GE(active_layer_->num_tilings(), 1u); + EXPECT_GE(pending_layer_->num_tilings(), 1u); // The pending tree invalidation creates tiles on the pending tree. - PictureLayerTiling* active_tiling = active_layer()->tilings()->tiling_at(0); - PictureLayerTiling* pending_tiling = pending_layer()->tilings()->tiling_at(0); + PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); + PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); ASSERT_TRUE(active_tiling); ASSERT_TRUE(pending_tiling); @@ -2253,7 +2382,7 @@ } TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(10, 10); @@ -2264,44 +2393,44 @@ SetupTrees(pending_raster_source, active_raster_source); - EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); - EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScale(1.f)); + EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); + EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); // Gpu rasterization is disabled by default. - EXPECT_FALSE(host_impl()->use_gpu_rasterization()); + EXPECT_FALSE(host_impl_.use_gpu_rasterization()); // Toggling the gpu rasterization clears all tilings on both trees. - host_impl()->SetHasGpuRasterizationTrigger(true); - host_impl()->SetContentIsSuitableForGpuRasterization(true); - host_impl()->UpdateTreeResourcesForGpuRasterizationIfNeeded(); - EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + host_impl_.SetHasGpuRasterizationTrigger(true); + host_impl_.SetContentIsSuitableForGpuRasterization(true); + host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded(); + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); // Make sure that we can still add tiling to the pending layer, // that gets synced to the active layer. - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); - EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); + EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); ActivateTree(); - EXPECT_TRUE(active_layer()->tilings()->FindTilingWithScale(1.f)); + EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); SetupPendingTree(pending_raster_source); - EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(1.f)); + EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); // Toggling the gpu rasterization clears all tilings on both trees. - EXPECT_TRUE(host_impl()->use_gpu_rasterization()); - host_impl()->SetHasGpuRasterizationTrigger(false); - host_impl()->UpdateTreeResourcesForGpuRasterizationIfNeeded(); + EXPECT_TRUE(host_impl_.use_gpu_rasterization()); + host_impl_.SetHasGpuRasterizationTrigger(false); + host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded(); EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, - host_impl()->gpu_rasterization_status()); - EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + host_impl_.gpu_rasterization_status()); + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); - host_impl()->SetHasGpuRasterizationTrigger(true); - host_impl()->SetContentIsSuitableForGpuRasterization(false); + host_impl_.SetHasGpuRasterizationTrigger(true); + host_impl_.SetContentIsSuitableForGpuRasterization(false); EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, - host_impl()->gpu_rasterization_status()); + host_impl_.gpu_rasterization_status()); } TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { @@ -2313,8 +2442,8 @@ SetupPendingTree(pending_raster_source); // Sanity checks. - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); - EXPECT_TRUE(pending_layer()->tilings()->FindTilingWithScale(0.5f)); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); + EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(0.5f)); ActivateTree(); @@ -2323,123 +2452,123 @@ SetupPendingTree(pending_raster_source); // Another sanity check. - EXPECT_EQ(1.f, pending_layer()->MinimumContentsScale()); + EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale()); // Since the MinContentsScale is 1, the 0.5 tiling should have been replaced // by a 1.0 tiling during the UDP in SetupPendingTree. - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); PictureLayerTiling* tiling = - pending_layer()->tilings()->FindTilingWithScale(1.0f); + pending_layer_->tilings()->FindTilingWithScale(1.0f); ASSERT_TRUE(tiling); EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); } TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) { - gfx::Size default_tile_size(host_impl()->settings().default_tile_size); + gfx::Size default_tile_size(host_impl_.settings().default_tile_size); gfx::Size layer_bounds(default_tile_size.width() * 4, default_tile_size.height() * 4); - host_impl()->SetHasGpuRasterizationTrigger(false); + host_impl_.SetHasGpuRasterizationTrigger(false); SetupDefaultTrees(layer_bounds); - EXPECT_FALSE(host_impl()->use_gpu_rasterization()); + EXPECT_FALSE(host_impl_.use_gpu_rasterization()); // Should have only a high-res tiling. - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); ActivateTree(); // Should add a high and a low res for active tree. - EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { - gfx::Size default_tile_size(host_impl()->settings().default_tile_size); + gfx::Size default_tile_size(host_impl_.settings().default_tile_size); gfx::Size layer_bounds(default_tile_size.width() * 4, default_tile_size.height() * 4); - host_impl()->SetHasGpuRasterizationTrigger(true); - host_impl()->SetContentIsSuitableForGpuRasterization(true); + host_impl_.SetHasGpuRasterizationTrigger(true); + host_impl_.SetContentIsSuitableForGpuRasterization(true); SetupDefaultTrees(layer_bounds); - EXPECT_TRUE(host_impl()->use_gpu_rasterization()); + EXPECT_TRUE(host_impl_.use_gpu_rasterization()); // Should only have the high-res tiling. - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); ActivateTree(); // Should only have the high-res tiling. - EXPECT_EQ(1u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, RequiredTilesWithGpuRasterization) { - host_impl()->SetHasGpuRasterizationTrigger(true); - host_impl()->SetContentIsSuitableForGpuRasterization(true); + host_impl_.SetHasGpuRasterizationTrigger(true); + host_impl_.SetContentIsSuitableForGpuRasterization(true); gfx::Size viewport_size(1000, 1000); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); gfx::Size layer_bounds(4000, 4000); SetupDefaultTrees(layer_bounds); - EXPECT_TRUE(host_impl()->use_gpu_rasterization()); + EXPECT_TRUE(host_impl_.use_gpu_rasterization()); // Should only have the high-res tiling. - EXPECT_EQ(1u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); - active_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); // High res tiling should have 64 tiles (4x16 tile grid). - EXPECT_EQ(64u, active_layer()->HighResTiling()->AllTilesForTesting().size()); + EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size()); // Visible viewport should be covered by 4 tiles. No other // tiles should be required for activation. - EXPECT_EQ(4u, NumberOfTilesRequired(active_layer()->HighResTiling())); + EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling())); } TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { // Set up layers with tilings. SetupDefaultTrees(gfx::Size(10, 10)); SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, 0.f, false); - pending_layer()->PushPropertiesTo(active_layer()); - EXPECT_TRUE(pending_layer()->DrawsContent()); - EXPECT_TRUE(pending_layer()->CanHaveTilings()); - EXPECT_GE(pending_layer()->num_tilings(), 0u); - EXPECT_GE(active_layer()->num_tilings(), 0u); + pending_layer_->PushPropertiesTo(active_layer_); + EXPECT_TRUE(pending_layer_->DrawsContent()); + EXPECT_TRUE(pending_layer_->CanHaveTilings()); + EXPECT_GE(pending_layer_->num_tilings(), 0u); + EXPECT_GE(active_layer_->num_tilings(), 0u); // Set content to false, which should make CanHaveTilings return false. - pending_layer()->SetDrawsContent(false); - EXPECT_FALSE(pending_layer()->DrawsContent()); - EXPECT_FALSE(pending_layer()->CanHaveTilings()); + pending_layer_->SetDrawsContent(false); + EXPECT_FALSE(pending_layer_->DrawsContent()); + EXPECT_FALSE(pending_layer_->CanHaveTilings()); // No tilings should be pushed to active layer. - pending_layer()->PushPropertiesTo(active_layer()); - EXPECT_EQ(0u, active_layer()->num_tilings()); + pending_layer_->PushPropertiesTo(active_layer_); + EXPECT_EQ(0u, active_layer_->num_tilings()); } TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { SetupDefaultTrees(gfx::Size(10, 10)); // We start with a tiling at scale 1. - EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); + EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); // When we page scale up by 2.3, we get a new tiling that is a power of 2, in // this case 4. - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); float high_res_scale = 2.3f; SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, false); - EXPECT_EQ(4.f, pending_layer()->HighResTiling()->contents_scale()); + EXPECT_EQ(4.f, pending_layer_->HighResTiling()->contents_scale()); } TEST_F(PictureLayerImplTest, PinchingTooSmall) { SetupDefaultTrees(gfx::Size(10, 10)); // We start with a tiling at scale 1. - EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); + EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); float high_res_scale = 0.0001f; - EXPECT_LT(high_res_scale, pending_layer()->MinimumContentsScale()); + EXPECT_LT(high_res_scale, pending_layer_->MinimumContentsScale()); SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, false); - EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), - pending_layer()->HighResTiling()->contents_scale()); + EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), + pending_layer_->HighResTiling()->contents_scale()); } TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { @@ -2450,26 +2579,26 @@ float contents_scale = 0.15f; SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, 0.f, false); - ASSERT_GE(pending_layer()->num_tilings(), 0u); + ASSERT_GE(pending_layer_->num_tilings(), 0u); EXPECT_FLOAT_EQ(contents_scale, - pending_layer()->HighResTiling()->contents_scale()); + pending_layer_->HighResTiling()->contents_scale()); - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); float page_scale = 0.0001f; EXPECT_LT(page_scale * contents_scale, - pending_layer()->MinimumContentsScale()); + pending_layer_->MinimumContentsScale()); SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, 1.f, 0.f, false); - ASSERT_GE(pending_layer()->num_tilings(), 0u); - EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), - pending_layer()->HighResTiling()->contents_scale()); + ASSERT_GE(pending_layer_->num_tilings(), 0u); + EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), + pending_layer_->HighResTiling()->contents_scale()); } TEST_F(PictureLayerImplTest, ConsiderAnimationStartScaleForRasterScale) { gfx::Size viewport_size(1000, 1000); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); gfx::Size layer_bounds(100, 100); SetupDefaultTrees(layer_bounds); @@ -2527,7 +2656,7 @@ TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { gfx::Size viewport_size(1000, 1000); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); gfx::Size layer_bounds(100, 100); SetupDefaultTrees(layer_bounds); @@ -2670,10 +2799,10 @@ gfx::Size layer_bounds(100, 100); gfx::Size viewport_size(1000, 1000); SetupDefaultTrees(layer_bounds); - host_impl()->SetViewportSize(viewport_size); - host_impl()->SetHasGpuRasterizationTrigger(true); - host_impl()->SetContentIsSuitableForGpuRasterization(true); - host_impl()->UpdateTreeResourcesForGpuRasterizationIfNeeded(); + host_impl_.SetViewportSize(viewport_size); + host_impl_.SetHasGpuRasterizationTrigger(true); + host_impl_.SetContentIsSuitableForGpuRasterization(true); + host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded(); float contents_scale = 1.f; float device_scale = 1.3f; @@ -2729,9 +2858,9 @@ } TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); - host_impl()->SetViewportSize(gfx::Size(500, 500)); + host_impl_.SetViewportSize(gfx::Size(500, 500)); gfx::Size layer_bounds(1000, 1000); @@ -2739,7 +2868,7 @@ FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(pending_raster_source); - EXPECT_EQ(1u, pending_layer()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); std::set<Tile*> unique_tiles; bool reached_prepaint = false; @@ -2748,7 +2877,7 @@ int high_res_tile_count = 0u; int high_res_now_tiles = 0u; std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), false)); + pending_layer_->picture_layer_tiling_set(), false)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); TilePriority priority = prioritized_tile.priority(); @@ -2788,12 +2917,12 @@ std::unique_ptr<TilingSetRasterQueueRequired> required_queue( new TilingSetRasterQueueRequired( - pending_layer()->picture_layer_tiling_set(), + pending_layer_->picture_layer_tiling_set(), RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); EXPECT_TRUE(required_queue->IsEmpty()); required_queue.reset(new TilingSetRasterQueueRequired( - pending_layer()->picture_layer_tiling_set(), + pending_layer_->picture_layer_tiling_set(), RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); EXPECT_FALSE(required_queue->IsEmpty()); int required_for_activation_count = 0; @@ -2810,16 +2939,16 @@ EXPECT_EQ(high_res_now_tiles, required_for_activation_count); // No NOW tiles. - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); - pending_layer()->draw_properties().visible_layer_rect = + pending_layer_->draw_properties().visible_layer_rect = gfx::Rect(1100, 1100, 500, 500); - pending_layer()->UpdateTiles(); + pending_layer_->UpdateTiles(); unique_tiles.clear(); high_res_tile_count = 0u; queue.reset(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), false)); + pending_layer_->picture_layer_tiling_set(), false)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); TilePriority priority = prioritized_tile.priority(); @@ -2839,14 +2968,14 @@ EXPECT_EQ(16, high_res_tile_count); EXPECT_EQ(high_res_tile_count, static_cast<int>(unique_tiles.size())); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); - pending_layer()->draw_properties().visible_layer_rect = + pending_layer_->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 500, 500); - pending_layer()->UpdateTiles(); + pending_layer_->UpdateTiles(); std::vector<Tile*> high_res_tiles = - pending_layer()->HighResTiling()->AllTilesForTesting(); + pending_layer_->HighResTiling()->AllTilesForTesting(); for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); tile_it != high_res_tiles.end(); ++tile_it) { @@ -2856,14 +2985,14 @@ } queue.reset(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), true)); + pending_layer_->picture_layer_tiling_set(), true)); EXPECT_TRUE(queue->IsEmpty()); } TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); - host_impl()->SetViewportSize(gfx::Size(500, 500)); + host_impl_.SetViewportSize(gfx::Size(500, 500)); gfx::Size layer_bounds(1000, 1000); @@ -2872,11 +3001,11 @@ SetupPendingTree(pending_raster_source); ActivateTree(); - EXPECT_EQ(2u, active_layer()->num_tilings()); + EXPECT_EQ(2u, active_layer_->num_tilings()); std::unique_ptr<TilingSetRasterQueueRequired> queue( new TilingSetRasterQueueRequired( - active_layer()->picture_layer_tiling_set(), + active_layer_->picture_layer_tiling_set(), RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); EXPECT_FALSE(queue->IsEmpty()); while (!queue->IsEmpty()) { @@ -2887,7 +3016,7 @@ } queue.reset(new TilingSetRasterQueueRequired( - active_layer()->picture_layer_tiling_set(), + active_layer_->picture_layer_tiling_set(), RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); EXPECT_TRUE(queue->IsEmpty()); } @@ -2898,21 +3027,21 @@ SetupPendingTree(pending_raster_source); EXPECT_FALSE( - pending_layer()->picture_layer_tiling_set()->FindTilingWithResolution( + pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( HIGH_RESOLUTION)); std::unique_ptr<TilingSetRasterQueueRequired> queue( new TilingSetRasterQueueRequired( - pending_layer()->picture_layer_tiling_set(), + pending_layer_->picture_layer_tiling_set(), RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); EXPECT_TRUE(queue->IsEmpty()); } TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { gfx::Size layer_bounds(1000, 1000); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; - host_impl()->SetViewportSize(gfx::Size(500, 500)); + host_impl_.SetViewportSize(gfx::Size(500, 500)); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); @@ -2920,11 +3049,11 @@ // TODO(vmpstr): Add a test with tilings other than high res on the active // tree (crbug.com/519607). SetupPendingTree(pending_raster_source); - EXPECT_EQ(1u, pending_layer()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); std::vector<Tile*> all_tiles; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); std::vector<Tile*> tiles = tiling->AllTilesForTesting(); all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); } @@ -2934,10 +3063,10 @@ bool mark_required = false; size_t number_of_marked_tiles = 0u; size_t number_of_unmarked_tiles = 0u; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); for (PictureLayerTiling::CoverageIterator iter( - tiling, 1.f, pending_layer()->visible_layer_rect()); + tiling, 1.f, pending_layer_->visible_layer_rect()); iter; ++iter) { if (mark_required) { number_of_marked_tiles++; @@ -2957,11 +3086,10 @@ // Tiles don't have resources yet. std::unique_ptr<TilingSetEvictionQueue> queue( - new TilingSetEvictionQueue(pending_layer()->picture_layer_tiling_set())); + new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); EXPECT_TRUE(queue->IsEmpty()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - all_tiles); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); std::set<Tile*> unique_tiles; float expected_scales[] = {low_res_factor, 1.f}; @@ -2971,7 +3099,7 @@ size_t distance_decreasing = 0; size_t distance_increasing = 0; queue.reset( - new TilingSetEvictionQueue(pending_layer()->picture_layer_tiling_set())); + new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); Tile* tile = prioritized_tile.tile(); @@ -3058,7 +3186,7 @@ gfx::Size viewport_size(1000, 1000); LayerTestCommon::LayerImplTest impl; - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); @@ -3066,13 +3194,13 @@ ActivateTree(); std::vector<Tile*> tiles = - active_layer()->HighResTiling()->AllTilesForTesting(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); + active_layer_->HighResTiling()->AllTilesForTesting(); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); { SCOPED_TRACE("No occlusion"); gfx::Rect occluded; - impl.AppendQuadsWithOcclusion(active_layer(), occluded); + impl.AppendQuadsWithOcclusion(active_layer_, occluded); LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect(layer_bounds)); @@ -3081,8 +3209,8 @@ { SCOPED_TRACE("Full occlusion"); - gfx::Rect occluded(active_layer()->visible_layer_rect()); - impl.AppendQuadsWithOcclusion(active_layer(), occluded); + gfx::Rect occluded(active_layer_->visible_layer_rect()); + impl.AppendQuadsWithOcclusion(active_layer_, occluded); LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); EXPECT_EQ(impl.quad_list().size(), 0u); @@ -3091,7 +3219,7 @@ { SCOPED_TRACE("Partial occlusion"); gfx::Rect occluded(150, 0, 200, 1000); - impl.AppendQuadsWithOcclusion(active_layer(), occluded); + impl.AppendQuadsWithOcclusion(active_layer_, occluded); size_t partially_occluded_count = 0; LayerTestCommon::VerifyQuadsAreOccluded( @@ -3103,7 +3231,7 @@ } TEST_F(PictureLayerImplTest, RasterScaleChangeWithoutAnimation) { - gfx::Size tile_size(host_impl()->settings().default_tile_size); + gfx::Size tile_size(host_impl_.settings().default_tile_size); SetupDefaultTrees(tile_size); ResetTilingsAndRasterScales(); @@ -3148,20 +3276,20 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); // All pending layer tiles required are not ready. - EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); // Initialize all low-res tiles. - EXPECT_FALSE(pending_layer()->LowResTiling()); - pending_layer()->SetAllTilesReadyInTiling(active_layer()->LowResTiling()); + EXPECT_FALSE(pending_layer_->LowResTiling()); + pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling()); // Low-res tiles should not be enough. - EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); // Initialize remaining tiles. - pending_layer()->SetAllTilesReady(); - active_layer()->SetAllTilesReady(); + pending_layer_->SetAllTilesReady(); + active_layer_->SetAllTilesReady(); - EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); } TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { @@ -3173,14 +3301,14 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); // All pending layer tiles required are not ready. - EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); // Initialize all high-res tiles. - pending_layer()->SetAllTilesReadyInTiling(pending_layer()->HighResTiling()); - active_layer()->SetAllTilesReadyInTiling(active_layer()->HighResTiling()); + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); + active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); // High-res tiles should be enough, since they cover everything visible. - EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); } TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) { @@ -3192,130 +3320,130 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); // Initialize all high-res tiles in the active layer. - active_layer()->SetAllTilesReadyInTiling(active_layer()->HighResTiling()); + active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); // The pending high-res tiles are not ready, so we cannot activate. - EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); // When the pending high-res tiles are ready, we can activate. - pending_layer()->SetAllTilesReadyInTiling(pending_layer()->HighResTiling()); - EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); + EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); } TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { gfx::Size layer_bounds(1300, 1900); SetupDefaultTrees(layer_bounds); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); ResetTilingsAndRasterScales(); - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 6.f, // ideal contents scale 3.f, // device scale 2.f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the page scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 6.6f, // ideal contents scale 3.f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.6f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 7.26f, // ideal contents scale 3.3f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, but end up at the same total scale // factor somehow, then we don't get new tilings. - SetupDrawPropertiesAndUpdateTiles(active_layer(), + SetupDrawPropertiesAndUpdateTiles(active_layer_, 7.26f, // ideal contents scale 2.2f, // device scale 3.3f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - active_layer()->tilings()->tiling_at(0)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); } TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { gfx::Size layer_bounds(1300, 1900); SetupDefaultTrees(layer_bounds); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); ResetTilingsAndRasterScales(); - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 6.f, // ideal contents scale 3.f, // device scale 2.f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the page scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 6.6f, // ideal contents scale 3.f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(6.6f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, then we should get new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 7.26f, // ideal contents scale 3.3f, // device scale 2.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); // If we change the device scale factor, but end up at the same total scale // factor somehow, then we don't get new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 7.26f, // ideal contents scale 2.2f, // device scale 3.3f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(7.26f, - pending_layer()->tilings()->tiling_at(0)->contents_scale()); + pending_layer_->tilings()->tiling_at(0)->contents_scale()); } TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { @@ -3325,21 +3453,21 @@ SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); Tile* some_active_tile = - active_layer()->HighResTiling()->AllTilesForTesting()[0]; + active_layer_->HighResTiling()->AllTilesForTesting()[0]; EXPECT_FALSE(some_active_tile->draw_info().IsReadyToDraw()); // Since there is no invalidation, pending tree should have no tiles. - EXPECT_TRUE(pending_layer()->HighResTiling()->AllTilesForTesting().empty()); - if (host_impl()->settings().create_low_res_tiling) - EXPECT_TRUE(pending_layer()->LowResTiling()->AllTilesForTesting().empty()); + EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); + if (host_impl_.settings().create_low_res_tiling) + EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); - active_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - if (host_impl()->settings().create_low_res_tiling) - active_layer()->LowResTiling()->UpdateAllRequiredStateForTesting(); + active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + if (host_impl_.settings().create_low_res_tiling) + active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); - AssertAllTilesRequired(active_layer()->HighResTiling()); - if (host_impl()->settings().create_low_res_tiling) - AssertNoTilesRequired(active_layer()->LowResTiling()); + AssertAllTilesRequired(active_layer_->HighResTiling()); + if (host_impl_.settings().create_low_res_tiling) + AssertNoTilesRequired(active_layer_->LowResTiling()); } TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { @@ -3359,20 +3487,20 @@ tile_size, Region()); // Active layer has tilings, but no tiles due to missing recordings. - EXPECT_TRUE(active_layer()->CanHaveTilings()); - EXPECT_EQ(active_layer()->tilings()->num_tilings(), - host_impl()->settings().create_low_res_tiling ? 2u : 1u); - EXPECT_EQ(active_layer()->HighResTiling()->AllTilesForTesting().size(), 0u); + EXPECT_TRUE(active_layer_->CanHaveTilings()); + EXPECT_EQ(active_layer_->tilings()->num_tilings(), + host_impl_.settings().create_low_res_tiling ? 2u : 1u); + EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); // Since the active layer has no tiles at all, the pending layer doesn't // need content in order to activate. - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); - if (host_impl()->settings().create_low_res_tiling) - pending_layer()->LowResTiling()->UpdateAllRequiredStateForTesting(); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); + if (host_impl_.settings().create_low_res_tiling) + pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); - AssertNoTilesRequired(pending_layer()->HighResTiling()); - if (host_impl()->settings().create_low_res_tiling) - AssertNoTilesRequired(pending_layer()->LowResTiling()); + AssertNoTilesRequired(pending_layer_->HighResTiling()); + if (host_impl_.settings().create_low_res_tiling) + AssertNoTilesRequired(pending_layer_->LowResTiling()); } TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { @@ -3380,7 +3508,7 @@ std::vector<PictureLayerTiling*> used_tilings; SetupDefaultTrees(layer_bounds); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; EXPECT_LT(low_res_factor, 1.f); float device_scale = 1.7f; @@ -3391,50 +3519,50 @@ SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, 0.f, false); - ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to - // |used_tilings| variable, and it's here only to ensure that active_layer() + // |used_tilings| variable, and it's here only to ensure that active_layer_ // won't remove tilings before the test has a chance to verify behavior. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // We only have ideal tilings, so they aren't removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); // Changing the ideal but not creating new tilings. scale *= 1.5f; page_scale *= 1.5f; SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, 0.f, false); - ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); // The tilings are still our target scale, so they aren't removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); - host_impl()->PinchGestureEnd(); + host_impl_.PinchGestureEnd(); // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. scale /= 4.f; page_scale /= 4.f; SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, 0.f, false); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(1.f, - active_layer()->tilings()->tiling_at(1)->contents_scale()); + active_layer_->tilings()->tiling_at(1)->contents_scale()); // Ensure UpdateTiles won't remove any tilings. - active_layer()->MarkAllTilingsUsed(); + active_layer_->MarkAllTilingsUsed(); // Mark the non-ideal tilings as used. They won't be removed. used_tilings.clear(); - used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 0.5. Our target stays 1.2. SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, 0.f, false); @@ -3442,8 +3570,8 @@ // The high resolution tiling is between target and ideal, so is not // removed. The low res tiling for the old ideal=1.0 scale is removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 1.0. Our target stays 1.2. SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, 0.f, false); @@ -3451,86 +3579,86 @@ // All the tilings are between are target and the ideal, so they are not // removed. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. - SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.1f, device_scale, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, device_scale, page_scale, 1.f, 0.f, false); // Because the pending layer's ideal scale is still 1.0, our tilings fall // in the range [1.0,1.2] and are kept. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); // Move the ideal scale on the pending layer to 1.1 as well. Our target stays // 1.2 still. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.1f, device_scale, + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, device_scale, page_scale, 1.f, 0.f, false); // Our 1.0 tiling now falls outside the range between our ideal scale and our // target raster scale. But it is in our used tilings set, so nothing is // deleted. used_tilings.clear(); - used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); + used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); // If we remove it from our used tilings set, it is outside the range to keep // so it is deleted. used_tilings.clear(); - active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); - ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); + active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); + ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); } TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { gfx::Size layer_bounds(1300, 1900); SetupDefaultTrees(layer_bounds); - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); - EXPECT_EQ(1u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); + EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); // All tilings should be removed when losing output surface. - active_layer()->ReleaseResources(); - EXPECT_FALSE(active_layer()->tilings()); - active_layer()->RecreateResources(); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); - pending_layer()->ReleaseResources(); - EXPECT_FALSE(pending_layer()->tilings()); - pending_layer()->RecreateResources(); - EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); + active_layer_->ReleaseResources(); + EXPECT_FALSE(active_layer_->tilings()); + active_layer_->RecreateResources(); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); + pending_layer_->ReleaseResources(); + EXPECT_FALSE(pending_layer_->tilings()); + pending_layer_->RecreateResources(); + EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); // This should create new tilings. - SetupDrawPropertiesAndUpdateTiles(pending_layer(), + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.3f, // ideal contents scale 2.7f, // device scale 3.2f, // page scale 1.f, // maximum animation scale 0.f, // starting animation scale false); - EXPECT_EQ(1u, pending_layer()->tilings()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); gfx::Size layer_bounds(1000, 2000); - host_impl()->SetViewportSize(gfx::Size(10000, 20000)); + host_impl_.SetViewportSize(gfx::Size(10000, 20000)); SetupDefaultTrees(layer_bounds); ResetTilingsAndRasterScales(); - SetupDrawPropertiesAndUpdateTiles(active_layer(), 2.5f, 1.f, 1.f, 1.f, 0.f, + SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, false); - float max_contents_scale = active_layer()->MaximumTilingContentsScale(); + float max_contents_scale = active_layer_->MaximumTilingContentsScale(); EXPECT_EQ(2.5f, max_contents_scale); - gfx::Transform scaled_draw_transform = active_layer()->DrawTransform(); + gfx::Transform scaled_draw_transform = active_layer_->DrawTransform(); scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, SK_MScalar1 / max_contents_scale); AppendQuadsData data; - active_layer()->AppendQuads(render_pass.get(), &data); + active_layer_->AppendQuads(render_pass.get(), &data); // SharedQuadState should have be of size 1, as we are doing AppenQuad once. EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); @@ -3553,8 +3681,13 @@ class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { public: - std::unique_ptr<OutputSurface> CreateOutputSurface() override { - return FakeOutputSurface::CreateDelegating3d(); + PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() { + output_surface_ = FakeOutputSurface::CreateDelegating3d(); + } + + void InitializeRenderer() override { + host_impl_.SetVisible(true); + host_impl_.InitializeRenderer(output_surface_.get()); } }; @@ -3568,13 +3701,13 @@ scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(pending_raster_source); - pending_layer()->SetBounds(layer_bounds); + pending_layer_->SetBounds(layer_bounds); ActivateTree(); bool update_lcd_text = false; - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); std::vector<Tile*> tiles = - active_layer()->HighResTiling()->AllTilesForTesting(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); + active_layer_->HighResTiling()->AllTilesForTesting(); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); // Force tiles after max_tiles to be OOM. TileManager uses // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot @@ -3582,21 +3715,21 @@ // state. We also need to update tree priority separately. GlobalStateThatImpactsTilePriority state; size_t max_tiles = 1; - gfx::Size tile_size(host_impl()->settings().default_tile_size); + gfx::Size tile_size(host_impl_.settings().default_tile_size); size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height(); size_t resource_limit = max_tiles; ManagedMemoryPolicy policy(memory_limit, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, resource_limit); - host_impl()->SetMemoryPolicy(policy); - host_impl()->SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); - host_impl()->PrepareTiles(); + host_impl_.SetMemoryPolicy(policy); + host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); + host_impl_.PrepareTiles(); std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_HARDWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); // Even when OOM, quads should be produced, and should be different material // from quads with resource. @@ -3607,13 +3740,15 @@ render_pass->quad_list.back()->material); } +class OcclusionTrackingSettings : public LowResTilingsSettings { + public: + OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } +}; + class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { public: - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings = PictureLayerImplTest::CreateSettings(); - settings.use_occlusion_for_tile_prioritization = true; - return settings; - } + OcclusionTrackingPictureLayerImplTest() + : PictureLayerImplTest(OcclusionTrackingSettings()) {} void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, WhichTree tree, @@ -3661,14 +3796,14 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, OccludedTilesSkippedDuringRasterization) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(102, 102); gfx::Size layer_bounds(1000, 1000); gfx::Size viewport_size(500, 500); gfx::PointF occluding_layer_position(310.f, 0.f); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); @@ -3677,7 +3812,7 @@ // No occlusion. int unoccluded_tile_count = 0; std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), false)); + pending_layer_->picture_layer_tiling_set(), false)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); Tile* tile = prioritized_tile.tile(); @@ -3688,7 +3823,7 @@ // Some tiles may not be visible (i.e. outside the viewport). The rest are // visible and at least partially unoccluded, verified by the above expect. bool tile_is_visible = - tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); + tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); if (tile_is_visible) unoccluded_tile_count++; queue->Pop(); @@ -3696,21 +3831,21 @@ EXPECT_EQ(unoccluded_tile_count, 25); // Partial occlusion. - pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 1)); - LayerImpl* layer1 = pending_layer()->children()[0]; + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); + LayerImpl* layer1 = pending_layer_->children()[0]; layer1->SetBounds(layer_bounds); layer1->SetDrawsContent(true); layer1->SetContentsOpaque(true); layer1->SetPosition(occluding_layer_position); RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); unoccluded_tile_count = 0; queue.reset(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), false)); + pending_layer_->picture_layer_tiling_set(), false)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); Tile* tile = prioritized_tile.tile(); @@ -3718,7 +3853,7 @@ EXPECT_FALSE(prioritized_tile.is_occluded()); bool tile_is_visible = - tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); + tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); if (tile_is_visible) unoccluded_tile_count++; queue->Pop(); @@ -3730,12 +3865,12 @@ layer1->NoteLayerPropertyChanged(); RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); unoccluded_tile_count = 0; queue.reset(new TilingSetRasterQueueAll( - pending_layer()->picture_layer_tiling_set(), false)); + pending_layer_->picture_layer_tiling_set(), false)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); Tile* tile = prioritized_tile.tile(); @@ -3743,7 +3878,7 @@ EXPECT_FALSE(prioritized_tile.is_occluded()); bool tile_is_visible = - tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); + tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); if (tile_is_visible) unoccluded_tile_count++; queue->Pop(); @@ -3753,14 +3888,14 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, OccludedTilesNotMarkedAsRequired) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(102, 102); gfx::Size layer_bounds(1000, 1000); gfx::Size viewport_size(500, 500); gfx::PointF occluding_layer_position(310.f, 0.f); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); @@ -3768,8 +3903,8 @@ // No occlusion. int occluded_tile_count = 0; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -3791,20 +3926,20 @@ } // Partial occlusion. - pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 1)); - LayerImpl* layer1 = pending_layer()->children()[0]; + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); + LayerImpl* layer1 = pending_layer_->children()[0]; layer1->SetBounds(layer_bounds); layer1->SetDrawsContent(true); layer1->SetContentsOpaque(true); layer1->SetPosition(occluding_layer_position); RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -3838,11 +3973,11 @@ layer1->NoteLayerPropertyChanged(); RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -3873,7 +4008,7 @@ } TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(102, 102); gfx::Size layer_bounds(1000, 1000); @@ -3883,37 +4018,37 @@ scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); - ASSERT_TRUE(pending_layer()->CanHaveTilings()); + ASSERT_TRUE(pending_layer_->CanHaveTilings()); - pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 1)); - LayerImpl* layer1 = pending_layer()->children()[0]; + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); + LayerImpl* layer1 = pending_layer_->children()[0]; layer1->SetBounds(layer_bounds); layer1->SetDrawsContent(true); layer1->SetContentsOpaque(true); layer1->SetPosition(occluding_layer_position); - pending_layer()->tilings()->RemoveAllTilings(); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; - pending_layer()->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); - pending_layer()->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); - pending_layer()->AddTiling(0.7f)->set_resolution(HIGH_RESOLUTION); - pending_layer()->AddTiling(1.0f)->set_resolution(HIGH_RESOLUTION); - pending_layer()->AddTiling(2.0f)->set_resolution(HIGH_RESOLUTION); + pending_layer_->tilings()->RemoveAllTilings(); + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; + pending_layer_->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); + pending_layer_->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); + pending_layer_->AddTiling(0.7f)->set_resolution(HIGH_RESOLUTION); + pending_layer_->AddTiling(1.0f)->set_resolution(HIGH_RESOLUTION); + pending_layer_->AddTiling(2.0f)->set_resolution(HIGH_RESOLUTION); RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); // UpdateDrawProperties with the occluding layer. bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); - EXPECT_EQ(5u, pending_layer()->num_tilings()); + EXPECT_EQ(5u, pending_layer_->num_tilings()); int occluded_tile_count = 0; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); std::vector<Tile*> tiles = tiling->AllTilesForTesting(); @@ -3959,12 +4094,12 @@ scoped_refptr<FakeRasterSource> active_raster_source = FakeRasterSource::CreateFilled(layer_bounds); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetupPendingTree(active_raster_source); // Partially occlude the active layer. - pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 2)); - LayerImpl* layer1 = pending_layer()->children()[0]; + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); + LayerImpl* layer1 = pending_layer_->children()[0]; layer1->SetBounds(layer_bounds); layer1->SetDrawsContent(true); layer1->SetContentsOpaque(true); @@ -3972,8 +4107,8 @@ ActivateTree(); - for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -3996,8 +4131,8 @@ // Partially invalidate the pending layer. SetupPendingTreeWithInvalidation(pending_raster_source, invalidation_rect); - for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -4013,13 +4148,12 @@ EXPECT_FALSE(prioritized_tiles[tile].is_occluded()); if (tiling->resolution() == LOW_RESOLUTION) { - EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinTiling(tiling)); + EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinTiling(tiling)); continue; } - Tile* twin_tile = - active_layer()->GetPendingOrActiveTwinTiling(tiling)->TileAt( - iter.i(), iter.j()); + Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) + ->TileAt(iter.i(), iter.j()); gfx::Rect scaled_content_rect = ScaleToEnclosingRect( tile->content_rect(), 1.0f / tile->contents_scale()); @@ -4037,7 +4171,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, OccludedTilesConsideredDuringEviction) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(102, 102); gfx::Size layer_bounds(1000, 1000); @@ -4046,7 +4180,7 @@ gfx::PointF active_occluding_layer_position(0.f, 310.f); gfx::Rect invalidation_rect(230, 230, 152, 152); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetInitialDeviceScaleFactor(2.f); scoped_refptr<FakeRasterSource> pending_raster_source = @@ -4057,8 +4191,8 @@ SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); // Partially occlude the active layer. - pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 2)); - LayerImpl* active_occluding_layer = pending_layer()->children()[0]; + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); + LayerImpl* active_occluding_layer = pending_layer_->children()[0]; active_occluding_layer->SetBounds(layer_bounds); active_occluding_layer->SetDrawsContent(true); active_occluding_layer->SetContentsOpaque(true); @@ -4072,21 +4206,21 @@ invalidation_rect); // Partially occlude the pending layer in a different way. - pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 3)); - LayerImpl* pending_occluding_layer = pending_layer()->children()[0]; + pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); + LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; pending_occluding_layer->SetBounds(layer_bounds); pending_occluding_layer->SetDrawsContent(true); pending_occluding_layer->SetContentsOpaque(true); pending_occluding_layer->SetPosition(pending_occluding_layer_position); - EXPECT_EQ(1u, pending_layer()->num_tilings()); - EXPECT_EQ(2u, active_layer()->num_tilings()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); + EXPECT_EQ(2u, active_layer_->num_tilings()); RebuildPropertyTreesOnPendingTree(); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); // UpdateDrawProperties with the occluding layer. bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); // The expected number of occluded tiles on each of the 2 tilings for each of // the 3 tree priorities. @@ -4095,8 +4229,8 @@ size_t total_expected_occluded_tile_count_on_trees[] = {15u, 4u}; // Verify number of occluded tiles on the pending layer for each tiling. - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -4122,8 +4256,8 @@ } // Verify number of occluded tiles on the active layer for each tiling. - for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); @@ -4144,46 +4278,45 @@ } std::vector<Tile*> all_tiles; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); std::vector<Tile*> tiles = tiling->AllTilesForTesting(); all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); } - for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); std::vector<Tile*> tiles = tiling->AllTilesForTesting(); all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); } - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - all_tiles); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); VerifyEvictionConsidersOcclusion( - pending_layer(), PENDING_TREE, + pending_layer_, PENDING_TREE, total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); VerifyEvictionConsidersOcclusion( - active_layer(), ACTIVE_TREE, + active_layer_, ACTIVE_TREE, total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); // Repeat the tests without valid active tree priorities. - active_layer()->set_has_valid_tile_priorities(false); + active_layer_->set_has_valid_tile_priorities(false); VerifyEvictionConsidersOcclusion( - pending_layer(), PENDING_TREE, + pending_layer_, PENDING_TREE, total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); VerifyEvictionConsidersOcclusion( - active_layer(), ACTIVE_TREE, + active_layer_, ACTIVE_TREE, total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); - active_layer()->set_has_valid_tile_priorities(true); + active_layer_->set_has_valid_tile_priorities(true); // Repeat the tests without valid pending tree priorities. - pending_layer()->set_has_valid_tile_priorities(false); + pending_layer_->set_has_valid_tile_priorities(false); VerifyEvictionConsidersOcclusion( - active_layer(), ACTIVE_TREE, + active_layer_, ACTIVE_TREE, total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); VerifyEvictionConsidersOcclusion( - pending_layer(), PENDING_TREE, + pending_layer_, PENDING_TREE, total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); - pending_layer()->set_has_valid_tile_priorities(true); + pending_layer_->set_has_valid_tile_priorities(true); } TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { @@ -4192,28 +4325,28 @@ scoped_refptr<FakeRasterSource> raster_source = FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(raster_source); - EXPECT_FALSE(pending_layer()->GetPendingOrActiveTwinLayer()); + EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer()); ActivateTree(); - EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); + EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer()); SetupPendingTree(raster_source); - EXPECT_TRUE(pending_layer()->GetPendingOrActiveTwinLayer()); - EXPECT_TRUE(active_layer()->GetPendingOrActiveTwinLayer()); - EXPECT_EQ(pending_layer(), active_layer()->GetPendingOrActiveTwinLayer()); - EXPECT_EQ(active_layer(), pending_layer()->GetPendingOrActiveTwinLayer()); + EXPECT_TRUE(pending_layer_->GetPendingOrActiveTwinLayer()); + EXPECT_TRUE(active_layer_->GetPendingOrActiveTwinLayer()); + EXPECT_EQ(pending_layer_, active_layer_->GetPendingOrActiveTwinLayer()); + EXPECT_EQ(active_layer_, pending_layer_->GetPendingOrActiveTwinLayer()); ActivateTree(); - EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); + EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer()); // Make an empty pending tree. - host_impl()->CreatePendingTree(); - host_impl()->pending_tree()->ClearLayers(); - EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinLayer()); + host_impl_.CreatePendingTree(); + host_impl_.pending_tree()->ClearLayers(); + EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer()); } void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -4245,21 +4378,21 @@ ActivateTree(); if (test_for_solid) { - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); } else { - ASSERT_TRUE(active_layer()->tilings()); - ASSERT_GT(active_layer()->tilings()->num_tilings(), 0u); + ASSERT_TRUE(active_layer_->tilings()); + ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); std::vector<Tile*> tiles = - active_layer()->tilings()->tiling_at(0)->AllTilesForTesting(); + active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); EXPECT_FALSE(tiles.empty()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); } std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); AppendQuadsData data; - active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); - active_layer()->AppendQuads(render_pass.get(), &data); - active_layer()->DidDraw(nullptr); + active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + active_layer_->AppendQuads(render_pass.get(), &data); + active_layer_->DidDraw(nullptr); DrawQuad::Material expected = test_for_solid ? DrawQuad::Material::SOLID_COLOR @@ -4276,7 +4409,7 @@ } TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(100, 100); gfx::Size layer_bounds(200, 200); @@ -4308,11 +4441,11 @@ SetupPendingTree(raster_source1); ActivateTree(); bool update_lcd_text = false; - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); // We've started with a solid layer that contains some tilings. - ASSERT_TRUE(active_layer()->tilings()); - EXPECT_NE(0u, active_layer()->tilings()->num_tilings()); + ASSERT_TRUE(active_layer_->tilings()); + EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); client.set_fill_with_nonsolid_color(false); @@ -4329,12 +4462,12 @@ ActivateTree(); // We've switched to a solid color, so we should end up with no tilings. - ASSERT_TRUE(active_layer()->tilings()); - EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); + ASSERT_TRUE(active_layer_->tilings()); + EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); } TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(400, 4000); SetupDefaultTrees(layer_bounds); @@ -4343,50 +4476,52 @@ gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); gfx::Transform transform; - host_impl()->SetRequiresHighResToDraw(); + host_impl_.SetRequiresHighResToDraw(); // Update tiles. - pending_layer()->draw_properties().visible_layer_rect = viewport; - pending_layer()->draw_properties().screen_space_transform = transform; - SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + pending_layer_->draw_properties().visible_layer_rect = viewport; + pending_layer_->draw_properties().screen_space_transform = transform; + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); // Ensure we can't activate. - EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); // Now in the same frame, move the viewport (this can happen during // animation). viewport = gfx::Rect(0, 2000, 100, 100); // Update tiles. - pending_layer()->draw_properties().visible_layer_rect = viewport; - pending_layer()->draw_properties().screen_space_transform = transform; - SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, + pending_layer_->draw_properties().visible_layer_rect = viewport; + pending_layer_->draw_properties().screen_space_transform = transform; + SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, false); - pending_layer()->HighResTiling()->UpdateAllRequiredStateForTesting(); + pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); // Make sure all viewport tiles (viewport from the tiling) are ready to draw. std::vector<Tile*> tiles; for (PictureLayerTiling::CoverageIterator iter( - pending_layer()->HighResTiling(), 1.f, - pending_layer()->HighResTiling()->GetCurrentVisibleRectForTesting()); - iter; ++iter) { + pending_layer_->HighResTiling(), + 1.f, + pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); + iter; + ++iter) { if (*iter) tiles.push_back(*iter); } for (PictureLayerTiling::CoverageIterator iter( - active_layer()->HighResTiling(), 1.f, - active_layer()->HighResTiling()->GetCurrentVisibleRectForTesting()); + active_layer_->HighResTiling(), 1.f, + active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); iter; ++iter) { if (*iter) tiles.push_back(*iter); } - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); // Ensure we can activate. - EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); + EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); } TEST_F(PictureLayerImplTest, CloneMissingRecordings) { @@ -4403,8 +4538,8 @@ SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size, Region()); ActivateTree(); - PictureLayerTiling* pending_tiling = old_pending_layer()->HighResTiling(); - PictureLayerTiling* active_tiling = active_layer()->HighResTiling(); + PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); + PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); // We should have all tiles on active, and none on pending. EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size()); @@ -4451,13 +4586,13 @@ } TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(102, 102); gfx::Size layer_bounds(100, 100); gfx::Size viewport_size(100, 100); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetInitialDeviceScaleFactor(1.f); scoped_refptr<FakeRasterSource> pending_raster_source = @@ -4468,105 +4603,100 @@ SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); ActivateTree(); - EXPECT_TRUE(active_layer()->HighResTiling()->has_tiles()); + EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles()); - host_impl()->SetExternalTilePriorityConstraints(gfx::Rect(0, 5000, 100, 100), - gfx::Transform()); + host_impl_.SetExternalTilePriorityConstraints(gfx::Rect(0, 5000, 100, 100), + gfx::Transform()); SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, gfx::Rect()); - EXPECT_FALSE(pending_layer()->HighResTiling()->has_tiles()); - EXPECT_TRUE(pending_layer()->HighResTiling()->live_tiles_rect().IsEmpty()); + EXPECT_FALSE(pending_layer_->HighResTiling()->has_tiles()); + EXPECT_TRUE(pending_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); ActivateTree(); - EXPECT_FALSE(active_layer()->HighResTiling()->has_tiles()); - EXPECT_TRUE(active_layer()->HighResTiling()->live_tiles_rect().IsEmpty()); + EXPECT_FALSE(active_layer_->HighResTiling()->has_tiles()); + EXPECT_TRUE(active_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); - host_impl()->SetExternalTilePriorityConstraints(gfx::Rect(0, 110, 100, 100), - gfx::Transform()); + host_impl_.SetExternalTilePriorityConstraints(gfx::Rect(0, 110, 100, 100), + gfx::Transform()); SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, gfx::Rect()); - EXPECT_FALSE(pending_layer()->HighResTiling()->has_tiles()); - EXPECT_FALSE(pending_layer()->HighResTiling()->live_tiles_rect().IsEmpty()); + EXPECT_FALSE(pending_layer_->HighResTiling()->has_tiles()); + EXPECT_FALSE(pending_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); ActivateTree(); - EXPECT_TRUE(active_layer()->HighResTiling()->has_tiles()); - EXPECT_FALSE(active_layer()->HighResTiling()->live_tiles_rect().IsEmpty()); + EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles()); + EXPECT_FALSE(active_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); } TEST_F(PictureLayerImplTest, ScrollPropagatesToPending) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(1000, 1000); gfx::Size viewport_size(100, 100); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetInitialDeviceScaleFactor(1.f); SetupDefaultTrees(layer_bounds); - active_layer()->SetCurrentScrollOffset(gfx::ScrollOffset(0.0, 50.0)); - host_impl()->active_tree()->UpdateDrawProperties(false); - EXPECT_EQ("0,50 100x100", active_layer() - ->HighResTiling() + active_layer_->SetCurrentScrollOffset(gfx::ScrollOffset(0.0, 50.0)); + host_impl_.active_tree()->UpdateDrawProperties(false); + EXPECT_EQ("0,50 100x100", active_layer_->HighResTiling() ->GetCurrentVisibleRectForTesting() .ToString()); - EXPECT_EQ("0,0 100x100", pending_layer() - ->HighResTiling() + EXPECT_EQ("0,0 100x100", pending_layer_->HighResTiling() ->GetCurrentVisibleRectForTesting() .ToString()); - host_impl()->pending_tree()->UpdateDrawProperties(false); - EXPECT_EQ("0,50 100x100", pending_layer() - ->HighResTiling() + host_impl_.pending_tree()->UpdateDrawProperties(false); + EXPECT_EQ("0,50 100x100", pending_layer_->HighResTiling() ->GetCurrentVisibleRectForTesting() .ToString()); } TEST_F(PictureLayerImplTest, UpdateLCDInvalidatesPendingTree) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size tile_size(102, 102); gfx::Size layer_bounds(100, 100); gfx::Size viewport_size(100, 100); - host_impl()->SetViewportSize(viewport_size); + host_impl_.SetViewportSize(viewport_size); SetInitialDeviceScaleFactor(1.f); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilledLCD(layer_bounds); SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); - EXPECT_TRUE(pending_layer()->RasterSourceUsesLCDText()); - EXPECT_TRUE(pending_layer()->HighResTiling()->has_tiles()); + EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText()); + EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); std::vector<Tile*> tiles = - pending_layer()->HighResTiling()->AllTilesForTesting(); - auto prioritized_tiles = pending_layer() - ->HighResTiling() + pending_layer_->HighResTiling()->AllTilesForTesting(); + auto prioritized_tiles = pending_layer_->HighResTiling() ->UpdateAndGetAllPrioritizedTilesForTesting(); for (Tile* tile : tiles) - EXPECT_EQ(pending_layer()->raster_source(), + EXPECT_EQ(pending_layer_->raster_source(), prioritized_tiles[tile].raster_source()); - pending_layer()->draw_properties().can_use_lcd_text = false; - pending_layer()->UpdateCanUseLCDTextAfterCommit(); + pending_layer_->draw_properties().can_use_lcd_text = false; + pending_layer_->UpdateCanUseLCDTextAfterCommit(); - EXPECT_FALSE(pending_layer()->RasterSourceUsesLCDText()); - EXPECT_NE(pending_raster_source.get(), pending_layer()->raster_source()); - EXPECT_TRUE(pending_layer()->HighResTiling()->has_tiles()); - tiles = pending_layer()->HighResTiling()->AllTilesForTesting(); - prioritized_tiles = pending_layer() - ->HighResTiling() + EXPECT_FALSE(pending_layer_->RasterSourceUsesLCDText()); + EXPECT_NE(pending_raster_source.get(), pending_layer_->raster_source()); + EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); + tiles = pending_layer_->HighResTiling()->AllTilesForTesting(); + prioritized_tiles = pending_layer_->HighResTiling() ->UpdateAndGetAllPrioritizedTilesForTesting(); for (Tile* tile : tiles) - EXPECT_EQ(pending_layer()->raster_source(), + EXPECT_EQ(pending_layer_->raster_source(), prioritized_tiles[tile].raster_source()); } TEST_F(PictureLayerImplTest, TilingAllTilesDone) { - gfx::Size tile_size = host_impl()->settings().default_tile_size; + gfx::Size tile_size = host_impl_.settings().default_tile_size; size_t tile_mem = 4 * tile_size.width() * tile_size.height(); gfx::Size layer_bounds(1000, 1000); @@ -4574,13 +4704,13 @@ scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(pending_raster_source); - pending_layer()->SetBounds(layer_bounds); + pending_layer_->SetBounds(layer_bounds); ActivateTree(); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( - active_layer()->HighResTiling()->AllTilesForTesting()); - host_impl()->SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( + active_layer_->HighResTiling()->AllTilesForTesting()); + host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); - EXPECT_FALSE(active_layer()->HighResTiling()->all_tiles_done()); + EXPECT_FALSE(active_layer_->HighResTiling()->all_tiles_done()); { // Set a memory policy that will fit all tiles. @@ -4589,10 +4719,10 @@ ManagedMemoryPolicy policy(memory_limit, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, max_tiles); - host_impl()->SetMemoryPolicy(policy); - host_impl()->PrepareTiles(); + host_impl_.SetMemoryPolicy(policy); + host_impl_.PrepareTiles(); - EXPECT_TRUE(active_layer()->HighResTiling()->all_tiles_done()); + EXPECT_TRUE(active_layer_->HighResTiling()->all_tiles_done()); } { @@ -4602,36 +4732,39 @@ ManagedMemoryPolicy policy(memory_limit, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, max_tiles); - host_impl()->SetMemoryPolicy(policy); - host_impl()->PrepareTiles(); + host_impl_.SetMemoryPolicy(policy); + host_impl_.PrepareTiles(); - EXPECT_FALSE(active_layer()->HighResTiling()->all_tiles_done()); + EXPECT_FALSE(active_layer_->HighResTiling()->all_tiles_done()); } } -class TileSizeTest : public PictureLayerImplTest { +class TileSizeSettings : public PictureLayerImplTestSettings { public: - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings = PictureLayerImplTest::CreateSettings(); - settings.default_tile_size = gfx::Size(100, 100); - settings.max_untiled_layer_size = gfx::Size(200, 200); - return settings; + TileSizeSettings() { + default_tile_size = gfx::Size(100, 100); + max_untiled_layer_size = gfx::Size(200, 200); } }; +class TileSizeTest : public PictureLayerImplTest { + public: + TileSizeTest() : PictureLayerImplTest(TileSizeSettings()) {} +}; + TEST_F(TileSizeTest, TileSizes) { - host_impl()->CreatePendingTree(); + host_impl_.CreatePendingTree(); - LayerTreeImpl* pending_tree = host_impl()->pending_tree(); + LayerTreeImpl* pending_tree = host_impl_.pending_tree(); std::unique_ptr<FakePictureLayerImpl> layer = - FakePictureLayerImpl::Create(pending_tree, layer_id()); + FakePictureLayerImpl::Create(pending_tree, id_); - host_impl()->SetViewportSize(gfx::Size(1000, 1000)); + host_impl_.SetViewportSize(gfx::Size(1000, 1000)); gfx::Size result; - host_impl()->SetContentIsSuitableForGpuRasterization(true); - host_impl()->SetHasGpuRasterizationTrigger(false); - EXPECT_EQ(host_impl()->gpu_rasterization_status(), + host_impl_.SetContentIsSuitableForGpuRasterization(true); + host_impl_.SetHasGpuRasterizationTrigger(false); + EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::OFF_VIEWPORT); // Default tile-size for large layers. @@ -4651,12 +4784,11 @@ // Gpu-rasterization uses 25% viewport-height tiles. // The +2's below are for border texels. - host_impl()->SetHasGpuRasterizationTrigger(true); - EXPECT_EQ(host_impl()->gpu_rasterization_status(), - GpuRasterizationStatus::ON); - host_impl()->SetViewportSize(gfx::Size(2000, 2000)); + host_impl_.SetHasGpuRasterizationTrigger(true); + EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON); + host_impl_.SetViewportSize(gfx::Size(2000, 2000)); - layer->set_gpu_raster_max_texture_size(host_impl()->device_viewport_size()); + layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); result = layer->CalculateTileSize(gfx::Size(10000, 10000)); EXPECT_EQ(result.width(), MathUtil::UncheckedRoundUp( @@ -4665,8 +4797,8 @@ // Clamp and round-up, when smaller than viewport. // Tile-height doubles to 50% when width shrinks to <= 50%. - host_impl()->SetViewportSize(gfx::Size(1000, 1000)); - layer->set_gpu_raster_max_texture_size(host_impl()->device_viewport_size()); + host_impl_.SetViewportSize(gfx::Size(1000, 1000)); + layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); result = layer->CalculateTileSize(gfx::Size(447, 10000)); EXPECT_EQ(result.width(), 448); EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aliged. @@ -4684,7 +4816,7 @@ TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { gfx::Size layer_bounds(1300, 1900); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; SetupDefaultTrees(layer_bounds); ResetTilingsAndRasterScales(); @@ -4693,20 +4825,20 @@ EXPECT_BOTH_EQ(num_tilings(), 1u); EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), page_scale); - host_impl()->PinchGestureBegin(); + host_impl_.PinchGestureBegin(); // Zoom out to exactly the low res factor so that the previous high res // would be equal to the current low res (if it were possible to have one). float zoomed = page_scale / low_res_factor; SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false); - EXPECT_EQ(1u, pending_layer()->num_tilings()); - EXPECT_EQ(zoomed, pending_layer()->tilings()->tiling_at(0)->contents_scale()); + EXPECT_EQ(1u, pending_layer_->num_tilings()); + EXPECT_EQ(zoomed, pending_layer_->tilings()->tiling_at(0)->contents_scale()); } TEST_F(PictureLayerImplTest, HighResWasLowResCollision) { gfx::Size layer_bounds(1300, 1900); - float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; + float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; SetupDefaultTrees(layer_bounds); ResetTilingsAndRasterScales(); @@ -4714,36 +4846,34 @@ float page_scale = 4.f; float low_res = page_scale * low_res_factor; float extra_low_res = low_res * low_res_factor; - SetupDrawPropertiesAndUpdateTiles(active_layer(), page_scale, 1.0f, - page_scale, 1.0f, 0.f, false); - EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); + SetupDrawPropertiesAndUpdateTiles(active_layer_, page_scale, 1.0f, page_scale, + 1.0f, 0.f, false); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); EXPECT_EQ(page_scale, - active_layer()->tilings()->tiling_at(0)->contents_scale()); - EXPECT_EQ(low_res, active_layer()->tilings()->tiling_at(1)->contents_scale()); + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_EQ(low_res, active_layer_->tilings()->tiling_at(1)->contents_scale()); // Grab a current low res tile. PictureLayerTiling* old_low_res_tiling = - active_layer()->tilings()->tiling_at(1); - Tile* old_low_res_tile = - active_layer()->tilings()->tiling_at(1)->TileAt(0, 0); + active_layer_->tilings()->tiling_at(1); + Tile* old_low_res_tile = active_layer_->tilings()->tiling_at(1)->TileAt(0, 0); // The tiling knows it has low res content. - EXPECT_TRUE(active_layer() - ->tilings() + EXPECT_TRUE(active_layer_->tilings() ->tiling_at(1) ->may_contain_low_resolution_tiles()); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); // Zoom in to exactly the low res factor so that the previous low res // would be equal to the current high res. - SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res, - 1.0f, 0.f, false); + SetupDrawPropertiesAndUpdateTiles(active_layer_, low_res, 1.0f, low_res, 1.0f, + 0.f, false); // 3 tilings. The old high res, the new high res (old low res) and the new low // res. - EXPECT_EQ(3u, active_layer()->num_tilings()); + EXPECT_EQ(3u, active_layer_->num_tilings()); - PictureLayerTilingSet* tilings = active_layer()->tilings(); + PictureLayerTilingSet* tilings = active_layer_->tilings(); EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale()); EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale()); EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale());
diff --git a/cc/quads/draw_polygon.cc b/cc/quads/draw_polygon.cc index 26b5310..770d241 100644 --- a/cc/quads/draw_polygon.cc +++ b/cc/quads/draw_polygon.cc
@@ -183,32 +183,43 @@ const gfx::Vector3dF& plane_normal, gfx::Point3F* intersection, float distance_threshold) { - gfx::Vector3dF start_to_origin_vector = plane_origin - line_start; - gfx::Vector3dF end_to_origin_vector = plane_origin - line_end; + const gfx::Vector3dF line_start_vec(line_start.x(), line_start.y(), + line_start.z()); + const gfx::Vector3dF line_end_vec(line_end.x(), line_end.y(), line_end.z()); + const gfx::Vector3dF plane_origin_vec(plane_origin.x(), plane_origin.y(), + plane_origin.z()); - double start_distance = gfx::DotProduct(start_to_origin_vector, plane_normal); - double end_distance = gfx::DotProduct(end_to_origin_vector, plane_normal); + double plane_d = -gfx::DotProduct(plane_origin_vec, plane_normal); - // The case where one vertex lies on the thick-plane and the other - // is outside of it. - if (std::abs(start_distance) <= distance_threshold && - std::abs(end_distance) > distance_threshold) { + double end_distance = gfx::DotProduct(line_end_vec, plane_normal) + plane_d; + if (std::abs(end_distance) <= distance_threshold) { + // No intersection if |line_end| is within |distance_threshold| of plane. + return false; + } + + double start_distance = + gfx::DotProduct(line_start_vec, plane_normal) + plane_d; + if (std::abs(start_distance) <= distance_threshold) { + // Intersection at |line_start| if |line_start| is within + // |distance_threshold| of plane. intersection->SetPoint(line_start.x(), line_start.y(), line_start.z()); return true; } - // This is the case where we clearly cross the thick-plane. - if ((start_distance > distance_threshold && - end_distance < -distance_threshold) || - (start_distance < -distance_threshold && - end_distance > distance_threshold)) { - gfx::Vector3dF v = line_end - line_start; - float total_distance = std::abs(start_distance) + std::abs(end_distance); - float lerp_factor = std::abs(start_distance) / total_distance; + // If signs differ, we cross the plane. + if (start_distance * end_distance < 0.0) { + // Plane: P . N + d = 0 [ d = -(plane_normal . plane_origin) ] + // Ray: P = P0 + Pd * t [ P0 = line_start, Pd = line_end - line_start ] + // Substituting: + // (P0 + Pd * t) . N + d = 0 + // P0 . N + t * Pd . N + d = 0 + // t = -(P0 . N + d) / Pd . N - intersection->SetPoint(line_start.x() + (v.x() * lerp_factor), - line_start.y() + (v.y() * lerp_factor), - line_start.z() + (v.z() * lerp_factor)); + gfx::Vector3dF line_delta = line_end - line_start; + double t = -start_distance / gfx::DotProduct(plane_normal, line_delta); + intersection->SetPoint(line_start.x() + line_delta.x() * t, + line_start.y() + line_delta.y() * t, + line_start.z() + line_delta.z() * t); return true; }
diff --git a/cc/test/test_layer_tree_host_base.cc b/cc/test/test_layer_tree_host_base.cc deleted file mode 100644 index b79ad5f..0000000 --- a/cc/test/test_layer_tree_host_base.cc +++ /dev/null
@@ -1,180 +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 "cc/test/test_layer_tree_host_base.h" - -#include "cc/test/fake_output_surface.h" -#include "cc/test/fake_raster_source.h" -#include "cc/trees/layer_tree_impl.h" - -namespace cc { - -TestLayerTreeHostBase::TestLayerTreeHostBase() - : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), - pending_layer_(nullptr), - active_layer_(nullptr), - old_pending_layer_(nullptr), - root_id_(6), - id_(7) {} - -TestLayerTreeHostBase::~TestLayerTreeHostBase() = default; - -void TestLayerTreeHostBase::SetUp() { - output_surface_ = CreateOutputSurface(); - task_graph_runner_ = CreateTaskGraphRunner(); - host_impl_ = CreateHostImpl(CreateSettings(), &task_runner_provider_, - &shared_bitmap_manager_, task_graph_runner_.get(), - &gpu_memory_buffer_manager_); - InitializeRenderer(); - SetInitialTreePriority(); -} - -LayerTreeSettings TestLayerTreeHostBase::CreateSettings() { - return LayerTreeSettings(); -} - -std::unique_ptr<OutputSurface> TestLayerTreeHostBase::CreateOutputSurface() { - return FakeOutputSurface::Create3d(); -} - -std::unique_ptr<FakeLayerTreeHostImpl> TestLayerTreeHostBase::CreateHostImpl( - const LayerTreeSettings& settings, - TaskRunnerProvider* task_runner_provider, - SharedBitmapManager* shared_bitmap_manager, - TaskGraphRunner* task_graph_runner, - gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { - return base::WrapUnique(new FakeLayerTreeHostImpl( - settings, task_runner_provider, shared_bitmap_manager, task_graph_runner, - gpu_memory_buffer_manager)); -} - -std::unique_ptr<TaskGraphRunner> -TestLayerTreeHostBase::CreateTaskGraphRunner() { - return base::WrapUnique(new TestTaskGraphRunner); -} - -void TestLayerTreeHostBase::InitializeRenderer() { - host_impl_->SetVisible(true); - host_impl_->InitializeRenderer(output_surface_.get()); -} - -void TestLayerTreeHostBase::ResetOutputSurface( - std::unique_ptr<OutputSurface> output_surface) { - host_impl()->DidLoseOutputSurface(); - host_impl()->SetVisible(true); - host_impl()->InitializeRenderer(output_surface.get()); - output_surface_ = std::move(output_surface); -} - -std::unique_ptr<FakeLayerTreeHostImpl> TestLayerTreeHostBase::TakeHostImpl() { - return std::move(host_impl_); -} - -void TestLayerTreeHostBase::SetupDefaultTrees(const gfx::Size& layer_bounds) { - scoped_refptr<FakeRasterSource> pending_raster_source = - FakeRasterSource::CreateFilled(layer_bounds); - scoped_refptr<FakeRasterSource> active_raster_source = - FakeRasterSource::CreateFilled(layer_bounds); - - SetupTrees(std::move(pending_raster_source), std::move(active_raster_source)); -} - -void TestLayerTreeHostBase::SetupTrees( - scoped_refptr<RasterSource> pending_raster_source, - scoped_refptr<RasterSource> active_raster_source) { - SetupPendingTree(std::move(active_raster_source)); - ActivateTree(); - SetupPendingTree(std::move(pending_raster_source)); -} - -void TestLayerTreeHostBase::SetupPendingTree( - scoped_refptr<RasterSource> raster_source) { - SetupPendingTree(std::move(raster_source), gfx::Size(), Region()); -} - -void TestLayerTreeHostBase::SetupPendingTree( - scoped_refptr<RasterSource> raster_source, - const gfx::Size& tile_size, - const Region& invalidation) { - host_impl()->CreatePendingTree(); - host_impl()->pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, - 100000.f); - LayerTreeImpl* pending_tree = host_impl()->pending_tree(); - pending_tree->SetDeviceScaleFactor( - host_impl()->active_tree()->device_scale_factor()); - - // Steal from the recycled tree if possible. - LayerImpl* pending_root = pending_tree->root_layer(); - std::unique_ptr<FakePictureLayerImpl> pending_layer; - DCHECK(!pending_root || pending_root->id() == root_id_); - if (!pending_root) { - std::unique_ptr<LayerImpl> new_pending_root = - LayerImpl::Create(pending_tree, root_id_); - pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); - if (!tile_size.IsEmpty()) - pending_layer->set_fixed_tile_size(tile_size); - pending_layer->SetDrawsContent(true); - pending_layer->SetScrollClipLayer(new_pending_root->id()); - pending_root = new_pending_root.get(); - pending_tree->SetRootLayer(std::move(new_pending_root)); - } else { - pending_layer.reset(static_cast<FakePictureLayerImpl*>( - pending_root->RemoveChildForTesting(pending_root->children()[0]) - .release())); - if (!tile_size.IsEmpty()) - pending_layer->set_fixed_tile_size(tile_size); - } - pending_root->test_properties()->force_render_surface = true; - // The bounds() just mirror the raster source size. - pending_layer->SetBounds(raster_source->GetSize()); - pending_layer->SetRasterSourceOnPending(raster_source, invalidation); - - pending_root->AddChild(std::move(pending_layer)); - pending_tree->SetViewportLayersFromIds(Layer::INVALID_ID, - pending_tree->root_layer()->id(), - Layer::INVALID_ID, Layer::INVALID_ID); - - pending_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl()->pending_tree()->LayerById(id_)); - - // Add tilings/tiles for the layer. - bool update_lcd_text = false; - RebuildPropertyTreesOnPendingTree(); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); -} - -void TestLayerTreeHostBase::ActivateTree() { - RebuildPropertyTreesOnPendingTree(); - host_impl()->ActivateSyncTree(); - CHECK(!host_impl()->pending_tree()); - CHECK(host_impl()->recycle_tree()); - old_pending_layer_ = pending_layer_; - pending_layer_ = nullptr; - active_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl()->active_tree()->LayerById(id_)); - - bool update_lcd_text = false; - host_impl()->active_tree()->UpdateDrawProperties(update_lcd_text); -} - -void TestLayerTreeHostBase::RebuildPropertyTreesOnPendingTree() { - host_impl()->pending_tree()->property_trees()->needs_rebuild = true; - host_impl()->pending_tree()->BuildPropertyTreesForTesting(); -} - -void TestLayerTreeHostBase::SetInitialTreePriority() { - GlobalStateThatImpactsTilePriority state; - - state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; - state.num_resources_limit = 10000; - state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; - state.memory_limit_policy = ALLOW_ANYTHING; - state.tree_priority = SAME_PRIORITY_FOR_BOTH_TREES; - - host_impl_->resource_pool()->SetResourceUsageLimits( - state.soft_memory_limit_in_bytes, state.num_resources_limit); - host_impl_->tile_manager()->SetGlobalStateForTesting(state); -} - -} // namespace cc
diff --git a/cc/test/test_layer_tree_host_base.h b/cc/test/test_layer_tree_host_base.h deleted file mode 100644 index 849ed66..0000000 --- a/cc/test/test_layer_tree_host_base.h +++ /dev/null
@@ -1,83 +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 CC_TEST_TEST_LAYER_TREE_HOST_BASE_H_ -#define CC_TEST_TEST_LAYER_TREE_HOST_BASE_H_ - -#include <memory> - -#include "cc/output/output_surface.h" -#include "cc/test/fake_impl_task_runner_provider.h" -#include "cc/test/fake_layer_tree_host_impl.h" -#include "cc/test/fake_picture_layer_impl.h" -#include "cc/test/test_gpu_memory_buffer_manager.h" -#include "cc/test/test_shared_bitmap_manager.h" -#include "cc/test/test_task_graph_runner.h" -#include "cc/tiles/tile_priority.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/size.h" - -namespace cc { - -class TestLayerTreeHostBase : public testing::Test { - protected: - TestLayerTreeHostBase(); - ~TestLayerTreeHostBase() override; - - void SetUp() override; - - virtual LayerTreeSettings CreateSettings(); - virtual std::unique_ptr<OutputSurface> CreateOutputSurface(); - virtual std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( - const LayerTreeSettings& settings, - TaskRunnerProvider* task_runner_provider, - SharedBitmapManager* shared_bitmap_manager, - TaskGraphRunner* task_graph_runner, - gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_); - virtual std::unique_ptr<TaskGraphRunner> CreateTaskGraphRunner(); - virtual void InitializeRenderer(); - - void ResetOutputSurface(std::unique_ptr<OutputSurface> output_surface); - std::unique_ptr<FakeLayerTreeHostImpl> TakeHostImpl(); - - void SetupDefaultTrees(const gfx::Size& layer_bounds); - void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, - scoped_refptr<RasterSource> active_raster_source); - void SetupPendingTree(scoped_refptr<RasterSource> raster_source); - void SetupPendingTree(scoped_refptr<RasterSource> raster_source, - const gfx::Size& tile_size, - const Region& invalidation); - void ActivateTree(); - void RebuildPropertyTreesOnPendingTree(); - - FakeLayerTreeHostImpl* host_impl() const { return host_impl_.get(); } - TaskGraphRunner* task_graph_runner() const { - return task_graph_runner_.get(); - } - OutputSurface* output_surface() const { return output_surface_.get(); } - FakePictureLayerImpl* pending_layer() const { return pending_layer_; } - FakePictureLayerImpl* active_layer() const { return active_layer_; } - FakePictureLayerImpl* old_pending_layer() const { return old_pending_layer_; } - int layer_id() const { return id_; } - - private: - void SetInitialTreePriority(); - - FakeImplTaskRunnerProvider task_runner_provider_; - TestSharedBitmapManager shared_bitmap_manager_; - std::unique_ptr<TaskGraphRunner> task_graph_runner_; - TestGpuMemoryBufferManager gpu_memory_buffer_manager_; - std::unique_ptr<OutputSurface> output_surface_; - std::unique_ptr<FakeLayerTreeHostImpl> host_impl_; - - FakePictureLayerImpl* pending_layer_; - FakePictureLayerImpl* active_layer_; - FakePictureLayerImpl* old_pending_layer_; - const int root_id_; - const int id_; -}; - -} // namespace cc - -#endif // CC_TEST_TEST_LAYER_TREE_HOST_BASE_H_
diff --git a/cc/tiles/tile_manager_perftest.cc b/cc/tiles/tile_manager_perftest.cc index 195d1440f..5d7a03e 100644 --- a/cc/tiles/tile_manager_perftest.cc +++ b/cc/tiles/tile_manager_perftest.cc
@@ -21,7 +21,6 @@ #include "cc/test/fake_tile_manager.h" #include "cc/test/fake_tile_manager_client.h" #include "cc/test/fake_tile_task_manager.h" -#include "cc/test/test_layer_tree_host_base.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/test/test_task_graph_runner.h" #include "cc/test/test_tile_priorities.h" @@ -42,30 +41,97 @@ base::LazyInstance<FakeTileTaskManagerImpl> g_fake_tile_task_manager = LAZY_INSTANCE_INITIALIZER; -class TileManagerPerfTest : public TestLayerTreeHostBase { +class TileManagerPerfTest : public testing::Test { public: TileManagerPerfTest() - : timer_(kWarmupRuns, + : memory_limit_policy_(ALLOW_ANYTHING), + max_tiles_(10000), + id_(7), + task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), + output_surface_(FakeOutputSurface::Create3d()), + host_impl_(LayerTreeSettings(), + &task_runner_provider_, + &shared_bitmap_manager_, + &task_graph_runner_), + timer_(kWarmupRuns, base::TimeDelta::FromMilliseconds(kTimeLimitMillis), kTimeCheckInterval) {} - void InitializeRenderer() override { - host_impl()->SetVisible(true); - host_impl()->InitializeRenderer(output_surface()); + void SetTreePriority(TreePriority tree_priority) { + GlobalStateThatImpactsTilePriority state; + gfx::Size tile_size(256, 256); + + state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; + state.num_resources_limit = max_tiles_; + state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; + state.memory_limit_policy = memory_limit_policy_; + state.tree_priority = tree_priority; + + global_state_ = state; + host_impl_.resource_pool()->SetResourceUsageLimits( + state.soft_memory_limit_in_bytes, state.num_resources_limit); + host_impl_.tile_manager()->SetGlobalStateForTesting(state); + } + + void SetUp() override { + InitializeRenderer(); + SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); + } + + virtual void InitializeRenderer() { + host_impl_.SetVisible(true); + host_impl_.InitializeRenderer(output_surface_.get()); tile_manager()->SetTileTaskManagerForTesting( g_fake_tile_task_manager.Pointer()); } - void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, - const gfx::Size& tile_size) { + void SetupDefaultTrees(const gfx::Size& layer_bounds) { scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); scoped_refptr<FakeRasterSource> active_raster_source = FakeRasterSource::CreateFilled(layer_bounds); - SetupPendingTree(std::move(active_raster_source), tile_size, Region()); + SetupTrees(pending_raster_source, active_raster_source); + } + + void ActivateTree() { + host_impl_.ActivateSyncTree(); + CHECK(!host_impl_.pending_tree()); + pending_root_layer_ = NULL; + active_root_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.active_tree()->LayerById(id_)); + } + + void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, + const gfx::Size& tile_size) { + SetupDefaultTrees(layer_bounds); + pending_root_layer_->set_fixed_tile_size(tile_size); + active_root_layer_->set_fixed_tile_size(tile_size); + } + + void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, + scoped_refptr<RasterSource> active_raster_source) { + SetupPendingTree(active_raster_source); ActivateTree(); - SetupPendingTree(std::move(pending_raster_source), tile_size, Region()); + SetupPendingTree(pending_raster_source); + } + + void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { + host_impl_.CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl_.pending_tree(); + // Clear recycled tree. + pending_tree->ClearLayers(); + + std::unique_ptr<FakePictureLayerImpl> pending_layer = + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, + raster_source); + pending_layer->SetDrawsContent(true); + pending_layer->test_properties()->force_render_surface = true; + pending_tree->SetRootLayer(std::move(pending_layer)); + pending_tree->BuildPropertyTreesForTesting(); + + pending_root_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.pending_tree()->LayerById(id_)); } void RunRasterQueueConstructTest(const std::string& test_name, @@ -82,8 +148,8 @@ timer_.Reset(); do { std::unique_ptr<RasterTilePriorityQueue> queue( - host_impl()->BuildRasterQueue(priorities[priority_count], - RasterTilePriorityQueue::Type::ALL)); + host_impl_.BuildRasterQueue(priorities[priority_count], + RasterTilePriorityQueue::Type::ALL)); priority_count = (priority_count + 1) % arraysize(priorities); timer_.NextLap(); } while (!timer_.HasTimeLimitExpired()); @@ -112,8 +178,8 @@ do { int count = tile_count; std::unique_ptr<RasterTilePriorityQueue> queue( - host_impl()->BuildRasterQueue(priorities[priority_count], - RasterTilePriorityQueue::Type::ALL)); + host_impl_.BuildRasterQueue(priorities[priority_count], + RasterTilePriorityQueue::Type::ALL)); while (count--) { ASSERT_FALSE(queue->IsEmpty()); ASSERT_TRUE(queue->Top().tile()); @@ -151,7 +217,7 @@ timer_.Reset(); do { std::unique_ptr<EvictionTilePriorityQueue> queue( - host_impl()->BuildEvictionQueue(priorities[priority_count])); + host_impl_.BuildEvictionQueue(priorities[priority_count])); priority_count = (priority_count + 1) % arraysize(priorities); timer_.NextLap(); } while (!timer_.HasTimeLimitExpired()); @@ -186,7 +252,7 @@ do { int count = tile_count; std::unique_ptr<EvictionTilePriorityQueue> queue( - host_impl()->BuildEvictionQueue(priorities[priority_count])); + host_impl_.BuildEvictionQueue(priorities[priority_count])); while (count--) { ASSERT_FALSE(queue->IsEmpty()); ASSERT_TRUE(queue->Top().tile()); @@ -217,47 +283,46 @@ // will be creating one high res and one low res tiling. That is, // width and height should be smaller by sqrt(1 + low_res_scale). // This gives us _approximately_ correct counts. - LayerTreeSettings settings; - width *= settings.default_tile_size.width() / - std::sqrt(1 + settings.low_res_contents_scale_factor); - height *= settings.default_tile_size.height() / - std::sqrt(1 + settings.low_res_contents_scale_factor); + width *= settings_.default_tile_size.width() / + std::sqrt(1 + settings_.low_res_contents_scale_factor); + height *= settings_.default_tile_size.height() / + std::sqrt(1 + settings_.low_res_contents_scale_factor); // Ensure that we start with blank trees and no tiles. - host_impl()->ResetTreesForTesting(); + host_impl_.ResetTreesForTesting(); tile_manager()->FreeResourcesAndCleanUpReleasedTilesForTesting(); gfx::Size layer_bounds(width, height); gfx::Size viewport(width / 5, height / 5); - host_impl()->SetViewportSize(viewport); + host_impl_.SetViewportSize(viewport); SetupDefaultTreesWithFixedTileSize(layer_bounds, - settings.default_tile_size); + settings_.default_tile_size); std::vector<FakePictureLayerImpl*> layers; // Pending layer counts as one layer. - layers.push_back(pending_layer()); - int next_id = layer_id() + 1; + layers.push_back(pending_root_layer_); + int next_id = id_ + 1; // Create the rest of the layers as children of the root layer. scoped_refptr<FakeRasterSource> raster_source = FakeRasterSource::CreateFilled(layer_bounds); while (static_cast<int>(layers.size()) < layer_count) { - std::unique_ptr<FakePictureLayerImpl> child_layer = + std::unique_ptr<FakePictureLayerImpl> layer = FakePictureLayerImpl::CreateWithRasterSource( - host_impl()->pending_tree(), next_id, raster_source); - child_layer->SetBounds(layer_bounds); - child_layer->SetDrawsContent(true); - layers.push_back(child_layer.get()); - pending_layer()->AddChild(std::move(child_layer)); + host_impl_.pending_tree(), next_id, raster_source); + layer->SetBounds(layer_bounds); + layer->SetDrawsContent(true); + layers.push_back(layer.get()); + pending_root_layer_->AddChild(std::move(layer)); ++next_id; } // Property trees need to be rebuilt because layers were added above. - host_impl()->pending_tree()->property_trees()->needs_rebuild = true; - host_impl()->pending_tree()->BuildPropertyTreesForTesting(); + host_impl_.pending_tree()->property_trees()->needs_rebuild = true; + host_impl_.pending_tree()->BuildPropertyTreesForTesting(); bool update_lcd_text = false; - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); for (FakePictureLayerImpl* layer : layers) layer->CreateAllTiles(); @@ -266,7 +331,7 @@ GlobalStateThatImpactsTilePriority GlobalStateForTest() { GlobalStateThatImpactsTilePriority state; - gfx::Size tile_size = LayerTreeSettings().default_tile_size; + gfx::Size tile_size = settings_.default_tile_size; state.soft_memory_limit_in_bytes = 10000u * 4u * static_cast<size_t>(tile_size.width() * tile_size.height()); @@ -285,7 +350,7 @@ timer_.Reset(); do { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); for (const auto& layer : layers) layer->UpdateTiles(); @@ -299,10 +364,23 @@ timer_.LapsPerSecond(), "runs/s", true); } - TileManager* tile_manager() { return host_impl()->tile_manager(); } + TileManager* tile_manager() { return host_impl_.tile_manager(); } protected: + GlobalStateThatImpactsTilePriority global_state_; + + TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; + TileMemoryLimitPolicy memory_limit_policy_; + int max_tiles_; + int id_; + FakeImplTaskRunnerProvider task_runner_provider_; + std::unique_ptr<OutputSurface> output_surface_; + FakeLayerTreeHostImpl host_impl_; + FakePictureLayerImpl* pending_root_layer_; + FakePictureLayerImpl* active_root_layer_; LapTimer timer_; + LayerTreeSettings settings_; }; TEST_F(TileManagerPerfTest, PrepareTiles) {
diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc index fff4db7e..b40df6bf 100644 --- a/cc/tiles/tile_manager_unittest.cc +++ b/cc/tiles/tile_manager_unittest.cc
@@ -25,7 +25,6 @@ #include "cc/test/fake_tile_manager.h" #include "cc/test/fake_tile_task_manager.h" #include "cc/test/test_gpu_memory_buffer_manager.h" -#include "cc/test/test_layer_tree_host_base.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/test/test_task_graph_runner.h" #include "cc/test/test_tile_priorities.h" @@ -43,24 +42,148 @@ namespace cc { namespace { -class TileManagerTilePriorityQueueTest : public TestLayerTreeHostBase { +class LowResTilingsSettings : public LayerTreeSettings { public: - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings; - settings.create_low_res_tiling = true; - settings.verify_clip_tree_calculations = true; - return settings; + LowResTilingsSettings() { + create_low_res_tiling = true; + verify_clip_tree_calculations = true; + } +}; + +class TileManagerTilePriorityQueueTest : public testing::Test { + public: + TileManagerTilePriorityQueueTest() + : memory_limit_policy_(ALLOW_ANYTHING), + max_tiles_(10000), + ready_to_activate_(false), + id_(7), + task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), + output_surface_(FakeOutputSurface::Create3d()), + host_impl_(LowResTilingsSettings(), + &task_runner_provider_, + &shared_bitmap_manager_, + &task_graph_runner_, + &gpu_memory_buffer_manager_) {} + + void SetTreePriority(TreePriority tree_priority) { + GlobalStateThatImpactsTilePriority state; + gfx::Size tile_size(256, 256); + + state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; + state.num_resources_limit = max_tiles_; + state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; + state.memory_limit_policy = memory_limit_policy_; + state.tree_priority = tree_priority; + + global_state_ = state; + host_impl_.resource_pool()->SetResourceUsageLimits( + state.soft_memory_limit_in_bytes, + state.num_resources_limit); + host_impl_.tile_manager()->SetGlobalStateForTesting(state); } - TileManager* tile_manager() { return host_impl()->tile_manager(); } + void SetUp() override { + InitializeRenderer(); + SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); + } + + virtual void InitializeRenderer() { + host_impl_.SetVisible(true); + host_impl_.InitializeRenderer(output_surface_.get()); + } + + void SetupDefaultTrees(const gfx::Size& layer_bounds) { + scoped_refptr<FakeRasterSource> pending_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + scoped_refptr<FakeRasterSource> active_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + + SetupTrees(pending_raster_source, active_raster_source); + } + + // This matches picture_layer_impl_unittest's ActivateTree. + void ActivateTree() { + host_impl_.ActivateSyncTree(); + CHECK(!host_impl_.pending_tree()); + pending_layer_ = NULL; + active_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.active_tree()->LayerById(id_)); + bool update_lcd_text = false; + host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); + } + + void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, + const gfx::Size& tile_size) { + SetupDefaultTrees(layer_bounds); + pending_layer_->set_fixed_tile_size(tile_size); + active_layer_->set_fixed_tile_size(tile_size); + } + + void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, + scoped_refptr<RasterSource> active_raster_source) { + SetupPendingTree(active_raster_source); + ActivateTree(); + SetupPendingTree(pending_raster_source); + } + + void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { + host_impl_.CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl_.pending_tree(); + + // Steal from the recycled tree. + LayerImpl* old_pending_root = pending_tree->root_layer(); + DCHECK(!old_pending_root || old_pending_root->id() == id_); + + FakePictureLayerImpl* pending_layer = nullptr; + if (old_pending_root) { + pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); + pending_layer->SetRasterSourceOnPending(raster_source, Region()); + } else { + std::unique_ptr<FakePictureLayerImpl> new_root = + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, + raster_source); + pending_layer = new_root.get(); + pending_tree->SetRootLayer(std::move(new_root)); + pending_layer->SetDrawsContent(true); + pending_layer->SetHasRenderSurface(true); + } + // The bounds() just mirror the raster source size. + pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); + + pending_layer_ = static_cast<FakePictureLayerImpl*>( + host_impl_.pending_tree()->LayerById(id_)); + + // Add tilings/tiles for the layer. + bool update_lcd_text = false; + host_impl_.pending_tree()->BuildPropertyTreesForTesting(); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); + } + + TileManager* tile_manager() { return host_impl_.tile_manager(); } + + protected: + GlobalStateThatImpactsTilePriority global_state_; + + TestSharedBitmapManager shared_bitmap_manager_; + TestTaskGraphRunner task_graph_runner_; + TestGpuMemoryBufferManager gpu_memory_buffer_manager_; + TileMemoryLimitPolicy memory_limit_policy_; + int max_tiles_; + bool ready_to_activate_; + int id_; + FakeImplTaskRunnerProvider task_runner_provider_; + std::unique_ptr<OutputSurface> output_surface_; + FakeLayerTreeHostImpl host_impl_; + FakePictureLayerImpl* pending_layer_; + FakePictureLayerImpl* active_layer_; }; TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); @@ -78,8 +201,8 @@ // Sanity check, all tiles should be visible. std::set<Tile*> smoothness_tiles; - queue = host_impl()->BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, - RasterTilePriorityQueue::Type::ALL); + queue = host_impl_.BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, + RasterTilePriorityQueue::Type::ALL); bool had_low_res = false; while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); @@ -95,7 +218,7 @@ EXPECT_TRUE(had_low_res); // Check that everything is required for activation. - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); std::set<Tile*> required_for_activation_tiles; @@ -108,7 +231,7 @@ EXPECT_EQ(all_tiles, required_for_activation_tiles); // Check that everything is required for draw. - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); std::set<Tile*> required_for_draw_tiles; @@ -123,35 +246,35 @@ Region invalidation(gfx::Rect(0, 0, 500, 500)); // Invalidate the pending tree. - pending_layer()->set_invalidation(invalidation); - pending_layer()->HighResTiling()->Invalidate(invalidation); + pending_layer_->set_invalidation(invalidation); + pending_layer_->HighResTiling()->Invalidate(invalidation); // Renew all of the tile priorities. gfx::Rect viewport(50, 50, 100, 100); - pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); - active_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + active_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); // Populate all tiles directly from the tilings. all_tiles.clear(); std::set<Tile*> high_res_tiles; std::vector<Tile*> pending_high_res_tiles = - pending_layer()->HighResTiling()->AllTilesForTesting(); + pending_layer_->HighResTiling()->AllTilesForTesting(); for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) { all_tiles.insert(pending_high_res_tiles[i]); high_res_tiles.insert(pending_high_res_tiles[i]); } std::vector<Tile*> active_high_res_tiles = - active_layer()->HighResTiling()->AllTilesForTesting(); + active_layer_->HighResTiling()->AllTilesForTesting(); for (size_t i = 0; i < active_high_res_tiles.size(); ++i) { all_tiles.insert(active_high_res_tiles[i]); high_res_tiles.insert(active_high_res_tiles[i]); } std::vector<Tile*> active_low_res_tiles = - active_layer()->LowResTiling()->AllTilesForTesting(); + active_layer_->LowResTiling()->AllTilesForTesting(); for (size_t i = 0; i < active_low_res_tiles.size(); ++i) all_tiles.insert(active_low_res_tiles[i]); @@ -160,8 +283,8 @@ tile_count = 0; size_t correct_order_tiles = 0u; // Here we expect to get increasing ACTIVE_TREE priority_bin. - queue = host_impl()->BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, - RasterTilePriorityQueue::Type::ALL); + queue = host_impl_.BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, + RasterTilePriorityQueue::Type::ALL); std::set<Tile*> expected_required_for_draw_tiles; std::set<Tile*> expected_required_for_activation_tiles; while (!queue->IsEmpty()) { @@ -210,7 +333,7 @@ EXPECT_GT(correct_order_tiles, 3 * tile_count / 4); // Check that we have consistent required_for_activation tiles. - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); required_for_activation_tiles.clear(); @@ -225,7 +348,7 @@ EXPECT_NE(all_tiles, required_for_activation_tiles); // Check that we have consistent required_for_draw tiles. - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); required_for_draw_tiles.clear(); @@ -242,8 +365,8 @@ last_tile = PrioritizedTile(); size_t increasing_distance_tiles = 0u; // Here we expect to get increasing PENDING_TREE priority_bin. - queue = host_impl()->BuildRasterQueue(NEW_CONTENT_TAKES_PRIORITY, - RasterTilePriorityQueue::Type::ALL); + queue = host_impl_.BuildRasterQueue(NEW_CONTENT_TAKES_PRIORITY, + RasterTilePriorityQueue::Type::ALL); tile_count = 0; while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); @@ -281,7 +404,7 @@ EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); // Check that we have consistent required_for_activation tiles. - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( NEW_CONTENT_TAKES_PRIORITY, RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); required_for_activation_tiles.clear(); @@ -296,7 +419,7 @@ EXPECT_NE(new_content_tiles, required_for_activation_tiles); // Check that we have consistent required_for_draw tiles. - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( NEW_CONTENT_TAKES_PRIORITY, RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); required_for_draw_tiles.clear(); @@ -314,22 +437,22 @@ RasterTilePriorityQueueHighNonIdealTilings) { const gfx::Size layer_bounds(1000, 1000); const gfx::Size viewport(800, 800); - host_impl()->SetViewportSize(viewport); + host_impl_.SetViewportSize(viewport); SetupDefaultTrees(layer_bounds); - pending_layer()->tilings()->AddTiling(1.5f, pending_layer()->raster_source()); - active_layer()->tilings()->AddTiling(1.5f, active_layer()->raster_source()); - pending_layer()->tilings()->AddTiling(1.7f, pending_layer()->raster_source()); - active_layer()->tilings()->AddTiling(1.7f, active_layer()->raster_source()); + pending_layer_->tilings()->AddTiling(1.5f, pending_layer_->raster_source()); + active_layer_->tilings()->AddTiling(1.5f, active_layer_->raster_source()); + pending_layer_->tilings()->AddTiling(1.7f, pending_layer_->raster_source()); + active_layer_->tilings()->AddTiling(1.7f, active_layer_->raster_source()); - pending_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, - 5.0, Occlusion(), true); - active_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, + pending_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, Occlusion(), true); + active_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, + Occlusion(), true); std::set<Tile*> all_expected_tiles; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); if (tiling->contents_scale() == 1.f) { tiling->set_resolution(HIGH_RESOLUTION); const auto& all_tiles = tiling->AllTilesForTesting(); @@ -339,8 +462,8 @@ } } - for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); if (tiling->contents_scale() == 1.5f) { tiling->set_resolution(HIGH_RESOLUTION); const auto& all_tiles = tiling->AllTilesForTesting(); @@ -359,7 +482,7 @@ } } - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); @@ -381,22 +504,22 @@ RasterTilePriorityQueueHighLowTilings) { const gfx::Size layer_bounds(1000, 1000); const gfx::Size viewport(800, 800); - host_impl()->SetViewportSize(viewport); + host_impl_.SetViewportSize(viewport); SetupDefaultTrees(layer_bounds); - pending_layer()->tilings()->AddTiling(1.5f, pending_layer()->raster_source()); - active_layer()->tilings()->AddTiling(1.5f, active_layer()->raster_source()); - pending_layer()->tilings()->AddTiling(1.7f, pending_layer()->raster_source()); - active_layer()->tilings()->AddTiling(1.7f, active_layer()->raster_source()); + pending_layer_->tilings()->AddTiling(1.5f, pending_layer_->raster_source()); + active_layer_->tilings()->AddTiling(1.5f, active_layer_->raster_source()); + pending_layer_->tilings()->AddTiling(1.7f, pending_layer_->raster_source()); + active_layer_->tilings()->AddTiling(1.7f, active_layer_->raster_source()); - pending_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, - 5.0, Occlusion(), true); - active_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, + pending_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, Occlusion(), true); + active_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, + Occlusion(), true); std::set<Tile*> all_expected_tiles; - for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); if (tiling->contents_scale() == 1.f) { tiling->set_resolution(HIGH_RESOLUTION); const auto& all_tiles = tiling->AllTilesForTesting(); @@ -406,8 +529,8 @@ } } - for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { - PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); + for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { + PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); if (tiling->contents_scale() == 1.5f) { tiling->set_resolution(HIGH_RESOLUTION); const auto& all_tiles = tiling->AllTilesForTesting(); @@ -426,7 +549,7 @@ } } - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); @@ -446,27 +569,27 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(gfx::Size(500, 500)); + host_impl_.SetViewportSize(gfx::Size(500, 500)); SetupDefaultTrees(layer_bounds); // Use a tile's content rect as an invalidation. We should inset it a bit to // ensure that border math doesn't invalidate neighbouring tiles. gfx::Rect invalidation = - active_layer()->HighResTiling()->TileAt(1, 0)->content_rect(); + active_layer_->HighResTiling()->TileAt(1, 0)->content_rect(); invalidation.Inset(2, 2); - pending_layer()->set_invalidation(invalidation); - pending_layer()->HighResTiling()->Invalidate(invalidation); - pending_layer()->HighResTiling()->CreateMissingTilesInLiveTilesRect(); + pending_layer_->set_invalidation(invalidation); + pending_layer_->HighResTiling()->Invalidate(invalidation); + pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect(); // Sanity checks: Tile at 0, 0 not exist on the pending tree (it's not // invalidated). Tile 1, 0 should exist on both. - EXPECT_FALSE(pending_layer()->HighResTiling()->TileAt(0, 0)); - EXPECT_TRUE(active_layer()->HighResTiling()->TileAt(0, 0)); - EXPECT_TRUE(pending_layer()->HighResTiling()->TileAt(1, 0)); - EXPECT_TRUE(active_layer()->HighResTiling()->TileAt(1, 0)); - EXPECT_NE(pending_layer()->HighResTiling()->TileAt(1, 0), - active_layer()->HighResTiling()->TileAt(1, 0)); + EXPECT_FALSE(pending_layer_->HighResTiling()->TileAt(0, 0)); + EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(0, 0)); + EXPECT_TRUE(pending_layer_->HighResTiling()->TileAt(1, 0)); + EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(1, 0)); + EXPECT_NE(pending_layer_->HighResTiling()->TileAt(1, 0), + active_layer_->HighResTiling()->TileAt(1, 0)); std::set<Tile*> expected_now_tiles; std::set<Tile*> expected_required_for_draw_tiles; @@ -474,14 +597,14 @@ for (int i = 0; i <= 1; ++i) { for (int j = 0; j <= 1; ++j) { bool have_pending_tile = false; - if (pending_layer()->HighResTiling()->TileAt(i, j)) { + if (pending_layer_->HighResTiling()->TileAt(i, j)) { expected_now_tiles.insert( - pending_layer()->HighResTiling()->TileAt(i, j)); + pending_layer_->HighResTiling()->TileAt(i, j)); expected_required_for_activation_tiles.insert( - pending_layer()->HighResTiling()->TileAt(i, j)); + pending_layer_->HighResTiling()->TileAt(i, j)); have_pending_tile = true; } - Tile* active_tile = active_layer()->HighResTiling()->TileAt(i, j); + Tile* active_tile = active_layer_->HighResTiling()->TileAt(i, j); EXPECT_TRUE(active_tile); expected_now_tiles.insert(active_tile); expected_required_for_draw_tiles.insert(active_tile); @@ -500,11 +623,11 @@ std::set<Tile*> expected_all_tiles; for (int i = 0; i <= 3; ++i) { for (int j = 0; j <= 3; ++j) { - if (pending_layer()->HighResTiling()->TileAt(i, j)) + if (pending_layer_->HighResTiling()->TileAt(i, j)) expected_all_tiles.insert( - pending_layer()->HighResTiling()->TileAt(i, j)); - EXPECT_TRUE(active_layer()->HighResTiling()->TileAt(i, j)); - expected_all_tiles.insert(active_layer()->HighResTiling()->TileAt(i, j)); + pending_layer_->HighResTiling()->TileAt(i, j)); + EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(i, j)); + expected_all_tiles.insert(active_layer_->HighResTiling()->TileAt(i, j)); } } // Expect 15 shared tiles and 1 unshared tile. @@ -512,7 +635,7 @@ // The actual test will now build different queues and verify that the queues // return the same information as computed manually above. - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); std::set<Tile*> actual_now_tiles; std::set<Tile*> actual_all_tiles; @@ -526,7 +649,7 @@ EXPECT_EQ(expected_now_tiles, actual_now_tiles); EXPECT_EQ(expected_all_tiles, actual_all_tiles); - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); std::set<Tile*> actual_required_for_draw_tiles; @@ -537,7 +660,7 @@ } EXPECT_EQ(expected_required_for_draw_tiles, actual_required_for_draw_tiles); - queue = host_impl()->BuildRasterQueue( + queue = host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); std::set<Tile*> actual_required_for_activation_tiles; @@ -551,7 +674,7 @@ } TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(1000, 1000); SetupDefaultTrees(layer_bounds); @@ -561,21 +684,21 @@ FakeRasterSource::CreateFilled(layer_bounds); std::unique_ptr<FakePictureLayerImpl> pending_child = FakePictureLayerImpl::CreateWithRasterSource( - host_impl()->pending_tree(), layer_id() + 1, pending_raster_source); + host_impl_.pending_tree(), id_ + 1, pending_raster_source); FakePictureLayerImpl* pending_child_raw = pending_child.get(); pending_child_raw->SetDrawsContent(true); - pending_layer()->AddChild(std::move(pending_child)); + pending_layer_->AddChild(std::move(pending_child)); // Set a small viewport, so we have soon and eventually tiles. - host_impl()->SetViewportSize(gfx::Size(200, 200)); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.SetViewportSize(gfx::Size(200, 200)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->property_trees()->needs_rebuild = true; - host_impl()->pending_tree()->BuildPropertyTreesForTesting(); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->property_trees()->needs_rebuild = true; + host_impl_.pending_tree()->BuildPropertyTreesForTesting(); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); - host_impl()->SetRequiresHighResToDraw(); - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + host_impl_.SetRequiresHighResToDraw(); + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); @@ -600,22 +723,22 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); - ASSERT_TRUE(active_layer()->HighResTiling()); - ASSERT_TRUE(active_layer()->LowResTiling()); - ASSERT_TRUE(pending_layer()->HighResTiling()); - EXPECT_FALSE(pending_layer()->LowResTiling()); + ASSERT_TRUE(active_layer_->HighResTiling()); + ASSERT_TRUE(active_layer_->LowResTiling()); + ASSERT_TRUE(pending_layer_->HighResTiling()); + EXPECT_FALSE(pending_layer_->LowResTiling()); std::unique_ptr<EvictionTilePriorityQueue> empty_queue( - host_impl()->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); + host_impl_.BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); EXPECT_TRUE(empty_queue->IsEmpty()); std::set<Tile*> all_tiles; size_t tile_count = 0; std::unique_ptr<RasterTilePriorityQueue> raster_queue( - host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, - RasterTilePriorityQueue::Type::ALL)); + host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, + RasterTilePriorityQueue::Type::ALL)); while (!raster_queue->IsEmpty()) { ++tile_count; EXPECT_TRUE(raster_queue->Top().tile()); @@ -630,7 +753,7 @@ std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); std::unique_ptr<EvictionTilePriorityQueue> queue( - host_impl()->BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY)); + host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY)); EXPECT_FALSE(queue->IsEmpty()); // Sanity check, all tiles should be visible. @@ -651,32 +774,32 @@ Region invalidation(gfx::Rect(0, 0, 500, 500)); // Invalidate the pending tree. - pending_layer()->set_invalidation(invalidation); - pending_layer()->HighResTiling()->Invalidate(invalidation); - pending_layer()->HighResTiling()->CreateMissingTilesInLiveTilesRect(); - EXPECT_FALSE(pending_layer()->LowResTiling()); + pending_layer_->set_invalidation(invalidation); + pending_layer_->HighResTiling()->Invalidate(invalidation); + pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect(); + EXPECT_FALSE(pending_layer_->LowResTiling()); // Renew all of the tile priorities. gfx::Rect viewport(50, 50, 100, 100); - pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); - active_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + active_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); // Populate all tiles directly from the tilings. all_tiles.clear(); std::vector<Tile*> pending_high_res_tiles = - pending_layer()->HighResTiling()->AllTilesForTesting(); + pending_layer_->HighResTiling()->AllTilesForTesting(); for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) all_tiles.insert(pending_high_res_tiles[i]); std::vector<Tile*> active_high_res_tiles = - active_layer()->HighResTiling()->AllTilesForTesting(); + active_layer_->HighResTiling()->AllTilesForTesting(); for (size_t i = 0; i < active_high_res_tiles.size(); ++i) all_tiles.insert(active_high_res_tiles[i]); std::vector<Tile*> active_low_res_tiles = - active_layer()->LowResTiling()->AllTilesForTesting(); + active_layer_->LowResTiling()->AllTilesForTesting(); for (size_t i = 0; i < active_low_res_tiles.size(); ++i) all_tiles.insert(active_low_res_tiles[i]); @@ -687,7 +810,7 @@ smoothness_tiles.clear(); tile_count = 0; // Here we expect to get increasing combined priority_bin. - queue = host_impl()->BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY); + queue = host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY); int distance_increasing = 0; int distance_decreasing = 0; while (!queue->IsEmpty()) { @@ -730,7 +853,7 @@ std::set<Tile*> new_content_tiles; last_tile = PrioritizedTile(); // Again, we expect to get increasing combined priority_bin. - queue = host_impl()->BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); + queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); distance_decreasing = 0; distance_increasing = 0; while (!queue->IsEmpty()) { @@ -771,42 +894,42 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueWithOcclusion) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(layer_bounds); SetupPendingTree(pending_raster_source); std::unique_ptr<FakePictureLayerImpl> pending_child = - FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(), - 2, pending_raster_source); - pending_layer()->AddChild(std::move(pending_child)); + FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, + pending_raster_source); + pending_layer_->AddChild(std::move(pending_child)); FakePictureLayerImpl* pending_child_layer = - static_cast<FakePictureLayerImpl*>(pending_layer()->children()[0]); + static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); pending_child_layer->SetDrawsContent(true); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->property_trees()->needs_rebuild = true; - host_impl()->pending_tree()->BuildPropertyTreesForTesting(); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->property_trees()->needs_rebuild = true; + host_impl_.pending_tree()->BuildPropertyTreesForTesting(); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); ActivateTree(); SetupPendingTree(pending_raster_source); FakePictureLayerImpl* active_child_layer = - static_cast<FakePictureLayerImpl*>(active_layer()->children()[0]); + static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); std::set<Tile*> all_tiles; size_t tile_count = 0; std::unique_ptr<RasterTilePriorityQueue> raster_queue( - host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, - RasterTilePriorityQueue::Type::ALL)); + host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, + RasterTilePriorityQueue::Type::ALL)); while (!raster_queue->IsEmpty()) { ++tile_count; EXPECT_TRUE(raster_queue->Top().tile()); @@ -818,12 +941,12 @@ // Renew all of the tile priorities. gfx::Rect viewport(layer_bounds); - pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); pending_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); - active_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + active_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); active_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); @@ -831,7 +954,7 @@ // Populate all tiles directly from the tilings. all_tiles.clear(); std::vector<Tile*> pending_high_res_tiles = - pending_layer()->HighResTiling()->AllTilesForTesting(); + pending_layer_->HighResTiling()->AllTilesForTesting(); all_tiles.insert(pending_high_res_tiles.begin(), pending_high_res_tiles.end()); @@ -850,7 +973,7 @@ size_t occluded_count = 0u; PrioritizedTile last_tile; std::unique_ptr<EvictionTilePriorityQueue> queue( - host_impl()->BuildEvictionQueue(tree_priority)); + host_impl_.BuildEvictionQueue(tree_priority)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); if (!last_tile.tile()) @@ -886,7 +1009,7 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueWithTransparentLayer) { - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); gfx::Size layer_bounds(1000, 1000); @@ -895,30 +1018,30 @@ SetupPendingTree(pending_raster_source); std::unique_ptr<FakePictureLayerImpl> pending_child = - FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(), - 2, pending_raster_source); + FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, + pending_raster_source); FakePictureLayerImpl* pending_child_layer = pending_child.get(); - pending_layer()->AddChild(std::move(pending_child)); + pending_layer_->AddChild(std::move(pending_child)); // Create a fully transparent child layer so that its tile priorities are not // considered to be valid. pending_child_layer->SetDrawsContent(true); pending_child_layer->test_properties()->force_render_surface = true; - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; - host_impl()->pending_tree()->property_trees()->needs_rebuild = true; - host_impl()->pending_tree()->BuildPropertyTreesForTesting(); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.pending_tree()->property_trees()->needs_rebuild = true; + host_impl_.pending_tree()->BuildPropertyTreesForTesting(); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); pending_child_layer->OnOpacityAnimated(0.0); - host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); - host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); + host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); + host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); // Renew all of the tile priorities. gfx::Rect viewport(layer_bounds); - pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( + pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); pending_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( viewport, 1.0f, 1.0, Occlusion(), true); @@ -926,7 +1049,7 @@ // Populate all tiles directly from the tilings. std::set<Tile*> all_pending_tiles; std::vector<Tile*> pending_high_res_tiles = - pending_layer()->HighResTiling()->AllTilesForTesting(); + pending_layer_->HighResTiling()->AllTilesForTesting(); all_pending_tiles.insert(pending_high_res_tiles.begin(), pending_high_res_tiles.end()); EXPECT_EQ(16u, pending_high_res_tiles.size()); @@ -945,7 +1068,7 @@ tile_manager()->InitializeTilesWithResourcesForTesting( std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); - EXPECT_TRUE(pending_layer()->HasValidTilePriorities()); + EXPECT_TRUE(pending_layer_->HasValidTilePriorities()); EXPECT_FALSE(pending_child_layer->HasValidTilePriorities()); // Verify that eviction queue returns tiles also from layers without valid @@ -955,7 +1078,7 @@ std::set<Tile*> new_content_tiles; size_t tile_count = 0; std::unique_ptr<EvictionTilePriorityQueue> queue( - host_impl()->BuildEvictionQueue(tree_priority)); + host_impl_.BuildEvictionQueue(tree_priority)); while (!queue->IsEmpty()) { PrioritizedTile prioritized_tile = queue->Top(); Tile* tile = prioritized_tile.tile(); @@ -976,10 +1099,10 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); @@ -996,16 +1119,15 @@ EXPECT_EQ(16u, tile_count); for (int i = 1; i < 10; ++i) { - std::unique_ptr<FakePictureLayerImpl> pending_child_layer = - FakePictureLayerImpl::Create(host_impl()->pending_tree(), - layer_id() + i); - pending_child_layer->SetDrawsContent(true); - pending_child_layer->set_has_valid_tile_priorities(true); - pending_layer()->AddChild(std::move(pending_child_layer)); + std::unique_ptr<FakePictureLayerImpl> pending_layer = + FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); + pending_layer->SetDrawsContent(true); + pending_layer->set_has_valid_tile_priorities(true); + pending_layer_->AddChild(std::move(pending_layer)); } - queue = host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, - RasterTilePriorityQueue::Type::ALL); + queue = host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, + RasterTilePriorityQueue::Type::ALL); EXPECT_FALSE(queue->IsEmpty()); tile_count = 0; @@ -1022,12 +1144,12 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); std::unique_ptr<RasterTilePriorityQueue> raster_queue( - host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, - RasterTilePriorityQueue::Type::ALL)); + host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, + RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(raster_queue->IsEmpty()); size_t tile_count = 0; @@ -1042,19 +1164,18 @@ EXPECT_EQ(16u, tile_count); std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); - host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); for (int i = 1; i < 10; ++i) { - std::unique_ptr<FakePictureLayerImpl> pending_child_layer = - FakePictureLayerImpl::Create(host_impl()->pending_tree(), - layer_id() + i); - pending_child_layer->SetDrawsContent(true); - pending_child_layer->set_has_valid_tile_priorities(true); - pending_layer()->AddChild(std::move(pending_child_layer)); + std::unique_ptr<FakePictureLayerImpl> pending_layer = + FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); + pending_layer->SetDrawsContent(true); + pending_layer->set_has_valid_tile_priorities(true); + pending_layer_->AddChild(std::move(pending_layer)); } std::unique_ptr<EvictionTilePriorityQueue> queue( - host_impl()->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); + host_impl_.BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); EXPECT_FALSE(queue->IsEmpty()); tile_count = 0; @@ -1260,87 +1381,87 @@ TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADraw) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); // Verify that the queue has a required for draw tile at Top. - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); EXPECT_TRUE(queue->Top().tile()->required_for_draw()); - EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); - EXPECT_TRUE(host_impl()->is_likely_to_require_a_draw()); + EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); + host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); + EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); } TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADrawOnZeroMemoryBudget) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); // Verify that the queue has a required for draw tile at Top. - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); EXPECT_TRUE(queue->Top().tile()->required_for_draw()); - ManagedMemoryPolicy policy = host_impl()->ActualManagedMemoryPolicy(); + ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); policy.bytes_limit_when_visible = 0; - host_impl()->SetMemoryPolicy(policy); + host_impl_.SetMemoryPolicy(policy); - EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); - EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); + EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); + host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); + EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); } TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); // Verify that the queue has a required for draw tile at Top. - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); EXPECT_TRUE(queue->Top().tile()->required_for_draw()); EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); - EXPECT_EQ(RGBA_8888, host_impl()->resource_provider()->best_texture_format()); + EXPECT_EQ(RGBA_8888, host_impl_.resource_provider()->best_texture_format()); - ManagedMemoryPolicy policy = host_impl()->ActualManagedMemoryPolicy(); + ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); policy.bytes_limit_when_visible = ResourceUtil::UncheckedSizeInBytes<size_t>( gfx::Size(256, 256), RGBA_8888); - host_impl()->SetMemoryPolicy(policy); + host_impl_.SetMemoryPolicy(policy); - EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); - EXPECT_TRUE(host_impl()->is_likely_to_require_a_draw()); + EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); + host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); + EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); - Resource* resource = host_impl()->resource_pool()->AcquireResource( + Resource* resource = host_impl_.resource_pool()->AcquireResource( gfx::Size(256, 256), RGBA_8888); - host_impl()->tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); - EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); + host_impl_.tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); + EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); - host_impl()->resource_pool()->ReleaseResource(resource, 0); + host_impl_.resource_pool()->ReleaseResource(resource, 0); } TEST_F(TileManagerTilePriorityQueueTest, DefaultMemoryPolicy) { const gfx::Size layer_bounds(1000, 1000); - host_impl()->SetViewportSize(layer_bounds); + host_impl_.SetViewportSize(layer_bounds); SetupDefaultTrees(layer_bounds); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); + host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); // 64MB is the default mem limit. EXPECT_EQ(67108864u, - host_impl()->global_tile_state().hard_memory_limit_in_bytes); + host_impl_.global_tile_state().hard_memory_limit_in_bytes); EXPECT_EQ(TileMemoryLimitPolicy::ALLOW_ANYTHING, - host_impl()->global_tile_state().memory_limit_policy); + host_impl_.global_tile_state().memory_limit_policy); EXPECT_EQ(ManagedMemoryPolicy::kDefaultNumResourcesLimit, - host_impl()->global_tile_state().num_resources_limit); + host_impl_.global_tile_state().num_resources_limit); } TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) { @@ -1431,7 +1552,7 @@ tiling_client.SetTileSize(size); std::unique_ptr<PictureLayerImpl> layer_impl = - PictureLayerImpl::Create(host_impl()->active_tree(), 1, false); + PictureLayerImpl::Create(host_impl_.active_tree(), 1, false); layer_impl->set_is_drawn_render_surface_layer_list_member(true); PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set(); @@ -1444,7 +1565,7 @@ gfx::Rect(layer_bounds), // Soon rect. gfx::Rect(layer_bounds)); // Eventually rect. - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); + host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); std::vector<Tile*> tiles = tiling->AllTilesForTesting(); for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { @@ -1461,47 +1582,113 @@ } } -class TileManagerTest : public TestLayerTreeHostBase { +// TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest. +class TileManagerTest : public testing::Test { public: + void SetUp() override { + LayerTreeSettings settings; + settings.verify_clip_tree_calculations = true; + + CustomizeSettings(&settings); + output_surface_ = GetOutputSurface(); + task_graph_runner_ = GetTaskGraphRunner(); + host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_, + &shared_bitmap_manager_, + task_graph_runner_.get())); + host_impl_->SetVisible(true); + host_impl_->InitializeRenderer(output_surface_.get()); + } + + void SetupDefaultTrees(const gfx::Size& layer_bounds) { + scoped_refptr<FakeRasterSource> pending_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + scoped_refptr<FakeRasterSource> active_raster_source = + FakeRasterSource::CreateFilled(layer_bounds); + + SetupTrees(pending_raster_source, active_raster_source); + } + + // This matches picture_layer_impl_unittest's ActivateTree. + void ActivateTree() { + host_impl_->ActivateSyncTree(); + CHECK(!host_impl_->pending_tree()); + bool update_lcd_text = false; + host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); + } + + void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, + scoped_refptr<RasterSource> active_raster_source) { + SetupPendingTree(active_raster_source); + ActivateTree(); + SetupPendingTree(pending_raster_source); + } + + void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { + host_impl_->CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl_->pending_tree(); + + // Steal from the recycled tree. + LayerImpl* old_pending_root = pending_tree->root_layer(); + FakePictureLayerImpl* pending_layer = nullptr; + if (old_pending_root) { + pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); + pending_layer->SetRasterSourceOnPending(raster_source, Region()); + } else { + int id = 7; + std::unique_ptr<FakePictureLayerImpl> new_root = + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id, + raster_source); + pending_layer = new_root.get(); + pending_layer->SetDrawsContent(true); + pending_layer->SetHasRenderSurface(true); + pending_tree->SetRootLayer(std::move(new_root)); + } + + // The bounds() just mirror the raster source size. + pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); + + // Add tilings/tiles for the layer. + bool update_lcd_text = false; + host_impl_->pending_tree()->BuildPropertyTreesForTesting(); + host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); + } + + protected: // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { public: - MockLayerTreeHostImpl( - const LayerTreeSettings& settings, - TaskRunnerProvider* task_runner_provider, - SharedBitmapManager* manager, - TaskGraphRunner* task_graph_runner, - gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) + MockLayerTreeHostImpl(const LayerTreeSettings& settings, + TaskRunnerProvider* task_runner_provider, + SharedBitmapManager* manager, + TaskGraphRunner* task_graph_runner) : FakeLayerTreeHostImpl(settings, task_runner_provider, manager, - task_graph_runner, - gpu_memory_buffer_manager) {} + task_graph_runner) {} MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); MOCK_METHOD0(NotifyReadyToDraw, void()); }; - std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( - const LayerTreeSettings& settings, - TaskRunnerProvider* task_runner_provider, - SharedBitmapManager* shared_bitmap_manager, - TaskGraphRunner* task_graph_runner, - gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) override { - return base::WrapUnique(new MockLayerTreeHostImpl( - settings, task_runner_provider, shared_bitmap_manager, - task_graph_runner, gpu_memory_buffer_manager)); + // By default do no customization. + virtual void CustomizeSettings(LayerTreeSettings* settings) {} + + // By default use TestTaskGraphRunner. + virtual std::unique_ptr<TaskGraphRunner> GetTaskGraphRunner() const { + return base::WrapUnique(new TestTaskGraphRunner()); } // By default use SoftwareOutputSurface. - std::unique_ptr<OutputSurface> CreateOutputSurface() override { + virtual std::unique_ptr<OutputSurface> GetOutputSurface() const { return FakeOutputSurface::CreateSoftware( base::WrapUnique(new SoftwareOutputDevice)); } - MockLayerTreeHostImpl& MockHostImpl() { - return *static_cast<MockLayerTreeHostImpl*>(host_impl()); - } + TestSharedBitmapManager shared_bitmap_manager_; + std::unique_ptr<TaskGraphRunner> task_graph_runner_; + FakeImplTaskRunnerProvider task_runner_provider_; + std::unique_ptr<OutputSurface> output_surface_; + std::unique_ptr<MockLayerTreeHostImpl> host_impl_; }; // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is @@ -1510,12 +1697,11 @@ // Check with no tile work enqueued. { base::RunLoop run_loop; - EXPECT_FALSE( - host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); - EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) + EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); + EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); - EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); + host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); + EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); run_loop.Run(); } @@ -1523,13 +1709,12 @@ // callback. { base::RunLoop run_loop; - EXPECT_FALSE( - host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); - EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) + EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); + EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); - host_impl()->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); - EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); + host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); + host_impl_->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); + EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); run_loop.Run(); } } @@ -1537,35 +1722,34 @@ TEST_F(TileManagerTest, ActivateAndDrawWhenOOM) { SetupDefaultTrees(gfx::Size(1000, 1000)); - auto global_state = host_impl()->global_tile_state(); + auto global_state = host_impl_->global_tile_state(); global_state.hard_memory_limit_in_bytes = 1u; global_state.soft_memory_limit_in_bytes = 1u; { base::RunLoop run_loop; - EXPECT_FALSE( - host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); - EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) + EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); + EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); - host_impl()->tile_manager()->PrepareTiles(global_state); - EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); + host_impl_->tile_manager()->PrepareTiles(global_state); + EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); run_loop.Run(); } - EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToDraw()); - EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); - EXPECT_TRUE(host_impl()->notify_tile_state_changed_called()); + EXPECT_TRUE(host_impl_->tile_manager()->IsReadyToDraw()); + EXPECT_TRUE(host_impl_->tile_manager()->IsReadyToActivate()); + EXPECT_TRUE(host_impl_->notify_tile_state_changed_called()); // Next PrepareTiles should skip NotifyTileStateChanged since all tiles // are marked oom already. { base::RunLoop run_loop; - host_impl()->set_notify_tile_state_changed_called(false); - EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) + host_impl_->set_notify_tile_state_changed_called(false); + EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); - host_impl()->tile_manager()->PrepareTiles(global_state); + host_impl_->tile_manager()->PrepareTiles(global_state); run_loop.Run(); - EXPECT_FALSE(host_impl()->notify_tile_state_changed_called()); + EXPECT_FALSE(host_impl_->notify_tile_state_changed_called()); } } @@ -1600,7 +1784,7 @@ tiling_client.SetTileSize(size); std::unique_ptr<PictureLayerImpl> layer = - PictureLayerImpl::Create(host_impl()->active_tree(), 1, false); + PictureLayerImpl::Create(host_impl_->active_tree(), 1, false); PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); layer->set_is_drawn_render_surface_layer_list_member(true); @@ -1615,14 +1799,14 @@ // SMOOTHNESS_TAKES_PRIORITY ensures that we will actually raster // LOW_RESOLUTION tiles, otherwise they are skipped. - host_impl()->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); + host_impl_->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); // Call PrepareTiles and wait for it to complete. - auto* tile_manager = host_impl()->tile_manager(); + auto* tile_manager = host_impl_->tile_manager(); base::RunLoop run_loop; - EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) + EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); - tile_manager->PrepareTiles(host_impl()->global_tile_state()); + tile_manager->PrepareTiles(host_impl_->global_tile_state()); run_loop.Run(); tile_manager->Flush(); @@ -1632,7 +1816,7 @@ EXPECT_TRUE(tile->draw_info().IsReadyToDraw()); ResourceProvider::ScopedReadLockSoftware lock( - host_impl()->resource_provider(), tile->draw_info().resource_id()); + host_impl_->resource_provider(), tile->draw_info().resource_id()); const SkBitmap* bitmap = lock.sk_bitmap(); for (int x = 0; x < size.width(); ++x) { for (int y = 0; y < size.height(); ++y) { @@ -1655,18 +1839,20 @@ class ActivationTasksDoNotBlockReadyToDrawTest : public TileManagerTest { protected: - std::unique_ptr<TaskGraphRunner> CreateTaskGraphRunner() override { + std::unique_ptr<TaskGraphRunner> GetTaskGraphRunner() const override { return base::WrapUnique(new SynchronousTaskGraphRunner()); } - std::unique_ptr<OutputSurface> CreateOutputSurface() override { + std::unique_ptr<OutputSurface> GetOutputSurface() const override { return FakeOutputSurface::Create3d(); } - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings = TileManagerTest::CreateSettings(); - settings.gpu_rasterization_forced = true; - return settings; + void CustomizeSettings(LayerTreeSettings* settings) override { + settings->gpu_rasterization_forced = true; + } + + SynchronousTaskGraphRunner* GetSynchronousTaskGraphRunner() const { + return static_cast<SynchronousTaskGraphRunner*>(task_graph_runner_.get()); } }; @@ -1674,7 +1860,7 @@ ActivationTasksDoNotBlockReadyToDraw) { const gfx::Size layer_bounds(1000, 1000); - EXPECT_TRUE(host_impl()->use_gpu_rasterization()); + EXPECT_TRUE(host_impl_->use_gpu_rasterization()); // Active tree has no non-solid tiles, so it will generate no tile tasks. std::unique_ptr<FakeRecordingSource> active_tree_recording_source = @@ -1707,15 +1893,14 @@ pending_tree_recording_source.get(), false); SetupTrees(pending_tree_raster_source, active_tree_raster_source); - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); + host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); // The first task to run should be ReadyToDraw (this should not be blocked by // the tasks required for activation). base::RunLoop run_loop; - EXPECT_CALL(MockHostImpl(), NotifyReadyToDraw()) + EXPECT_CALL(*host_impl_, NotifyReadyToDraw()) .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); - static_cast<SynchronousTaskGraphRunner*>(task_graph_runner()) - ->RunSingleTaskForTesting(); + GetSynchronousTaskGraphRunner()->RunSingleTaskForTesting(); run_loop.Run(); } @@ -1738,10 +1923,8 @@ class PartialRasterTileManagerTest : public TileManagerTest { public: - LayerTreeSettings CreateSettings() override { - LayerTreeSettings settings = TileManagerTest::CreateSettings(); - settings.use_partial_raster = true; - return settings; + void CustomizeSettings(LayerTreeSettings* settings) override { + settings->use_partial_raster = true; } }; @@ -1751,7 +1934,7 @@ // Create a CancellingTaskRunner and set it on the tile manager so that all // scheduled work is immediately cancelled. CancellingTileTaskManager cancelling_task_manager; - host_impl()->tile_manager()->SetTileTaskManagerForTesting( + host_impl_->tile_manager()->SetTileTaskManagerForTesting( &cancelling_task_manager); // Pick arbitrary IDs - they don't really matter as long as they're constant. @@ -1761,8 +1944,8 @@ scoped_refptr<FakeRasterSource> pending_raster_source = FakeRasterSource::CreateFilled(kTileSize); - host_impl()->CreatePendingTree(); - LayerTreeImpl* pending_tree = host_impl()->pending_tree(); + host_impl_->CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl_->pending_tree(); // Steal from the recycled tree. std::unique_ptr<FakePictureLayerImpl> pending_layer = @@ -1776,29 +1959,28 @@ pending_tree->SetRootLayer(std::move(pending_layer)); // Add tilings/tiles for the layer. - host_impl()->pending_tree()->BuildPropertyTreesForTesting(); - host_impl()->pending_tree()->UpdateDrawProperties( - false /* update_lcd_text */); + host_impl_->pending_tree()->BuildPropertyTreesForTesting(); + host_impl_->pending_tree()->UpdateDrawProperties(false /* update_lcd_text */); // Build the raster queue and invalidate the top tile. - std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( + std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_->BuildRasterQueue( SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); EXPECT_FALSE(queue->IsEmpty()); queue->Top().tile()->SetInvalidated(gfx::Rect(), kInvalidatedId); // PrepareTiles to schedule tasks. Due to the CancellingTileTaskManager, // these tasks will immediately be canceled. - host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); + host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); // Make sure that the tile we invalidated above was not returned to the pool // with its invalidated resource ID. - host_impl()->resource_pool()->CheckBusyResources(); - EXPECT_FALSE(host_impl()->resource_pool()->TryAcquireResourceWithContentId( + host_impl_->resource_pool()->CheckBusyResources(); + EXPECT_FALSE(host_impl_->resource_pool()->TryAcquireResourceWithContentId( kInvalidatedId)); // Free our host_impl_ before the cancelling_task_manager we passed it, as it // will use that class in clean up. - TakeHostImpl(); + host_impl_ = nullptr; } // FakeRasterBufferProviderImpl that verifies the resource content ID of raster @@ -1906,13 +2088,15 @@ // Ensures that the tile manager successfully reuses tiles when partial // raster is enabled. TEST_F(PartialRasterTileManagerTest, PartialRasterSuccessfullyEnabled) { - RunPartialRasterCheck(TakeHostImpl(), true /* partial_raster_enabled */); + RunPartialRasterCheck(std::move(host_impl_), + true /* partial_raster_enabled */); } // Ensures that the tile manager does not attempt to reuse tiles when partial // raster is disabled. TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { - RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); + RunPartialRasterCheck(std::move(host_impl_), + false /* partial_raster_enabled */); } } // namespace
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index f4860f9..afe1e98 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn
@@ -518,8 +518,11 @@ "{{bundle_root_dir}}/Versions/$chrome_version_full/{{source_file_part}}", ] public_deps = [ - ":chrome_framework", ":chrome_helper_app", + + # verify_chrome_framework_order depends on :chrome_framework and, for + # non-component builds, will ensure the export symbol table is correct. + ":verify_chrome_framework_order", ] } @@ -756,6 +759,7 @@ chrome_dylib_version, "-current_version", chrome_dylib_version, + "-Wl,-order_file," + rebase_path("app/framework.order", root_build_dir), ] if (is_component_build) { @@ -766,6 +770,37 @@ ] } } + + if (!is_asan && !is_component_build) { + action("verify_chrome_framework_order") { + script = "//chrome/tools/build/mac/run_verify_order.py" + stamp_file = "$target_out_dir/run_$target_name.stamp" + inputs = [ + script, + "//chrome/tools/build/mac/verify_order", + ] + args = [ + "--stamp", + rebase_path(stamp_file, root_out_dir), + "_ChromeMain", + rebase_path( + "$root_out_dir/$chrome_framework_name.framework/$chrome_framework_name", + root_out_dir), + ] + outputs = [ + stamp_file, + ] + public_deps = [ + ":chrome_framework", + ] + } + } else { + group("verify_chrome_framework_order") { + public_deps = [ + ":chrome_framework", + ] + } + } } # GYP version: chromium_browser_dependencies variable in chrome.gyp
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java index 07311812..61fcc435 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java
@@ -87,7 +87,7 @@ for (int i = 0; i < TabWindowManager.MAX_SIMULTANEOUS_SELECTORS; i++) { if (processedSelectors.contains(i)) continue; clearedIncognito &= deleteIncognitoStateFilesInDirectory( - TabPersistentStore.getStateDirectory(this, i)); + TabPersistentStore.getOrCreateSelectorStateDirectory(i)); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java index a073f83..2535fc08 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -121,8 +121,6 @@ private int mSnapshotHeight; private int mSnapshotScrollY; - private int mPeekingCardVerticalScrollStart; - /** * Manages the view interaction with the rest of the system. */ @@ -419,7 +417,6 @@ }); initializeSearchBoxRecyclerViewScrollHandling(); mRecyclerView.addItemDecoration(new SnippetItemDecoration(getContext())); - updatePeekingCard(); updateSnippetsHeaderDisplay(); } else { initializeSearchBoxScrollHandling(); @@ -466,7 +463,7 @@ } /** - * Calculate the peeking card/first snippet bleed and padding when scrolling if it is visible. + * Change the peeking card's width, padding and children's opacity to give a smooth transition. */ private void updatePeekingCard() { // Get the first snippet that could display to make the peeking card transition. @@ -475,36 +472,33 @@ if (firstSnippet == null || !firstSnippet.isShown()) return; - // If first snippet exists change the parameters from peeking card with bleed to full page - // card when scrolling. + // If first snippet exists change the peeking card margin and padding to change its + // width when scrolling. // Value used for max peeking card height and padding. int maxPadding = getResources().getDimensionPixelSize( R.dimen.snippets_padding_and_peeking_card_height); - // As the user scrolls, the bleed increases or decreases. - int bleed = maxPadding - (getVerticalScroll() - mPeekingCardVerticalScrollStart); + // The peeking card's resting position is |maxPadding| from the bottom of the screen hence + // |getHeight() - maxPadding|, and it grows the further it gets from this. + int padding = getHeight() - maxPadding - firstSnippet.getTop(); - // Never let the bleed go into negative digits. - bleed = Math.max(bleed, 0); - // Never let the bleed be greater than the maxPadding. - bleed = Math.min(bleed, maxPadding); + // Make sure the |padding| is between 0 and |maxPadding|. + padding = Math.min(Math.max(padding, 0), maxPadding); - // Modify the padding so as the margin increases, the padding decreases so the cards - // content does not shift. Top and bottom remain the same. - firstSnippet.setPadding( - maxPadding - bleed, maxPadding, maxPadding - bleed, maxPadding); + // Modify the padding so as the margin increases, the padding decreases, keeping the card's + // contents in the same position. The top and bottom remain the same. + firstSnippet.setPadding(padding, maxPadding, padding, maxPadding); - // Modify the margin to grow the card from bleed to full width. RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) firstSnippet.getLayoutParams(); - params.leftMargin = bleed; - params.rightMargin = bleed; + params.leftMargin = maxPadding - padding; + params.rightMargin = maxPadding - padding; // Set the opacity of the card content to be 0 when peeking and 1 when full width. int firstSnippetChildCount = firstSnippet.getChildCount(); for (int i = 0; i < firstSnippetChildCount; ++i) { View snippetChild = firstSnippet.getChildAt(i); - snippetChild.setAlpha((maxPadding - bleed) / (float) maxPadding); + snippetChild.setAlpha(padding / (float) maxPadding); } } @@ -603,8 +597,6 @@ mRecyclerView.getHeight() < mMostVisitedLayout.getBottom(); int targetScroll; - // Set peeking card vertical scroll to be vertical scroll. - mPeekingCardVerticalScrollStart = 0; NewTabPageUma.SnapState snapState = NewTabPageUma.SnapState.ABOVE_THE_FOLD; if (currentScroll < mNewTabPageLayout.getHeight() / 3) { // In either case, if in the top 1/3 of the original NTP, snap to the top. @@ -613,8 +605,6 @@ && currentScroll < mNewTabPageLayout.getHeight() * 2 / 3) { // If in the middle 1/3 and we are snapping to Most Likely, snap to it. targetScroll = topOfMostLikelyScroll; - // Set the peeking card vertical scroll start for the snapped view. - mPeekingCardVerticalScrollStart = targetScroll; } else { // Otherwise, snap to the Articles. targetScroll = topOfSnippetsScroll; @@ -971,6 +961,10 @@ // placed with their new layout configurations. setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent); updateSearchBoxOnScroll(); + + if (mUseCardsUi) { + updatePeekingCard(); + } } // MostVisitedURLsObserver implementation @@ -1231,6 +1225,10 @@ mNewTabPageLayout.setParentViewportHeight(MeasureSpec.getSize(heightMeasureSpec)); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + if (mUseCardsUi) { + updatePeekingCard(); + } } private int getVerticalScroll() {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java index a0c6105..f3328c4 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java
@@ -543,6 +543,6 @@ /** @return Where tabbed mode data is stored for the main {@link TabModelImpl}. */ protected File getTabbedDataDirectory() { - return TabPersistentStore.getStateDirectory(getContext(), TAB_MODEL_INDEX); + return TabPersistentStore.getOrCreateSelectorStateDirectory(TAB_MODEL_INDEX); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java index 0af3ce9f..5bf1b58e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java
@@ -163,8 +163,7 @@ initialize(isIncognitoSelected(), normalModel, incognitoModel); mRegularTabCreator.setTabModel(normalModel, mTabContentManager); mIncognitoTabCreator.setTabModel(incognitoModel, mTabContentManager); - - mTabSaver.setTabContentManager(tabContentProvider); + mTabSaver.setTabContentManager(mTabContentManager); addObserver(new EmptyTabModelSelectorObserver() { @Override
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java index 6e787e1..000ebc4 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
@@ -200,7 +200,7 @@ @Override protected File getStateDirectory() { if (mStateDirectory == null) { - mStateDirectory = getStateDirectory(mContext, mSelectorIndex); + mStateDirectory = getOrCreateSelectorStateDirectory(mSelectorIndex); } return mStateDirectory; } @@ -215,24 +215,26 @@ } /** - * @return Folder that all metadata for the ChromeTabbedActivity TabModels should be located. - * Each subdirectory stores info about different instances of ChromeTabbedActivity. + * Folder that all metadata for the TabModels should be located. Each subdirectory stores info + * about different instances of ChromeTabbedActivity. + * + * @return The parent state directory. */ - private static File getBaseStateDirectory(Context context) { + private static File getBaseStateDirectory() { if (sBaseStateDirectory == null) { - setBaseStateDirectory(context.getDir(BASE_STATE_FOLDER, Context.MODE_PRIVATE)); + Context appContext = ContextUtils.getApplicationContext(); + setBaseStateDirectory(appContext.getDir(BASE_STATE_FOLDER, Context.MODE_PRIVATE)); } return sBaseStateDirectory; } /** * The folder where the state should be saved to. - * @param context A Context instance. * @param index The TabModelSelector index. * @return A file representing the directory that contains the TabModelSelector state. */ - public static File getStateDirectory(Context context, int index) { - File file = new File(getBaseStateDirectory(context), Integer.toString(index)); + public static File getOrCreateSelectorStateDirectory(int index) { + File file = new File(getBaseStateDirectory(), Integer.toString(index)); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { @@ -249,7 +251,7 @@ * Waits for the task that migrates all state files to their new location to finish. */ @VisibleForTesting - public static void waitForMigrationToFinish() { + public void waitForMigrationToFinish() { assert sMigrationTask != null : "The migration should be initialized by now."; try { sMigrationTask.get(); @@ -258,10 +260,6 @@ } } - private static void logSaveException(Exception e) { - Log.w(TAG, "Error while saving tabs state; will attempt to continue...", e); - } - /** * Sets the {@link TabContentManager} to use. * @param cache The {@link TabContentManager} to use. @@ -289,7 +287,7 @@ try { saveListToFile(serializeTabMetadata()); } catch (IOException e) { - logSaveException(e); + Log.w(TAG, "Error while saving tabs state; will attempt to continue...", e); } // Add current tabs to save because they did not get a save signal yet. @@ -337,7 +335,7 @@ TabState.saveState(stream, state, incognito); } } catch (IOException e) { - logSaveException(e); + Log.w(TAG, "Error while saving tabs state; will attempt to continue...", e); } catch (OutOfMemoryError e) { Log.w(TAG, "Out of memory error while attempting to save tab state. Erasing."); deleteTabState(id, incognito); @@ -778,7 +776,7 @@ // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/473357 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { - File[] folders = getBaseStateDirectory(mContext).listFiles(); + File[] folders = getBaseStateDirectory().listFiles(); if (folders == null) return; for (File folder : folders) { if (!folder.isDirectory()) continue; @@ -962,6 +960,12 @@ } } + /** + * File mutations (e.g. saving & deleting) are explicitly serialized to ensure that they occur + * in the correct order. + * + * @param file Name of file under the state directory to be deleted. + */ private void deleteFileAsync(final String file) { new AsyncTask<Void, Void, Void>() { @Override @@ -973,7 +977,6 @@ return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); - // Explicitly serializing file mutations (save & delete) to ensure they occur in order. } private class CleanUpTabStateDataTask extends AsyncTask<Void, Void, String[]> { @@ -1005,7 +1008,6 @@ } private class LoadTabTask extends AsyncTask<Void, Void, TabState> { - public final TabRestoreDetails mTabToRestore; public LoadTabTask(TabRestoreDetails tabToRestore) { @@ -1037,7 +1039,6 @@ } private static final class TabRestoreDetails { - public final int id; public final int originalIndex; public final String url; @@ -1054,12 +1055,13 @@ private class FileMigrationTask extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { - File oldFolder = mContext.getFilesDir(); File newFolder = getStateDirectory(); + // If we already have files here just return. File[] newFiles = newFolder.listFiles(); if (newFiles != null && newFiles.length > 0) return null; + File oldFolder = mContext.getFilesDir(); File modelFile = new File(oldFolder, SAVED_STATE_FILE); if (modelFile.exists()) { if (!modelFile.renameTo(new File(newFolder, SAVED_STATE_FILE))) { @@ -1095,8 +1097,7 @@ * * @return True if the tab is definitely Incognito, false if it's not or if it's undecideable. */ - private boolean isIncognitoTabBeingRestored( - TabRestoreDetails tabDetails, TabState tabState) { + private boolean isIncognitoTabBeingRestored(TabRestoreDetails tabDetails, TabState tabState) { if (tabState != null) { // The Tab's previous state was completely restored. return tabState.isIncognito();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/StorageDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/StorageDelegate.java index c81924e..2bd218a6 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/StorageDelegate.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/StorageDelegate.java
@@ -115,9 +115,7 @@ } private void preloadStateDirectory() { - if (sBaseStateDirectoryFetchTask != null) { - return; - } + if (sBaseStateDirectoryFetchTask != null) return; sBaseStateDirectoryFetchTask = new AsyncTask<Void, Void, File>() { @Override @@ -139,8 +137,7 @@ // If the AsyncTask failed for some reason, we have no choice but to fall back to // main-thread disk access. - return ContextUtils.getApplicationContext().getDir( - STATE_DIRECTORY, Context.MODE_PRIVATE); + return ContextUtils.getApplicationContext().getDir(STATE_DIRECTORY, Context.MODE_PRIVATE); } /**
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/RestoreMigrateTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/RestoreMigrateTest.java index 1e6c432..89504bf 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/RestoreMigrateTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/RestoreMigrateTest.java
@@ -36,8 +36,7 @@ return TabPersistentStore.serializeTabModelSelector(selector, null); } }); - File f = TabPersistentStore.getStateDirectory( - getInstrumentation().getTargetContext(), index); + File f = TabPersistentStore.getOrCreateSelectorStateDirectory(index); FileOutputStream fos = null; try { fos = new FileOutputStream(new File(f, TabPersistentStore.SAVED_STATE_FILE)); @@ -87,11 +86,10 @@ MockTabModelSelector selector = new MockTabModelSelector(0, 0, null); TabPersistentStore store = new TabPersistentStore(selector, 0, getInstrumentation().getTargetContext(), null, null); - TabPersistentStore.waitForMigrationToFinish(); + store.waitForMigrationToFinish(); // Check that the files were moved. - File newDir = - TabPersistentStore.getStateDirectory(getInstrumentation().getTargetContext(), 0); + File newDir = TabPersistentStore.getOrCreateSelectorStateDirectory(0); File newStateFile = new File(newDir, TabPersistentStore.SAVED_STATE_FILE); File newTab0 = new File(newDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0"); File newTab1 = new File(newDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "1"); @@ -140,8 +138,7 @@ assertTrue("Could not create tab 3 file", tab3.createNewFile()); // Write new state files - File newDir = - TabPersistentStore.getStateDirectory(getInstrumentation().getTargetContext(), 0); + File newDir = TabPersistentStore.getOrCreateSelectorStateDirectory(0); File newStateFile = new File(newDir, TabPersistentStore.SAVED_STATE_FILE); File newTab4 = new File(newDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "4"); @@ -152,7 +149,7 @@ MockTabModelSelector selector = new MockTabModelSelector(0, 0, null); TabPersistentStore store = new TabPersistentStore(selector, 0, getInstrumentation().getTargetContext(), null, null); - TabPersistentStore.waitForMigrationToFinish(); + store.waitForMigrationToFinish(); assertTrue("Could not find new state file", newStateFile.exists()); assertTrue("Could not find new tab 4 file", newTab4.exists()); @@ -198,15 +195,14 @@ MockTabModelSelector selector = new MockTabModelSelector(0, 0, null); TabPersistentStore store = new TabPersistentStore(selector, 0, getInstrumentation().getTargetContext(), null, null); - TabPersistentStore.waitForMigrationToFinish(); + store.waitForMigrationToFinish(); assertFalse("Could still find old state file", stateFile.exists()); assertFalse("Could still find old tab 0 file", tab0.exists()); assertTrue("Could not find other file", otherFile.exists()); // Check that the files were moved. - File newDir = - TabPersistentStore.getStateDirectory(getInstrumentation().getTargetContext(), 0); + File newDir = TabPersistentStore.getOrCreateSelectorStateDirectory(0); File newStateFile = new File(newDir, TabPersistentStore.SAVED_STATE_FILE); File newTab0 = new File(newDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0"); File newOtherFile = new File(newDir, "other.file");
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/invalidation/InvalidationControllerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/invalidation/InvalidationControllerTest.java index 8d6b1033..85e22e2 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/invalidation/InvalidationControllerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/invalidation/InvalidationControllerTest.java
@@ -13,6 +13,7 @@ import org.chromium.base.ApplicationState; import org.chromium.base.ApplicationStatus; import org.chromium.base.CollectionUtil; +import org.chromium.base.ContextUtils; import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.sync.ProfileSyncService; import org.chromium.components.invalidation.InvalidationClientService; @@ -72,7 +73,6 @@ private ShadowActivity mShadowActivity; private Context mContext; - private InvalidationController mController; /** * The names of the preferred ModelTypes. @@ -89,8 +89,10 @@ Activity activity = Robolectric.buildActivity(Activity.class).setup().get(); mShadowActivity = Robolectric.shadowOf(activity); mContext = activity; + ContextUtils.initApplicationContextForTests(mContext.getApplicationContext()); ModelTypeHelper.setTestDelegate(new ModelTypeHelper.TestDelegate() { + @Override public String toNotificationType(int modelType) { return Integer.toString(modelType); }
diff --git a/chrome/browser/android/ntp/most_visited_sites.cc b/chrome/browser/android/ntp/most_visited_sites.cc index a8766c0..372090f 100644 --- a/chrome/browser/android/ntp/most_visited_sites.cc +++ b/chrome/browser/android/ntp/most_visited_sites.cc
@@ -200,8 +200,8 @@ supervisor_->SetObserver(nullptr); } -void MostVisitedSites::SetMostVisitedURLsObserver( - MostVisitedSites::Observer* observer, int num_sites) { +void MostVisitedSites::SetMostVisitedURLsObserver(Observer* observer, + int num_sites) { DCHECK(observer); observer_ = observer; num_sites_ = num_sites; @@ -218,6 +218,7 @@ received_popular_sites_ = true; } + // TODO(treib): Can |top_sites_| ever be null? If not, remove these checks. if (top_sites_) { // TopSites updates itself after a delay. To ensure up-to-date results, // force an update now. @@ -239,11 +240,11 @@ suggestions_service_->FetchSuggestionsData(); } -void MostVisitedSites::GetURLThumbnail( - const GURL& url, - const ThumbnailCallback& callback) { +void MostVisitedSites::GetURLThumbnail(const GURL& url, + const ThumbnailCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); + // TODO(treib): Move this to the blocking pool? Doesn't seem related to DB. BrowserThread::PostTaskAndReplyWithResult( BrowserThread::DB, FROM_HERE, base::Bind(&MaybeFetchLocalThumbnail, url, top_sites_), @@ -284,17 +285,16 @@ OnObtainedThumbnail(true, callback, url, bitmap.get()); } -void MostVisitedSites::OnObtainedThumbnail( - bool is_local_thumbnail, - const ThumbnailCallback& callback, - const GURL& url, - const SkBitmap* bitmap) { +void MostVisitedSites::OnObtainedThumbnail(bool is_local_thumbnail, + const ThumbnailCallback& callback, + const GURL& url, + const SkBitmap* bitmap) { DCHECK_CURRENTLY_ON(BrowserThread::UI); callback.Run(is_local_thumbnail, bitmap); } -void MostVisitedSites::AddOrRemoveBlacklistedUrl( - const GURL& url, bool add_url) { +void MostVisitedSites::AddOrRemoveBlacklistedUrl(const GURL& url, + bool add_url) { // Always blacklist in the local TopSites. if (top_sites_) { if (add_url) @@ -354,7 +354,12 @@ // static void MostVisitedSites::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { + // TODO(treib): Remove this, it's unused. Do we need migration code to clean + // up existing entries? registry->RegisterListPref(ntp_tiles::prefs::kNTPSuggestionsURL); + // TODO(treib): Remove this. It's only used to determine if we need + // PopularSites at all. Find a way to do that without prefs, or failing that, + // replace this list pref by a simple bool. registry->RegisterListPref(ntp_tiles::prefs::kNTPSuggestionsIsPersonal); } @@ -385,7 +390,7 @@ void MostVisitedSites::OnMostVisitedURLsAvailable( const history::MostVisitedURLList& visited_list) { - MostVisitedSites::SuggestionsPtrVector suggestions; + SuggestionsPtrVector suggestions; size_t num_tiles = std::min(visited_list.size(), static_cast<size_t>(num_sites_)); for (size_t i = 0; i < num_tiles; ++i) { @@ -408,7 +413,7 @@ received_most_visited_sites_ = true; mv_source_ = TOP_SITES; - SaveNewNTPSuggestions(&suggestions); + SaveNewSuggestions(&suggestions); NotifyMostVisitedURLsObserver(); } @@ -423,7 +428,7 @@ if (num_sites_ < num_tiles) num_tiles = num_sites_; - MostVisitedSites::SuggestionsPtrVector suggestions; + SuggestionsPtrVector suggestions; for (int i = 0; i < num_tiles; ++i) { const ChromeSuggestion& suggestion = suggestions_profile.suggestions(i); if (supervisor_->IsBlocked(GURL(suggestion.url()))) @@ -443,18 +448,18 @@ received_most_visited_sites_ = true; mv_source_ = SUGGESTIONS_SERVICE; - SaveNewNTPSuggestions(&suggestions); + SaveNewSuggestions(&suggestions); NotifyMostVisitedURLsObserver(); } MostVisitedSites::SuggestionsPtrVector MostVisitedSites::CreateWhitelistEntryPointSuggestions( - const MostVisitedSites::SuggestionsPtrVector& personal_suggestions) { + const SuggestionsPtrVector& personal_suggestions) { size_t num_personal_suggestions = personal_suggestions.size(); DCHECK_LE(num_personal_suggestions, static_cast<size_t>(num_sites_)); size_t num_whitelist_suggestions = num_sites_ - num_personal_suggestions; - MostVisitedSites::SuggestionsPtrVector whitelist_suggestions; + SuggestionsPtrVector whitelist_suggestions; std::set<std::string> personal_hosts; for (const auto& suggestion : personal_suggestions) @@ -490,11 +495,11 @@ MostVisitedSites::SuggestionsPtrVector MostVisitedSites::CreatePopularSitesSuggestions( - const MostVisitedSites::SuggestionsPtrVector& personal_suggestions, - const MostVisitedSites::SuggestionsPtrVector& whitelist_suggestions) { + const SuggestionsPtrVector& personal_suggestions, + const SuggestionsPtrVector& whitelist_suggestions) { // For child accounts popular sites suggestions will not be added. if (supervisor_->IsChildProfile()) - return MostVisitedSites::SuggestionsPtrVector(); + return SuggestionsPtrVector(); size_t num_suggestions = personal_suggestions.size() + whitelist_suggestions.size(); @@ -503,7 +508,7 @@ // Collect non-blacklisted popular suggestions, skipping those already present // in the personal suggestions. size_t num_popular_sites_suggestions = num_sites_ - num_suggestions; - MostVisitedSites::SuggestionsPtrVector popular_sites_suggestions; + SuggestionsPtrVector popular_sites_suggestions; if (num_popular_sites_suggestions > 0 && popular_sites_) { std::set<std::string> hosts; @@ -533,185 +538,77 @@ return popular_sites_suggestions; } -void MostVisitedSites::SaveNewNTPSuggestions( - MostVisitedSites::SuggestionsPtrVector* personal_suggestions) { - MostVisitedSites::SuggestionsPtrVector whitelist_suggestions = +void MostVisitedSites::SaveNewSuggestions( + SuggestionsPtrVector* personal_suggestions) { + SuggestionsPtrVector whitelist_suggestions = CreateWhitelistEntryPointSuggestions(*personal_suggestions); - MostVisitedSites::SuggestionsPtrVector popular_sites_suggestions = + SuggestionsPtrVector popular_sites_suggestions = CreatePopularSitesSuggestions(*personal_suggestions, whitelist_suggestions); + size_t num_actual_tiles = personal_suggestions->size() + whitelist_suggestions.size() + popular_sites_suggestions.size(); - std::vector<std::string> old_sites_url; - std::vector<bool> old_sites_is_personal; - // TODO(treib): We used to call |GetPreviousNTPSites| here to populate - // |old_sites_url| and |old_sites_is_personal|, but that caused problems - // (crbug.com/585391). Either figure out a way to fix them and re-enable, - // or properly remove the order-persisting code. crbug.com/601734 - MostVisitedSites::SuggestionsPtrVector merged_suggestions = MergeSuggestions( - personal_suggestions, &whitelist_suggestions, &popular_sites_suggestions, - old_sites_url, old_sites_is_personal); + DCHECK_LE(num_actual_tiles, static_cast<size_t>(num_sites_)); + + SuggestionsPtrVector merged_suggestions = MergeSuggestions( + personal_suggestions, &whitelist_suggestions, &popular_sites_suggestions); DCHECK_EQ(num_actual_tiles, merged_suggestions.size()); + current_suggestions_.resize(merged_suggestions.size()); for (size_t i = 0; i < merged_suggestions.size(); ++i) std::swap(*merged_suggestions[i], current_suggestions_[i]); + if (received_popular_sites_) - SaveCurrentNTPSites(); + SaveCurrentSuggestionsToPrefs(); } // static MostVisitedSites::SuggestionsPtrVector MostVisitedSites::MergeSuggestions( - MostVisitedSites::SuggestionsPtrVector* personal_suggestions, - MostVisitedSites::SuggestionsPtrVector* whitelist_suggestions, - MostVisitedSites::SuggestionsPtrVector* popular_suggestions, - const std::vector<std::string>& old_sites_url, - const std::vector<bool>& old_sites_is_personal) { + SuggestionsPtrVector* personal_suggestions, + SuggestionsPtrVector* whitelist_suggestions, + SuggestionsPtrVector* popular_suggestions) { size_t num_personal_suggestions = personal_suggestions->size(); size_t num_whitelist_suggestions = whitelist_suggestions->size(); size_t num_popular_suggestions = popular_suggestions->size(); size_t num_tiles = num_popular_suggestions + num_whitelist_suggestions + num_personal_suggestions; - MostVisitedSites::SuggestionsPtrVector merged_suggestions; - merged_suggestions.resize(num_tiles); + SuggestionsPtrVector merged_suggestions; + AppendSuggestions(personal_suggestions, &merged_suggestions); + AppendSuggestions(whitelist_suggestions, &merged_suggestions); + AppendSuggestions(popular_suggestions, &merged_suggestions); + DCHECK_EQ(num_tiles, merged_suggestions.size()); - size_t num_old_tiles = old_sites_url.size(); - DCHECK_LE(num_old_tiles, num_tiles); - DCHECK_EQ(num_old_tiles, old_sites_is_personal.size()); - std::vector<std::string> old_sites_host; - old_sites_host.reserve(num_old_tiles); - // Only populate the hosts for popular suggestions as only they can be - // replaced by host. Personal suggestions require an exact url match to be - // replaced. - for (size_t i = 0; i < num_old_tiles; ++i) { - old_sites_host.push_back(old_sites_is_personal[i] - ? std::string() - : GURL(old_sites_url[i]).host()); - } - - // Insert personal suggestions if they existed previously. - std::vector<size_t> new_personal_suggestions = InsertMatchingSuggestions( - personal_suggestions, &merged_suggestions, old_sites_url, old_sites_host); - // Insert whitelist suggestions if they existed previously. - std::vector<size_t> new_whitelist_suggestions = - InsertMatchingSuggestions(whitelist_suggestions, &merged_suggestions, - old_sites_url, old_sites_host); - // Insert popular suggestions if they existed previously. - std::vector<size_t> new_popular_suggestions = InsertMatchingSuggestions( - popular_suggestions, &merged_suggestions, old_sites_url, old_sites_host); - // Insert leftover personal suggestions. - size_t filled_so_far = InsertAllSuggestions( - 0, new_personal_suggestions, personal_suggestions, &merged_suggestions); - // Insert leftover whitelist suggestions. - filled_so_far = - InsertAllSuggestions(filled_so_far, new_whitelist_suggestions, - whitelist_suggestions, &merged_suggestions); - // Insert leftover popular suggestions. - InsertAllSuggestions(filled_so_far, new_popular_suggestions, - popular_suggestions, &merged_suggestions); return merged_suggestions; } -void MostVisitedSites::GetPreviousNTPSites( - size_t num_tiles, - std::vector<std::string>* old_sites_url, - std::vector<bool>* old_sites_is_personal) const { - const base::ListValue* url_list = prefs_->GetList( - ntp_tiles::prefs::kNTPSuggestionsURL); - const base::ListValue* source_list = - prefs_->GetList(ntp_tiles::prefs::kNTPSuggestionsIsPersonal); - DCHECK_EQ(url_list->GetSize(), source_list->GetSize()); - if (url_list->GetSize() < num_tiles) - num_tiles = url_list->GetSize(); - if (num_tiles == 0) { - // No fallback required as Personal suggestions take precedence anyway. - return; - } - old_sites_url->reserve(num_tiles); - old_sites_is_personal->reserve(num_tiles); - for (size_t i = 0; i < num_tiles; ++i) { - std::string url_string; - bool success = url_list->GetString(i, &url_string); - DCHECK(success); - old_sites_url->push_back(url_string); - bool is_personal; - success = source_list->GetBoolean(i, &is_personal); - DCHECK(success); - old_sites_is_personal->push_back(is_personal); - } +// TODO(treib): Once we use SuggestionsVector (non-Ptr) everywhere, move this +// into an anonymous namespace. +// static +void MostVisitedSites::AppendSuggestions(SuggestionsPtrVector* src, + SuggestionsPtrVector* dst) { + dst->insert(dst->end(), + std::make_move_iterator(src->begin()), + std::make_move_iterator(src->end())); } -void MostVisitedSites::SaveCurrentNTPSites() { +void MostVisitedSites::SaveCurrentSuggestionsToPrefs() { base::ListValue url_list; base::ListValue source_list; for (const auto& suggestion : current_suggestions_) { url_list.AppendString(suggestion.url.spec()); - source_list.AppendBoolean(suggestion.source != MostVisitedSites::POPULAR); + source_list.AppendBoolean(suggestion.source != POPULAR); } prefs_->Set(ntp_tiles::prefs::kNTPSuggestionsIsPersonal, source_list); prefs_->Set(ntp_tiles::prefs::kNTPSuggestionsURL, url_list); } -// static -std::vector<size_t> MostVisitedSites::InsertMatchingSuggestions( - MostVisitedSites::SuggestionsPtrVector* src_suggestions, - MostVisitedSites::SuggestionsPtrVector* dst_suggestions, - const std::vector<std::string>& match_urls, - const std::vector<std::string>& match_hosts) { - std::vector<size_t> unmatched_suggestions; - size_t num_src_suggestions = src_suggestions->size(); - size_t num_matchers = match_urls.size(); - for (size_t i = 0; i < num_src_suggestions; ++i) { - size_t position; - for (position = 0; position < num_matchers; ++position) { - if ((*dst_suggestions)[position] != nullptr) - continue; - if (match_urls[position] == (*src_suggestions)[i]->url.spec()) - break; - // match_hosts is only populated for suggestions which can be replaced by - // host matching like popular suggestions. - if (match_hosts[position] == (*src_suggestions)[i]->url.host()) - break; - } - if (position == num_matchers) { - unmatched_suggestions.push_back(i); - } else { - // A move is required as the source and destination containers own the - // elements. - std::swap((*dst_suggestions)[position], (*src_suggestions)[i]); - } - } - return unmatched_suggestions; -} - -// static -size_t MostVisitedSites::InsertAllSuggestions( - size_t start_position, - const std::vector<size_t>& insert_positions, - std::vector<std::unique_ptr<Suggestion>>* src_suggestions, - std::vector<std::unique_ptr<Suggestion>>* dst_suggestions) { - size_t num_inserts = insert_positions.size(); - size_t num_dests = dst_suggestions->size(); - - size_t src_pos = 0; - size_t i = start_position; - for (; i < num_dests && src_pos < num_inserts; ++i) { - if ((*dst_suggestions)[i] != nullptr) - continue; - size_t src = insert_positions[src_pos++]; - std::swap((*dst_suggestions)[i], (*src_suggestions)[src]); - } - // Return destination positions filled so far which becomes the start_position - // for future runs. - return i; -} - void MostVisitedSites::NotifyMostVisitedURLsObserver() { - size_t num_suggestions = current_suggestions_.size(); if (received_most_visited_sites_ && received_popular_sites_ && !recorded_uma_) { RecordImpressionUMAMetrics(); - UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", num_suggestions); + UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", + current_suggestions_.size()); recorded_uma_ = true; }
diff --git a/chrome/browser/android/ntp/most_visited_sites.h b/chrome/browser/android/ntp/most_visited_sites.h index 8416b4b8..14b3e636 100644 --- a/chrome/browser/android/ntp/most_visited_sites.h +++ b/chrome/browser/android/ntp/most_visited_sites.h
@@ -159,8 +159,8 @@ void BuildCurrentSuggestions(); - // Initialize the query to Top Sites. Called if the SuggestionsService is not - // enabled, or if it returns no data. + // Initialize the query to Top Sites. Called if the SuggestionsService + // returned no data. void InitiateTopSitesQuery(); // If there's a whitelist entry point for the URL, return the large icon path. @@ -187,42 +187,20 @@ // Takes the personal suggestions, creates and merges in whitelist and popular // suggestions if appropriate, and saves the new suggestions. - void SaveNewNTPSuggestions(SuggestionsPtrVector* personal_suggestions); + void SaveNewSuggestions(SuggestionsPtrVector* personal_suggestions); - // Workhorse for SaveNewNTPSuggestions above. Implemented as a separate static + // Workhorse for SaveNewSuggestions above. Implemented as a separate static // method for ease of testing. static SuggestionsPtrVector MergeSuggestions( SuggestionsPtrVector* personal_suggestions, SuggestionsPtrVector* whitelist_suggestions, - SuggestionsPtrVector* popular_suggestions, - const std::vector<std::string>& old_sites_url, - const std::vector<bool>& old_sites_is_personal); + SuggestionsPtrVector* popular_suggestions); - void GetPreviousNTPSites(size_t num_tiles, - std::vector<std::string>* old_sites_url, - std::vector<bool>* old_sites_source) const; + // Appends suggestions from |src| to |dst|. + static void AppendSuggestions(SuggestionsPtrVector* src, + SuggestionsPtrVector* dst); - void SaveCurrentNTPSites(); - - // Takes suggestions from |src_suggestions| and moves them to - // |dst_suggestions| if the suggestion's url/host matches - // |match_urls|/|match_hosts| respectively. Unmatched suggestion indices from - // |src_suggestions| are returned for ease of insertion later. - static std::vector<size_t> InsertMatchingSuggestions( - SuggestionsPtrVector* src_suggestions, - SuggestionsPtrVector* dst_suggestions, - const std::vector<std::string>& match_urls, - const std::vector<std::string>& match_hosts); - - // Inserts suggestions from |src_suggestions| at positions |insert_positions| - // into |dst_suggestions| where ever empty starting from |start_position|. - // Returns the last filled position so that future insertions can start from - // there. - static size_t InsertAllSuggestions( - size_t start_position, - const std::vector<size_t>& insert_positions, - SuggestionsPtrVector* src_suggestions, - SuggestionsPtrVector* dst_suggestions); + void SaveCurrentSuggestionsToPrefs(); // Notifies the observer about the availability of suggestions. // Also records impressions UMA if not done already.
diff --git a/chrome/browser/android/ntp/most_visited_sites_unittest.cc b/chrome/browser/android/ntp/most_visited_sites_unittest.cc index 7a18c5c..c629a7d 100644 --- a/chrome/browser/android/ntp/most_visited_sites_unittest.cc +++ b/chrome/browser/android/ntp/most_visited_sites_unittest.cc
@@ -35,22 +35,17 @@ } // namespace // This a test for MostVisitedSites::MergeSuggestions(...) method, and thus has -// the same scope as the method itself. This includes: -// + Merge popular suggestions with personal suggestions. -// + Order the suggestions correctly based on the previous ordering. -// More importantly things out of the scope of testing presently: +// the same scope as the method itself. This tests merging popular suggestions +// with personal suggestions. +// More important things out of the scope of testing presently: // - Removing blacklisted suggestions. -// - Storing the current suggestion ordering. -// - Retrieving the previous ordering. -// - Correct Host extraction from the URL. +// - Correct host extraction from the URL. // - Ensuring personal suggestions are not duplicated in popular suggestions. class MostVisitedSitesTest : public testing::Test { protected: void Check(const std::vector<TitleURL>& popular_sites, const std::vector<TitleURL>& whitelist_entry_points, const std::vector<TitleURL>& personal_sites, - const std::vector<std::string>& old_sites_url, - const std::vector<bool>& old_sites_is_personal, const std::vector<bool>& expected_sites_is_personal, const std::vector<TitleURL>& expected_sites) { MostVisitedSites::SuggestionsPtrVector personal_suggestions; @@ -63,9 +58,9 @@ for (const TitleURL& site : popular_sites) popular_suggestions.push_back(MakeSuggestionFrom(site, false, false)); MostVisitedSites::SuggestionsPtrVector result_suggestions = - MostVisitedSites::MergeSuggestions( - &personal_suggestions, &whitelist_suggestions, &popular_suggestions, - old_sites_url, old_sites_is_personal); + MostVisitedSites::MergeSuggestions(&personal_suggestions, + &whitelist_suggestions, + &popular_suggestions); std::vector<TitleURL> result_sites; std::vector<bool> result_is_personal; result_sites.reserve(result_suggestions.size()); @@ -76,8 +71,8 @@ result_is_personal.push_back(suggestion->source != MostVisitedSites::POPULAR); } - EXPECT_EQ(result_is_personal, expected_sites_is_personal); - EXPECT_EQ(result_sites, expected_sites); + EXPECT_EQ(expected_sites_is_personal, result_is_personal); + EXPECT_EQ(expected_sites, result_sites); } static std::unique_ptr<MostVisitedSites::Suggestion> MakeSuggestionFrom( const TitleURL& title_url, @@ -94,148 +89,51 @@ } }; -TEST_F(MostVisitedSitesTest, PersonalSitesDefaultOrder) { - TitleURL personal[] = { +TEST_F(MostVisitedSitesTest, PersonalSites) { + std::vector<TitleURL> personal_sites{ TitleURL("Site 1", "https://www.site1.com/"), TitleURL("Site 2", "https://www.site2.com/"), TitleURL("Site 3", "https://www.site3.com/"), TitleURL("Site 4", "https://www.site4.com/"), }; - std::vector<TitleURL> personal_sites(personal, - personal + arraysize(personal)); - std::vector<std::string> old_sites_url; - std::vector<bool> old_sites_source; - // Without any previous ordering or popular suggestions, the result after - // merge should be the personal suggestions themselves. + // Without any popular suggestions, the result after merge should be the + // personal suggestions. std::vector<bool> expected_sites_source(kNumSites, true /*personal source*/); Check(std::vector<TitleURL>(), std::vector<TitleURL>(), personal_sites, - old_sites_url, old_sites_source, expected_sites_source, personal_sites); + expected_sites_source, personal_sites); } -TEST_F(MostVisitedSitesTest, PersonalSitesDefinedOrder) { - TitleURL personal[] = { +TEST_F(MostVisitedSitesTest, PopularSites) { + std::vector<TitleURL> popular_sites{ TitleURL("Site 1", "https://www.site1.com/"), TitleURL("Site 2", "https://www.site2.com/"), TitleURL("Site 3", "https://www.site3.com/"), TitleURL("Site 4", "https://www.site4.com/"), }; - std::string old[] = { - "https://www.site4.com/", "https://www.site2.com/", - }; - std::vector<bool> old_sites_source(arraysize(old), true /*personal source*/); - TitleURL expected[] = { - TitleURL("Site 4", "https://www.site4.com/"), - TitleURL("Site 2", "https://www.site2.com/"), - TitleURL("Site 1", "https://www.site1.com/"), - TitleURL("Site 3", "https://www.site3.com/"), - }; - std::vector<bool> expected_sites_source(kNumSites, true /*personal source*/); - Check(std::vector<TitleURL>(), std::vector<TitleURL>(), - std::vector<TitleURL>(personal, personal + arraysize(personal)), - std::vector<std::string>(old, old + arraysize(old)), old_sites_source, - expected_sites_source, - std::vector<TitleURL>(expected, expected + arraysize(expected))); -} - -TEST_F(MostVisitedSitesTest, PopularSitesDefaultOrder) { - TitleURL popular[] = { - TitleURL("Site 1", "https://www.site1.com/"), - TitleURL("Site 2", "https://www.site2.com/"), - TitleURL("Site 3", "https://www.site3.com/"), - TitleURL("Site 4", "https://www.site4.com/"), - }; - std::vector<TitleURL> popular_sites(popular, popular + arraysize(popular)); - std::vector<std::string> old_sites_url; - std::vector<bool> old_sites_source; - // Without any previous ordering or personal suggestions, the result after - // merge should be the popular suggestions themselves. + // Without any personal suggestions, the result after merge should be the + // popular suggestions. std::vector<bool> expected_sites_source(kNumSites, false /*popular source*/); Check(popular_sites, std::vector<TitleURL>(), std::vector<TitleURL>(), - old_sites_url, old_sites_source, expected_sites_source, popular_sites); + expected_sites_source, popular_sites); } -TEST_F(MostVisitedSitesTest, PopularSitesDefinedOrder) { - TitleURL popular[] = { - TitleURL("Site 1", "https://www.site1.com/"), - TitleURL("Site 2", "https://www.site2.com/"), - TitleURL("Site 3", "https://www.site3.com/"), - TitleURL("Site 4", "https://www.site4.com/"), - }; - std::string old[] = { - "https://www.site4.com/", "https://www.site2.com/", - }; - std::vector<bool> old_sites_source(arraysize(old), false /*popular source*/); - TitleURL expected[] = { - TitleURL("Site 4", "https://www.site4.com/"), - TitleURL("Site 2", "https://www.site2.com/"), - TitleURL("Site 1", "https://www.site1.com/"), - TitleURL("Site 3", "https://www.site3.com/"), - }; - std::vector<bool> expected_sites_source(kNumSites, false /*popular source*/); - Check(std::vector<TitleURL>(popular, popular + arraysize(popular)), - std::vector<TitleURL>(), std::vector<TitleURL>(), - std::vector<std::string>(old, old + arraysize(old)), old_sites_source, - expected_sites_source, - std::vector<TitleURL>(expected, expected + arraysize(expected))); -} - -TEST_F(MostVisitedSitesTest, PopularAndPersonalDefaultOrder) { - TitleURL popular[] = { +TEST_F(MostVisitedSitesTest, PersonalPrecedePopularSites) { + std::vector<TitleURL> popular_sites{ TitleURL("Site 1", "https://www.site1.com/"), TitleURL("Site 2", "https://www.site2.com/"), }; - TitleURL personal[] = { + std::vector<TitleURL> personal_sites{ TitleURL("Site 3", "https://www.site3.com/"), TitleURL("Site 4", "https://www.site4.com/"), }; - // Without an explicit ordering, personal suggestions precede popular - // suggestions. - TitleURL expected[] = { + // Personal suggestions should precede popular suggestions. + std::vector<TitleURL> expected_sites{ TitleURL("Site 3", "https://www.site3.com/"), TitleURL("Site 4", "https://www.site4.com/"), TitleURL("Site 1", "https://www.site1.com/"), TitleURL("Site 2", "https://www.site2.com/"), }; - bool expected_source_is_personal[] = {true, true, false, false}; - Check(std::vector<TitleURL>(popular, popular + arraysize(popular)), - std::vector<TitleURL>(), - std::vector<TitleURL>(personal, personal + arraysize(personal)), - std::vector<std::string>(), std::vector<bool>(), - std::vector<bool>(expected_source_is_personal, - expected_source_is_personal + - arraysize(expected_source_is_personal)), - std::vector<TitleURL>(expected, expected + arraysize(expected))); -} - -TEST_F(MostVisitedSitesTest, PopularAndPersonalDefinedOrder) { - TitleURL popular[] = { - TitleURL("Site 1", "https://www.site1.com/"), - TitleURL("Site 2", "https://www.site2.com/"), - }; - TitleURL personal[] = { - TitleURL("Site 3", "https://www.site3.com/"), - TitleURL("Site 4", "https://www.site4.com/"), - }; - std::string old[] = { - "https://www.site2.com/", "https://www.unknownsite.com/", - "https://www.site4.com/", - }; - std::vector<bool> old_sites_source(arraysize(old), false /*popular source*/); - // Keep the order constant for previous suggestions, else personal suggestions - // precede popular suggestions. - TitleURL expected[] = { - TitleURL("Site 2", "https://www.site2.com/"), - TitleURL("Site 3", "https://www.site3.com/"), - TitleURL("Site 4", "https://www.site4.com/"), - TitleURL("Site 1", "https://www.site1.com/"), - }; - bool expected_source_is_personal[] = {false, true, true, false}; - Check(std::vector<TitleURL>(popular, popular + arraysize(popular)), - std::vector<TitleURL>(), - std::vector<TitleURL>(personal, personal + arraysize(personal)), - std::vector<std::string>(old, old + arraysize(old)), old_sites_source, - std::vector<bool>(expected_source_is_personal, - expected_source_is_personal + - arraysize(expected_source_is_personal)), - std::vector<TitleURL>(expected, expected + arraysize(expected))); + std::vector<bool> expected_sites_source{true, true, false, false}; + Check(popular_sites, std::vector<TitleURL>(), personal_sites, + expected_sites_source, expected_sites); }
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index b107415b..2a24e8a 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -2540,6 +2540,17 @@ #endif } +bool ChromeContentBrowserClient::IsPepperVpnProviderAPIAllowed( + content::BrowserContext* browser_context, + const GURL& url) { +#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) + return ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed( + browser_context, url); +#else + return false; +#endif +} + ui::SelectFilePolicy* ChromeContentBrowserClient::CreateSelectFilePolicy( WebContents* web_contents) { return new ChromeSelectFilePolicy(web_contents);
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index a01f4d5..82affab 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h
@@ -228,6 +228,8 @@ const GURL& url, bool private_api, const content::SocketPermissionRequest* params) override; + bool IsPepperVpnProviderAPIAllowed(content::BrowserContext* browser_context, + const GURL& url) override; ui::SelectFilePolicy* CreateSelectFilePolicy( content::WebContents* web_contents) override; void GetAdditionalAllowedSchemesForFileSystem(
diff --git a/chrome/browser/chromeos/arc/arc_auth_service.cc b/chrome/browser/chromeos/arc/arc_auth_service.cc index 470e17e..bfea838 100644 --- a/chrome/browser/chromeos/arc/arc_auth_service.cc +++ b/chrome/browser/chromeos/arc/arc_auth_service.cc
@@ -18,6 +18,7 @@ #include "chrome/browser/browser_process_platform_part.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/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/extensions/extension_util.h" @@ -28,6 +29,7 @@ #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/extensions/app_launch_params.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/common/pref_names.h" @@ -60,10 +62,6 @@ base::LazyInstance<base::ThreadChecker> thread_checker = LAZY_INSTANCE_INITIALIZER; -const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; -const char kArcSupportExtensionId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; -const char kArcSupportStorageId[] = "arc_support"; - // Skip creating UI in unit tests bool disable_ui_for_testing = false; @@ -128,6 +126,33 @@ enable_check_android_management_for_testing = true; } +bool ArcAuthService::IsAllowedForProfile(const Profile* profile) { + if (!arc::ArcBridgeService::GetEnabled( + base::CommandLine::ForCurrentProcess())) { + VLOG(1) << "Arc is not enabled."; + return false; + } + + user_manager::User const* const user = + chromeos::ProfileHelper::Get()->GetUserByProfile(profile); + if (profile->IsLegacySupervised()) { + VLOG(1) << "Supervised users are not supported in ARC."; + return false; + } + if (!user->HasGaiaAccount()) { + VLOG(1) << "Users without GAIA accounts are not supported in ARC."; + return false; + } + + if (user_manager::UserManager::Get() + ->IsCurrentUserCryptohomeDataEphemeral()) { + VLOG(2) << "Users with ephemeral data are not supported in Arc."; + return false; + } + + return true; +} + void ArcAuthService::OnAuthInstanceReady() { arc_bridge_service()->auth_instance()->Init( binding_.CreateInterfacePtrAndBind()); @@ -234,37 +259,28 @@ FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInChanged(state_)); } +bool ArcAuthService::IsAllowed() const { + DCHECK(thread_checker.Get().CalledOnValidThread()); + return profile_ != nullptr; +} + void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { DCHECK(profile && profile != profile_); DCHECK(thread_checker.Get().CalledOnValidThread()); Shutdown(); - user_manager::User const* const user = - chromeos::ProfileHelper::Get()->GetUserByProfile(profile); - if (profile->IsLegacySupervised()) { - VLOG(1) << "Supervised users are not supported in ARC."; + if (!IsAllowedForProfile(profile)) return; - } - if (!user->HasGaiaAccount()) { - VLOG(1) << "Users without GAIA accounts are not supported in ARC."; - return; - } - - if (user_manager::UserManager::Get() - ->IsCurrentUserCryptohomeDataEphemeral()) { - VLOG(2) << "Users with ephemeral data are not supported in Arc."; - return; - } profile_ = profile; PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( prefs::kArcEnabled, this); // Reuse storage used in ARC OptIn platform app. - const std::string site_url = - base::StringPrintf("%s://%s/persist?%s", content::kGuestScheme, - kArcSupportExtensionId, kArcSupportStorageId); + const std::string site_url = base::StringPrintf( + "%s://%s/persist?%s", content::kGuestScheme, ArcSupportHost::kHostAppId, + ArcSupportHost::kStorageId); storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( profile_, GURL(site_url)); CHECK(storage_partition_); @@ -335,14 +351,16 @@ const extensions::AppWindowRegistry* const app_window_registry = extensions::AppWindowRegistry::Get(profile_); DCHECK(app_window_registry); - if (app_window_registry->GetCurrentAppWindowForApp(kArcSupportExtensionId)) + if (app_window_registry->GetCurrentAppWindowForApp( + ArcSupportHost::kHostAppId)) { return; + } const extensions::Extension* extension = extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( - kArcSupportExtensionId); - CHECK(extension && - extensions::util::IsAppLaunchable(kArcSupportExtensionId, profile_)); + ArcSupportHost::kHostAppId); + CHECK(extension && extensions::util::IsAppLaunchable( + ArcSupportHost::kHostAppId, profile_)); OpenApplication(CreateAppLaunchParamsUserContainer( profile_, extension, NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); @@ -523,13 +541,21 @@ DisableArc(); } +bool ArcAuthService::IsArcEnabled() { + DCHECK(thread_checker.Get().CalledOnValidThread()); + DCHECK(profile_); + return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); +} + void ArcAuthService::EnableArc() { DCHECK(thread_checker.Get().CalledOnValidThread()); + DCHECK(profile_); profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); } void ArcAuthService::DisableArc() { DCHECK(thread_checker.Get().CalledOnValidThread()); + DCHECK(profile_); profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); }
diff --git a/chrome/browser/chromeos/arc/arc_auth_service.h b/chrome/browser/chromeos/arc/arc_auth_service.h index 3691ac3..354f12f 100644 --- a/chrome/browser/chromeos/arc/arc_auth_service.h +++ b/chrome/browser/chromeos/arc/arc_auth_service.h
@@ -98,6 +98,12 @@ static void EnableCheckAndroidManagementForTesting(); + // Returns true if Arc is allowed to run for the given profile. + static bool IsAllowedForProfile(const Profile* profile); + + // Returns true if Arc is allowed to run for the current session. + bool IsAllowed() const; + void OnPrimaryUserProfilePrepared(Profile* profile); void Shutdown(); @@ -134,6 +140,7 @@ // Called from Arc support platform app when user cancels signing. void CancelAuthCode(); + bool IsArcEnabled(); void EnableArc(); void DisableArc();
diff --git a/chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc b/chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc index 4e712f76..094c8df6 100644 --- a/chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc +++ b/chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc
@@ -25,6 +25,7 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/testing_profile.h" +#include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/session_manager_client.h" @@ -129,6 +130,7 @@ url); // Enable ARC. + command_line->AppendSwitch(chromeos::switches::kEnableArc); chromeos::FakeSessionManagerClient* const fake_session_manager_client = new chromeos::FakeSessionManagerClient; fake_session_manager_client->set_arc_available(true);
diff --git a/chrome/browser/chromeos/arc/arc_auth_service_unittest.cc b/chrome/browser/chromeos/arc/arc_auth_service_unittest.cc index ba66555a..3089338 100644 --- a/chrome/browser/chromeos/arc/arc_auth_service_unittest.cc +++ b/chrome/browser/chromeos/arc/arc_auth_service_unittest.cc
@@ -7,6 +7,7 @@ #include <vector> #include "base/bind.h" +#include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" @@ -21,6 +22,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" +#include "chromeos/chromeos_switches.h" #include "chromeos/login/user_names.h" #include "components/arc/arc_bridge_service.h" #include "components/arc/test/fake_arc_bridge_service.h" @@ -54,6 +56,8 @@ ~ArcAuthServiceTest() override = default; void SetUp() override { + base::CommandLine::ForCurrentProcess()->AppendSwitch( + chromeos::switches::kEnableArc); ArcAuthService::DisableUIForTesting(); EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
diff --git a/chrome/browser/chromeos/arc/arc_support_host.cc b/chrome/browser/chromeos/arc/arc_support_host.cc index c706567..ea22008 100644 --- a/chrome/browser/chromeos/arc/arc_support_host.cc +++ b/chrome/browser/chromeos/arc/arc_support_host.cc
@@ -32,6 +32,12 @@ const char ArcSupportHost::kHostName[] = "com.google.arc_support"; // static +const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; + +// static +const char ArcSupportHost::kStorageId[] = "arc_support"; + +// static const char* const ArcSupportHost::kHostOrigin[] = { "chrome-extension://cnbgggchhmkkdmeppjobngjoejnihlei/"};
diff --git a/chrome/browser/chromeos/arc/arc_support_host.h b/chrome/browser/chromeos/arc/arc_support_host.h index 23df4b8f..082aeee2 100644 --- a/chrome/browser/chromeos/arc/arc_support_host.h +++ b/chrome/browser/chromeos/arc/arc_support_host.h
@@ -14,6 +14,8 @@ public arc::ArcAuthService::Observer { public: static const char kHostName[]; + static const char kHostAppId[]; + static const char kStorageId[]; static const char* const kHostOrigin[]; static std::unique_ptr<NativeMessageHost> Create();
diff --git a/chrome/browser/chromeos/policy/remote_commands/screenshot_delegate.cc b/chrome/browser/chromeos/policy/remote_commands/screenshot_delegate.cc index 0c9784cd..a774921 100644 --- a/chrome/browser/chromeos/policy/remote_commands/screenshot_delegate.cc +++ b/chrome/browser/chromeos/policy/remote_commands/screenshot_delegate.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/chromeos/policy/remote_commands/screenshot_delegate.h" #include "base/memory/ptr_util.h" +#include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" @@ -59,7 +60,8 @@ return std::unique_ptr<UploadJob>(new UploadJobImpl( upload_url, robot_account_id, device_oauth2_token_service, system_request_context, delegate, - base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator))); + base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator), + base::ThreadTaskRunnerHandle::Get())); } void ScreenshotDelegate::StoreScreenshot(
diff --git a/chrome/browser/chromeos/policy/system_log_uploader.cc b/chrome/browser/chromeos/policy/system_log_uploader.cc index 58e83b5..4f0b68d2 100644 --- a/chrome/browser/chromeos/policy/system_log_uploader.cc +++ b/chrome/browser/chromeos/policy/system_log_uploader.cc
@@ -64,7 +64,8 @@ // create an upload job and load system logs from the disk. class SystemLogDelegate : public policy::SystemLogUploader::Delegate { public: - SystemLogDelegate(); + explicit SystemLogDelegate( + scoped_refptr<base::SequencedTaskRunner> task_runner); ~SystemLogDelegate() override; // SystemLogUploader::Delegate: @@ -75,10 +76,15 @@ policy::UploadJob::Delegate* delegate) override; private: + // TaskRunner used for scheduling upload the upload task. + const scoped_refptr<base::SequencedTaskRunner> task_runner_; + DISALLOW_COPY_AND_ASSIGN(SystemLogDelegate); }; -SystemLogDelegate::SystemLogDelegate() {} +SystemLogDelegate::SystemLogDelegate( + scoped_refptr<base::SequencedTaskRunner> task_runner) + : task_runner_(task_runner) {} SystemLogDelegate::~SystemLogDelegate() {} @@ -104,8 +110,8 @@ return std::unique_ptr<policy::UploadJob>(new policy::UploadJobImpl( upload_url, robot_account_id, device_oauth2_token_service, system_request_context, delegate, - base::WrapUnique( - new policy::UploadJobImpl::RandomMimeBoundaryGenerator))); + base::WrapUnique(new policy::UploadJobImpl::RandomMimeBoundaryGenerator), + task_runner_)); } // Returns the system log upload frequency. @@ -165,7 +171,7 @@ upload_enabled_(false), weak_factory_(this) { if (!syslog_delegate_) - syslog_delegate_.reset(new SystemLogDelegate()); + syslog_delegate_.reset(new SystemLogDelegate(task_runner)); DCHECK(syslog_delegate_); // Watch for policy changes.
diff --git a/chrome/browser/chromeos/policy/upload_job_impl.cc b/chrome/browser/chromeos/policy/upload_job_impl.cc index d557c28..c8a02e7 100644 --- a/chrome/browser/chromeos/policy/upload_job_impl.cc +++ b/chrome/browser/chromeos/policy/upload_job_impl.cc
@@ -8,6 +8,7 @@ #include <set> #include <utility> +#include "base/location.h" #include "base/logging.h" #include "base/macros.h" #include "base/strings/stringprintf.h" @@ -28,12 +29,15 @@ // Value the "Content-Type" field will be set to in the POST request. const char kUploadContentType[] = "multipart/form-data"; -// Number of upload retries. -const int kMaxRetries = 1; +// Number of upload attempts. +const int kMaxAttempts = 4; // Max size of MIME boundary according to RFC 1341, section 7.2.1. const size_t kMaxMimeBoundarySize = 70; +// Delay after each unsuccessful upload attempt. +long g_retry_delay_ms = 25000; + } // namespace UploadJobImpl::Delegate::~Delegate() { @@ -127,7 +131,8 @@ OAuth2TokenService* token_service, scoped_refptr<net::URLRequestContextGetter> url_context_getter, Delegate* delegate, - std::unique_ptr<MimeBoundaryGenerator> boundary_generator) + std::unique_ptr<MimeBoundaryGenerator> boundary_generator, + scoped_refptr<base::SequencedTaskRunner> task_runner) : OAuth2TokenService::Consumer("cros_upload_job"), upload_url_(upload_url), account_id_(account_id), @@ -136,7 +141,9 @@ delegate_(delegate), boundary_generator_(std::move(boundary_generator)), state_(IDLE), - retry_(0) { + retry_(0), + task_runner_(task_runner), + weak_factory_(this) { DCHECK(token_service_); DCHECK(url_context_getter_); DCHECK(delegate_); @@ -154,6 +161,7 @@ const std::string& filename, const std::map<std::string, std::string>& header_entries, std::unique_ptr<std::string> data) { + DCHECK(thread_checker_.CalledOnValidThread()); // Cannot add data to busy or failed instance. DCHECK_EQ(IDLE, state_); if (state_ != IDLE) @@ -165,14 +173,26 @@ } void UploadJobImpl::Start() { + DCHECK(thread_checker_.CalledOnValidThread()); // Cannot start an upload on a busy or failed instance. DCHECK_EQ(IDLE, state_); if (state_ != IDLE) return; + DCHECK_EQ(0, retry_); + RequestAccessToken(); } +// static +void UploadJobImpl::SetRetryDelayForTesting(long retry_delay_ms) { + CHECK_GE(retry_delay_ms, 0); + g_retry_delay_ms = retry_delay_ms; +} + void UploadJobImpl::RequestAccessToken() { + DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK(!access_token_request_); + state_ = ACQUIRING_TOKEN; OAuth2TokenService::ScopeSet scope_set; @@ -264,13 +284,15 @@ upload_fetcher_->Start(); } -void UploadJobImpl::StartUpload(const std::string& access_token) { +void UploadJobImpl::StartUpload() { + DCHECK(thread_checker_.CalledOnValidThread()); + if (!SetUpMultipart()) { LOG(ERROR) << "Multipart message assembly failed."; state_ = ERROR; return; } - CreateAndStartURLFetcher(access_token); + CreateAndStartURLFetcher(access_token_); state_ = UPLOADING; } @@ -284,7 +306,7 @@ // Also cache the token locally, so that we can revoke it later if necessary. access_token_ = access_token; - StartUpload(access_token); + StartUpload(); } void UploadJobImpl::OnGetTokenFailure( @@ -294,57 +316,71 @@ DCHECK_EQ(access_token_request_.get(), request); access_token_request_.reset(); LOG(ERROR) << "Token request failed: " << error.ToString(); - state_ = ERROR; - delegate_->OnFailure(AUTHENTICATION_ERROR); + HandleError(AUTHENTICATION_ERROR); +} + +void UploadJobImpl::HandleError(ErrorCode error_code) { + retry_++; + upload_fetcher_.reset(); + + LOG(ERROR) << "Upload failed, error code: " << error_code; + + if (retry_ >= kMaxAttempts) { + // Maximum number of attempts reached, failure. + LOG(ERROR) << "Maximum number of attempts reached."; + access_token_.clear(); + post_data_.reset(); + state_ = ERROR; + delegate_->OnFailure(error_code); + } else { + if (error_code == AUTHENTICATION_ERROR) { + LOG(ERROR) << "Retrying upload with a new token."; + // Request new token and retry. + OAuth2TokenService::ScopeSet scope_set; + scope_set.insert(GaiaConstants::kDeviceManagementServiceOAuth); + token_service_->InvalidateAccessToken(account_id_, scope_set, + access_token_); + access_token_.clear(); + task_runner_->PostDelayedTask( + FROM_HERE, base::Bind(&UploadJobImpl::RequestAccessToken, + weak_factory_.GetWeakPtr()), + base::TimeDelta::FromMilliseconds(g_retry_delay_ms)); + } else { + // Retry without a new token. + state_ = ACQUIRING_TOKEN; + LOG(WARNING) << "Retrying upload with the same token."; + task_runner_->PostDelayedTask( + FROM_HERE, + base::Bind(&UploadJobImpl::StartUpload, weak_factory_.GetWeakPtr()), + base::TimeDelta::FromMilliseconds(g_retry_delay_ms)); + } + } } void UploadJobImpl::OnURLFetchComplete(const net::URLFetcher* source) { DCHECK_EQ(upload_fetcher_.get(), source); + DCHECK_EQ(UPLOADING, state_); const net::URLRequestStatus& status = source->GetStatus(); if (!status.is_success()) { LOG(ERROR) << "URLRequestStatus error " << status.error(); - upload_fetcher_.reset(); - state_ = ERROR; - post_data_.reset(); - delegate_->OnFailure(NETWORK_ERROR); - return; - } - - const int response_code = source->GetResponseCode(); - const bool success = response_code == net::HTTP_OK; - if (!success) - LOG(ERROR) << "POST request failed with HTTP status code " << response_code; - - if (response_code == net::HTTP_UNAUTHORIZED) { - if (retry_ >= kMaxRetries) { - upload_fetcher_.reset(); - LOG(ERROR) << "Unauthorized request."; - state_ = ERROR; - post_data_.reset(); - delegate_->OnFailure(AUTHENTICATION_ERROR); - return; - } - retry_++; - upload_fetcher_.reset(); - OAuth2TokenService::ScopeSet scope_set; - scope_set.insert(GaiaConstants::kDeviceManagementServiceOAuth); - token_service_->InvalidateAccessToken(account_id_, scope_set, - access_token_); - access_token_.clear(); - RequestAccessToken(); - return; - } - - upload_fetcher_.reset(); - access_token_.clear(); - upload_fetcher_.reset(); - post_data_.reset(); - if (success) { - state_ = SUCCESS; - delegate_->OnSuccess(); + HandleError(NETWORK_ERROR); } else { - state_ = ERROR; - delegate_->OnFailure(SERVER_ERROR); + const int response_code = source->GetResponseCode(); + if (response_code == net::HTTP_OK) { + // Successful upload + upload_fetcher_.reset(); + access_token_.clear(); + post_data_.reset(); + state_ = SUCCESS; + delegate_->OnSuccess(); + } else if (response_code == net::HTTP_UNAUTHORIZED) { + LOG(ERROR) << "Unauthorized request."; + HandleError(AUTHENTICATION_ERROR); + } else { + LOG(ERROR) << "POST request failed with HTTP status code " + << response_code << "."; + HandleError(SERVER_ERROR); + } } }
diff --git a/chrome/browser/chromeos/policy/upload_job_impl.h b/chrome/browser/chromeos/policy/upload_job_impl.h index 96d7df1..4c500b63 100644 --- a/chrome/browser/chromeos/policy/upload_job_impl.h +++ b/chrome/browser/chromeos/policy/upload_job_impl.h
@@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_vector.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/policy/upload_job.h" #include "google_apis/gaia/oauth2_token_service.h" #include "net/url_request/url_fetcher.h" @@ -49,12 +50,15 @@ std::string GenerateBoundary() const override; // MimeBoundaryGenerator }; + // |task_runner| must belong to the same thread from which the constructor and + // all the public methods are called. UploadJobImpl(const GURL& upload_url, const std::string& account_id, OAuth2TokenService* token_service, scoped_refptr<net::URLRequestContextGetter> url_context_getter, Delegate* delegate, - std::unique_ptr<MimeBoundaryGenerator> boundary_generator); + std::unique_ptr<MimeBoundaryGenerator> boundary_generator, + const scoped_refptr<base::SequencedTaskRunner> task_runner); ~UploadJobImpl() override; // UploadJob: @@ -64,8 +68,20 @@ std::unique_ptr<std::string> data) override; void Start() override; + // Sets the retry delay to a shorter time to prevent browser tests from + // timing out. + static void SetRetryDelayForTesting(long retryDelayMs); + private: // Indicates the current state of the UploadJobImpl. + // State transitions for successful upload: + // IDLE -> ACQUIRING_TOKEN -> PREPARING_CONTENT -> UPLOADING -> SUCCESS + // If error happens, state goes back to ACQUIRING_TOKEN. + // State transitions when error occurs once: + // IDLE -> ACQUIRING_TOKEN -> PREPARING_CONTENT -> UPLOADING -> + // -> ACQUIRING_TOKEN -> PREPARING_CONTENT -> UPLOADING -> SUCCESS + // State transitions when tried unsuccessfully kMaxRetries times: + // ... -> PREPARING_CONTENT -> UPLOADING -> ERROR enum State { IDLE, // Start() has not been called. ACQUIRING_TOKEN, // Trying to acquire the access token. @@ -85,11 +101,13 @@ // net::URLFetcherDelegate: void OnURLFetchComplete(const net::URLFetcher* source) override; + void HandleError(ErrorCode errorCode); + // Requests an access token for the upload scope. void RequestAccessToken(); // Dispatches POST request to URLFetcher. - void StartUpload(const std::string& access_token); + void StartUpload(); // Constructs the body of the POST request by concatenating the // |data_segments_|, separated by appropriate content-disposition headers and @@ -147,6 +165,15 @@ // The data chunks to be uploaded. ScopedVector<DataSegment> data_segments_; + // TaskRunner used for scheduling retry attempts. + const scoped_refptr<base::SequencedTaskRunner> task_runner_; + + base::ThreadChecker thread_checker_; + + // Should remain the last member so it will be destroyed first and + // invalidate all weak pointers. + base::WeakPtrFactory<UploadJobImpl> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(UploadJobImpl); };
diff --git a/chrome/browser/chromeos/policy/upload_job_unittest.cc b/chrome/browser/chromeos/policy/upload_job_unittest.cc index 2408dc5..0ab76560 100644 --- a/chrome/browser/chromeos/policy/upload_job_unittest.cc +++ b/chrome/browser/chromeos/policy/upload_job_unittest.cc
@@ -16,7 +16,6 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/run_loop.h" -#include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "chrome/browser/chromeos/policy/upload_job_impl.h" @@ -184,6 +183,8 @@ base::ThreadTaskRunnerHandle::Get()); oauth2_service_.AddAccount("robot@gmail.com"); ASSERT_TRUE(test_server_.Start()); + // Set retry delay to prevent timeouts + policy::UploadJobImpl::SetRetryDelayForTesting(0); } // testing::Test: @@ -195,10 +196,10 @@ std::unique_ptr<UploadJob> PrepareUploadJob( std::unique_ptr<UploadJobImpl::MimeBoundaryGenerator> mime_boundary_generator) { - std::unique_ptr<UploadJob> upload_job( - new UploadJobImpl(GetServerURL(), kRobotAccountId, &oauth2_service_, - request_context_getter_.get(), this, - std::move(mime_boundary_generator))); + std::unique_ptr<UploadJob> upload_job(new UploadJobImpl( + GetServerURL(), kRobotAccountId, &oauth2_service_, + request_context_getter_.get(), this, std::move(mime_boundary_generator), + base::ThreadTaskRunnerHandle::Get())); std::map<std::string, std::string> header_entries; header_entries.insert(std::make_pair(kCustomField1, "CUSTOM1")); @@ -230,10 +231,18 @@ UploadJobTestBase::SetUp(); test_server_.RegisterRequestHandler( base::Bind(&UploadFlowTest::HandlePostRequest, base::Unretained(this))); + upload_attempt_count_ = 0; + } + + // Sets the response code which will be returned when no other problems occur. + // Default is |net::HTTP_OK| + void SetResponseDefaultStatusCode(net::HttpStatusCode code) { + default_status_code_ = code; } std::unique_ptr<net::test_server::HttpResponse> HandlePostRequest( const net::test_server::HttpRequest& request) { + upload_attempt_count_++; EXPECT_TRUE(request.headers.find("Authorization") != request.headers.end()); const std::string authorization_header = request.headers.at("Authorization"); @@ -247,10 +256,14 @@ const std::string token = authorization_header.substr(pos + 1); response->set_code(oauth2_service_.IsTokenValid(token) - ? net::HTTP_OK + ? default_status_code_ : net::HTTP_UNAUTHORIZED); return std::move(response); } + + protected: + int upload_attempt_count_; + net::HttpStatusCode default_status_code_ = net::HTTP_OK; }; TEST_F(UploadFlowTest, SuccessfulUpload) { @@ -260,6 +273,7 @@ base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator)); upload_job->Start(); run_loop_.Run(); + ASSERT_EQ(1, upload_attempt_count_); } TEST_F(UploadFlowTest, TokenExpired) { @@ -270,11 +284,14 @@ base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator)); upload_job->Start(); run_loop_.Run(); + ASSERT_EQ(2, upload_attempt_count_); } TEST_F(UploadFlowTest, TokenInvalid) { oauth2_service_.AddTokenToQueue(kTokenInvalid); oauth2_service_.AddTokenToQueue(kTokenInvalid); + oauth2_service_.AddTokenToQueue(kTokenInvalid); + oauth2_service_.AddTokenToQueue(kTokenInvalid); SetExpectedError(std::unique_ptr<UploadJob::ErrorCode>( new UploadJob::ErrorCode(UploadJob::AUTHENTICATION_ERROR))); @@ -282,6 +299,20 @@ base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator)); upload_job->Start(); run_loop_.Run(); + ASSERT_EQ(4, upload_attempt_count_); +} + +TEST_F(UploadFlowTest, TokenMultipleTries) { + oauth2_service_.SetTokenValid(kTokenValid); + oauth2_service_.AddTokenToQueue(kTokenInvalid); + oauth2_service_.AddTokenToQueue(kTokenInvalid); + oauth2_service_.AddTokenToQueue(kTokenValid); + + std::unique_ptr<UploadJob> upload_job = PrepareUploadJob( + base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator)); + upload_job->Start(); + run_loop_.Run(); + ASSERT_EQ(3, upload_attempt_count_); } TEST_F(UploadFlowTest, TokenFetchFailure) { @@ -292,6 +323,24 @@ base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator)); upload_job->Start(); run_loop_.Run(); + // Without a token we don't try to upload + ASSERT_EQ(0, upload_attempt_count_); +} + +TEST_F(UploadFlowTest, InternalServerError) { + SetResponseDefaultStatusCode(net::HTTP_INTERNAL_SERVER_ERROR); + oauth2_service_.SetTokenValid(kTokenValid); + oauth2_service_.AddTokenToQueue(kTokenValid); + + SetExpectedError(std::unique_ptr<UploadJob::ErrorCode>( + new UploadJob::ErrorCode(UploadJob::SERVER_ERROR))); + + std::unique_ptr<UploadJob> upload_job = PrepareUploadJob( + base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator)); + upload_job->Start(); + run_loop_.Run(); + // kMaxAttempts + ASSERT_EQ(4, upload_attempt_count_); } class UploadRequestTest : public UploadJobTestBase {
diff --git a/chrome/browser/component_updater/component_patcher_operation_out_of_process.cc b/chrome/browser/component_updater/component_patcher_operation_out_of_process.cc index e134166a..ba3de60 100644 --- a/chrome/browser/component_updater/component_patcher_operation_out_of_process.cc +++ b/chrome/browser/component_updater/component_patcher_operation_out_of_process.cc
@@ -19,7 +19,7 @@ #include "content/public/browser/utility_process_host.h" #include "content/public/browser/utility_process_host_client.h" #include "courgette/courgette.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include "ipc/ipc_message_macros.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc index 2e0445bd..1d1349c 100644 --- a/chrome/browser/content_settings/content_settings_browsertest.cc +++ b/chrome/browser/content_settings/content_settings_browsertest.cc
@@ -43,10 +43,6 @@ #include "base/mac/scoped_nsautorelease_pool.h" #endif -#if defined(ENABLE_PEPPER_CDMS) -#include "chrome/browser/media/pepper_cdm_test_helper.h" -#endif - using content::BrowserThread; using net::URLRequestMockHTTPJob; @@ -321,17 +317,32 @@ #if defined(ENABLE_PLUGINS) class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest { protected: + static const char kExternalClearKeyMimeType[]; + // Registers any CDM plugins not registered by default. void SetUpCommandLine(base::CommandLine* command_line) override { #if defined(ENABLE_PEPPER_CDMS) + // Platform-specific filename relative to the chrome executable. +#if defined(OS_WIN) + const char kLibraryName[] = "clearkeycdmadapter.dll"; +#else // !defined(OS_WIN) +#if defined(OS_MACOSX) + const char kLibraryName[] = "clearkeycdmadapter.plugin"; +#elif defined(OS_POSIX) + const char kLibraryName[] = "libclearkeycdmadapter.so"; +#endif // defined(OS_MACOSX) +#endif // defined(OS_WIN) + // Append the switch to register the External Clear Key CDM. - base::FilePath::StringType pepper_plugins = BuildPepperCdmRegistration( - kClearKeyCdmAdapterFileName, kClearKeyCdmPepperMimeType); + base::FilePath::StringType pepper_plugins = BuildPepperPluginRegistration( + kLibraryName, "Clear Key CDM", kExternalClearKeyMimeType); #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) // The CDM must be registered when it is a component. pepper_plugins.append(FILE_PATH_LITERAL(",")); - pepper_plugins.append(BuildPepperCdmRegistration( - kWidevineCdmAdapterFileName, kWidevineCdmPluginMimeType)); + pepper_plugins.append( + BuildPepperPluginRegistration(kWidevineCdmAdapterFileName, + kWidevineCdmDisplayName, + kWidevineCdmPluginMimeType)); #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, pepper_plugins); @@ -417,8 +428,41 @@ tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT)); EXPECT_FALSE(tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS)); } + + private: + // Builds the string to pass to kRegisterPepperPlugins for a single + // plugin using the provided parameters and a dummy version. + // Multiple results may be passed to kRegisterPepperPlugins, separated by ",". + base::FilePath::StringType BuildPepperPluginRegistration( + const char* library_name, + const char* display_name, + const char* mime_type) { + base::FilePath plugin_dir; + EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); + + base::FilePath plugin_lib = plugin_dir.AppendASCII(library_name); + EXPECT_TRUE(base::PathExists(plugin_lib)); + + base::FilePath::StringType pepper_plugin = plugin_lib.value(); + std::string string_to_append = "#"; + string_to_append.append(display_name); + string_to_append.append("#A CDM#0.1.0.0;"); + string_to_append.append(mime_type); + +#if defined(OS_WIN) + pepper_plugin.append(base::ASCIIToUTF16(string_to_append)); +#else + pepper_plugin.append(string_to_append); +#endif + + return pepper_plugin; + } }; +const char +PepperContentSettingsSpecialCasesTest::kExternalClearKeyMimeType[] = + "application/x-ppapi-clearkey-cdm"; + class PepperContentSettingsSpecialCasesPluginsBlockedTest : public PepperContentSettingsSpecialCasesTest { public: @@ -452,7 +496,7 @@ ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); - RunLoadPepperPluginTest(kClearKeyCdmPepperMimeType, true); + RunLoadPepperPluginTest(kExternalClearKeyMimeType, true); } #endif // defined(ENABLE_PEPPER_CDMS) @@ -463,7 +507,7 @@ // The plugin successfully loaded above is blocked. IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, Normal) { - RunLoadPepperPluginTest(kClearKeyCdmPepperMimeType, false); + RunLoadPepperPluginTest(kExternalClearKeyMimeType, false); } #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(OS_CHROMEOS)
diff --git a/chrome/browser/media/encrypted_media_browsertest.cc b/chrome/browser/media/encrypted_media_browsertest.cc index 4704227..ffcf367 100644 --- a/chrome/browser/media/encrypted_media_browsertest.cc +++ b/chrome/browser/media/encrypted_media_browsertest.cc
@@ -23,11 +23,21 @@ #include "base/android/build_info.h" #endif +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + #if defined(ENABLE_PEPPER_CDMS) -#include "chrome/browser/media/pepper_cdm_test_helper.h" +// Platform-specific filename relative to the chrome executable. +const char kClearKeyCdmAdapterFileName[] = +#if defined(OS_MACOSX) + "clearkeycdmadapter.plugin"; +#elif defined(OS_WIN) + "clearkeycdmadapter.dll"; +#elif defined(OS_POSIX) + "libclearkeycdmadapter.so"; #endif -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. +const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; +#endif // defined(ENABLE_PEPPER_CDMS) // Available key systems. const char kClearKeyKeySystem[] = "org.w3.clearkey"; @@ -98,7 +108,7 @@ // Base class for encrypted media tests. class EncryptedMediaTestBase : public MediaBrowserTest { public: - EncryptedMediaTestBase() {} + EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} bool IsExternalClearKey(const std::string& key_system) { if (key_system == kExternalClearKeyKeySystem) @@ -251,13 +261,11 @@ #if defined(ENABLE_PEPPER_CDMS) if (IsExternalClearKey(key_system)) { - RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, - GetPepperType(key_system)); + RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system); } #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) else if (IsWidevine(key_system)) { // NOLINT - RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, - GetPepperType(key_system)); + RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system); } #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) #endif // defined(ENABLE_PEPPER_CDMS) @@ -265,10 +273,33 @@ private: #if defined(ENABLE_PEPPER_CDMS) + void RegisterPepperCdm(base::CommandLine* command_line, + const std::string& adapter_name, + const std::string& key_system) { + DCHECK(!is_pepper_cdm_registered_) + << "RegisterPepperCdm() can only be called once."; + is_pepper_cdm_registered_ = true; + + // Append the switch to register the Clear Key CDM Adapter. + base::FilePath plugin_dir; + EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); + base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); + EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); + base::FilePath::StringType pepper_plugin = plugin_lib.value(); + pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); +#if defined(OS_WIN) + pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); +#else + pepper_plugin.append(GetPepperType(key_system)); +#endif + command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, + pepper_plugin); + } + // Adapted from key_systems.cc. std::string GetPepperType(const std::string& key_system) { if (IsExternalClearKey(key_system)) - return kClearKeyCdmPepperMimeType; + return kClearKeyCdmPluginMimeType; #if defined(WIDEVINE_CDM_AVAILABLE) if (IsWidevine(key_system)) return kWidevineCdmPluginMimeType; @@ -278,6 +309,8 @@ return ""; } #endif // defined(ENABLE_PEPPER_CDMS) + + bool is_pepper_cdm_registered_; }; #if defined(ENABLE_PEPPER_CDMS)
diff --git a/chrome/browser/media/encrypted_media_supported_types_browsertest.cc b/chrome/browser/media/encrypted_media_supported_types_browsertest.cc index 974c341d..d59b992c 100644 --- a/chrome/browser/media/encrypted_media_supported_types_browsertest.cc +++ b/chrome/browser/media/encrypted_media_supported_types_browsertest.cc
@@ -27,16 +27,12 @@ #include "net/test/embedded_test_server/embedded_test_server.h" #include "url/gurl.h" -#if defined(ENABLE_PEPPER_CDMS) -#include "chrome/browser/media/pepper_cdm_test_helper.h" -#endif +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. #if defined(OS_ANDROID) #error This file needs to be updated to run on Android. #endif -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - namespace chrome { namespace { @@ -87,8 +83,8 @@ // Expectations for Widevine. // Note: Widevine is not available on platforms using components because // RegisterPepperCdm() cannot set the codecs. -// TODO(xhwang): Enable these tests after we have the ability to use the -// manifest in these tests. See http://crbug.com/586634 +// TODO(ddorwin): Enable these tests after we have the ability to use the CUS +// in these tests. See http://crbug.com/356833. #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT) #define EXPECT_WV_SUCCESS EXPECT_SUCCESS #define EXPECT_WV_PROPRIETARY EXPECT_PROPRIETARY @@ -104,7 +100,7 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest { protected: - EncryptedMediaSupportedTypesTest() { + EncryptedMediaSupportedTypesTest() : is_pepper_cdm_registered_(false) { audio_webm_codecs_.push_back("opus"); audio_webm_codecs_.push_back("vorbis"); @@ -151,6 +147,32 @@ } const CodecVector& invalid_codecs() const { return invalid_codecs_; } + // Update the command line to load |adapter_name| for + // |pepper_type_for_key_system|. + void RegisterPepperCdm(base::CommandLine* command_line, + const std::string& adapter_name, + const std::string& pepper_type_for_key_system, + bool expect_adapter_exists = true) { + DCHECK(!is_pepper_cdm_registered_) + << "RegisterPepperCdm() can only be called once."; + is_pepper_cdm_registered_ = true; + + // Append the switch to register the appropriate adapter. + base::FilePath plugin_dir; + EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); + base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); + EXPECT_EQ(expect_adapter_exists, base::PathExists(plugin_lib)); + base::FilePath::StringType pepper_plugin = plugin_lib.value(); + pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); +#if defined(OS_WIN) + pepper_plugin.append(base::ASCIIToUTF16(pepper_type_for_key_system)); +#else + pepper_plugin.append(pepper_type_for_key_system); +#endif + command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, + pepper_plugin); + } + void SetUpOnMainThread() override { InProcessBrowserTest::SetUpOnMainThread(); @@ -244,6 +266,8 @@ CodecVector video_mp4_codecs_; CodecVector video_mp4_hi10p_codecs_; CodecVector invalid_codecs_; + + bool is_pepper_cdm_registered_; }; // For ClearKey, nothing additional is required. @@ -258,8 +282,19 @@ protected: void SetUpCommandLine(base::CommandLine* command_line) override { EncryptedMediaSupportedTypesTest::SetUpCommandLine(command_line); - RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, - kClearKeyCdmPepperMimeType); + + // Platform-specific filename relative to the chrome executable. + const char adapter_file_name[] = +#if defined(OS_MACOSX) + "clearkeycdmadapter.plugin"; +#elif defined(OS_WIN) + "clearkeycdmadapter.dll"; +#elif defined(OS_POSIX) + "libclearkeycdmadapter.so"; +#endif + + const std::string pepper_name("application/x-ppapi-clearkey-cdm"); + RegisterPepperCdm(command_line, adapter_file_name, pepper_name); } #endif // defined(ENABLE_PEPPER_CDMS) }; @@ -278,8 +313,10 @@ protected: void SetUpCommandLine(base::CommandLine* command_line) override { EncryptedMediaSupportedTypesTest::SetUpCommandLine(command_line); - RegisterPepperCdm(command_line, "clearkeycdmadapterwrongname.dll", - kClearKeyCdmPepperMimeType, false); + RegisterPepperCdm(command_line, + "clearkeycdmadapterwrongname.dll", + "application/x-ppapi-clearkey-cdm", + false); } }; @@ -289,8 +326,10 @@ protected: void SetUpCommandLine(base::CommandLine* command_line) override { EncryptedMediaSupportedTypesTest::SetUpCommandLine(command_line); - RegisterPepperCdm(command_line, "widevinecdmadapterwrongname.dll", - "application/x-ppapi-widevine-cdm", false); + RegisterPepperCdm(command_line, + "widevinecdmadapterwrongname.dll", + "application/x-ppapi-widevine-cdm", + false); } }; #endif // defined(ENABLE_PEPPER_CDMS)
diff --git a/chrome/browser/media/pepper_cdm_test_helper.cc b/chrome/browser/media/pepper_cdm_test_helper.cc deleted file mode 100644 index 0fd101c..0000000 --- a/chrome/browser/media/pepper_cdm_test_helper.cc +++ /dev/null
@@ -1,58 +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 "chrome/browser/media/pepper_cdm_test_helper.h" - -#include "base/command_line.h" -#include "base/files/file_util.h" -#include "base/path_service.h" -#include "base/strings/utf_string_conversions.h" -#include "content/public/common/content_switches.h" - -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - -const char kClearKeyCdmAdapterFileName[] = -#if defined(OS_MACOSX) - "clearkeycdmadapter.plugin"; -#elif defined(OS_WIN) - "clearkeycdmadapter.dll"; -#elif defined(OS_POSIX) - "libclearkeycdmadapter.so"; -#endif - -const char kClearKeyCdmPepperMimeType[] = "application/x-ppapi-clearkey-cdm"; - -base::FilePath::StringType BuildPepperCdmRegistration( - const std::string& adapter_file_name, - const std::string& mime_type, - bool expect_adapter_exists) { - base::FilePath adapter_path; - PathService::Get(base::DIR_MODULE, &adapter_path); - adapter_path = adapter_path.AppendASCII(adapter_file_name); - DCHECK_EQ(expect_adapter_exists, base::PathExists(adapter_path)); - - base::FilePath::StringType pepper_cdm_registration = adapter_path.value(); - pepper_cdm_registration.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); - -#if defined(OS_WIN) - pepper_cdm_registration.append(base::ASCIIToUTF16(mime_type)); -#else - pepper_cdm_registration.append(mime_type); -#endif - - return pepper_cdm_registration; -} - -void RegisterPepperCdm(base::CommandLine* command_line, - const std::string& adapter_file_name, - const std::string& mime_type, - bool expect_adapter_exists) { - base::FilePath::StringType pepper_cdm_registration = - BuildPepperCdmRegistration(adapter_file_name, mime_type, - expect_adapter_exists); - - // Append the switch to register the CDM Adapter. - command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, - pepper_cdm_registration); -}
diff --git a/chrome/browser/media/pepper_cdm_test_helper.h b/chrome/browser/media/pepper_cdm_test_helper.h deleted file mode 100644 index cfff76f..0000000 --- a/chrome/browser/media/pepper_cdm_test_helper.h +++ /dev/null
@@ -1,37 +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 CHROME_BROWSER_MEDIA_PEPPER_CDM_TEST_HELPER_H_ -#define CHROME_BROWSER_MEDIA_PEPPER_CDM_TEST_HELPER_H_ - -#include <string> - -#include "base/files/file_path.h" - -namespace base { -class CommandLine; -} - -// Platform-specific filename relative to kClearKeyCdmBaseDirectory. -extern const char kClearKeyCdmAdapterFileName[]; - -// Pepper type for Clear Key CDM. -extern const char kClearKeyCdmPepperMimeType[]; - -// Builds the string to pass to kRegisterPepperPlugins for a single -// CDM using the provided parameters and a dummy version. -// Multiple results may be passed to kRegisterPepperPlugins, separated by ",". -// The CDM adapter should be located in DIR_MODULE. -base::FilePath::StringType BuildPepperCdmRegistration( - const std::string& adapter_file_name, - const std::string& mime_type, - bool expect_adapter_exists = true); - -// Registers pepper CDM in |command_line|. -void RegisterPepperCdm(base::CommandLine* command_line, - const std::string& adapter_file_name, - const std::string& mime_type, - bool expect_adapter_exists = true); - -#endif // CHROME_BROWSER_MEDIA_PEPPER_CDM_TEST_HELPER_H_
diff --git a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc index d0caa3f6..70ffc9b 100644 --- a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc +++ b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc
@@ -113,6 +113,34 @@ #endif } +bool ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed( + content::BrowserContext* browser_context, + const GURL& url) { +#if defined(ENABLE_EXTENSIONS) + Profile* profile = Profile::FromBrowserContext(browser_context); + if (!profile) + return false; + + const extensions::ExtensionSet* extension_set = + &extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); + if (!extension_set) + return false; + + // Access to the vpnProvider API is controlled by extension permissions. + if (url.is_valid() && url.SchemeIs(extensions::kExtensionScheme)) { + const extensions::Extension* extension = extension_set->GetByID(url.host()); + if (extension) { + if (extension->permissions_data()->HasAPIPermission( + extensions::APIPermission::kVpnProvider)) { + return true; + } + } + } +#endif + + return false; +} + bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs( content::BrowserContext* browser_context, const GURL& url,
diff --git a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.h b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.h index 815eafb..a567032 100644 --- a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.h +++ b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.h
@@ -32,6 +32,10 @@ const content::SocketPermissionRequest* params, const std::set<std::string>& allowed_socket_origin); + static bool IsPepperVpnProviderAPIAllowed( + content::BrowserContext* browser_context, + const GURL& url); + static bool IsPluginAllowedToCallRequestOSFileHandle( content::BrowserContext* browser_context, const GURL& url,
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index be1bb1c..8a392ac 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc
@@ -3823,6 +3823,10 @@ protected: void SetUpTest() { + // ArcAuthService functionality is available only when Arc is enabled. Use + // kEnableArc switch that activates it. + base::CommandLine::ForCurrentProcess()->AppendSwitch( + chromeos::switches::kEnableArc); arc::ArcAuthService::DisableUIForTesting(); browser()->profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
diff --git a/chrome/browser/resources/plugin_metadata/plugins_linux.json b/chrome/browser/resources/plugin_metadata/plugins_linux.json index e32a9730..62d3421 100644 --- a/chrome/browser/resources/plugin_metadata/plugins_linux.json +++ b/chrome/browser/resources/plugin_metadata/plugins_linux.json
@@ -1,5 +1,5 @@ { - "x-version": 13, + "x-version": 14, "google-talk": { "mime_types": [ ], @@ -80,9 +80,9 @@ ], "versions": [ { - "version": "21.0.0.213", + "version": "21.0.0.242", "status": "up_to_date", - "reference": "https://helpx.adobe.com/security/products/flash-player/apsb16-10.html" + "reference": "https://helpx.adobe.com/security/products/flash-player/apsb16-15.html" } ], "lang": "en-US",
diff --git a/chrome/browser/resources/plugin_metadata/plugins_mac.json b/chrome/browser/resources/plugin_metadata/plugins_mac.json index 0a286c06..eaee4e7c 100644 --- a/chrome/browser/resources/plugin_metadata/plugins_mac.json +++ b/chrome/browser/resources/plugin_metadata/plugins_mac.json
@@ -1,5 +1,5 @@ { - "x-version": 19, + "x-version": 20, "google-talk": { "mime_types": [ ], @@ -115,9 +115,9 @@ ], "versions": [ { - "version": "21.0.0.213", + "version": "21.0.0.242", "status": "requires_authorization", - "reference": "https://helpx.adobe.com/security/products/flash-player/apsb16-10.html" + "reference": "https://helpx.adobe.com/security/products/flash-player/apsb16-15.html" } ], "lang": "en-US",
diff --git a/chrome/browser/resources/plugin_metadata/plugins_win.json b/chrome/browser/resources/plugin_metadata/plugins_win.json index 3a26960..e5e91cd1 100644 --- a/chrome/browser/resources/plugin_metadata/plugins_win.json +++ b/chrome/browser/resources/plugin_metadata/plugins_win.json
@@ -1,5 +1,5 @@ { - "x-version": 28, + "x-version": 29, "google-talk": { "mime_types": [ ], @@ -137,9 +137,9 @@ ], "versions": [ { - "version": "21.0.0.213", + "version": "21.0.0.242", "status": "requires_authorization", - "reference": "https://helpx.adobe.com/security/products/flash-player/apsb16-10.html" + "reference": "https://helpx.adobe.com/security/products/flash-player/apsb16-15.html" } ], "lang": "en-US",
diff --git a/chrome/browser/ui/app_list/arc/arc_app_utils.cc b/chrome/browser/ui/app_list/arc/arc_app_utils.cc index 497c317..1143e47 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_utils.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_utils.cc
@@ -109,6 +109,8 @@ } // namespace +const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; + bool LaunchAppWithRect(content::BrowserContext* context, const std::string& app_id, const gfx::Rect& target_rect) {
diff --git a/chrome/browser/ui/app_list/arc/arc_app_utils.h b/chrome/browser/ui/app_list/arc/arc_app_utils.h index 1fecc41..666889b 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_utils.h +++ b/chrome/browser/ui/app_list/arc/arc_app_utils.h
@@ -16,6 +16,8 @@ namespace arc { +extern const char kPlayStoreAppId[]; + using CanHandleResolutionCallback = base::Callback<void(bool)>; // Launch an app and let the system decides how big and where to place it.
diff --git a/chrome/browser/ui/ash/chrome_launcher_prefs.cc b/chrome/browser/ui/ash/chrome_launcher_prefs.cc index a0ac9767..bca3ef1 100644 --- a/chrome/browser/ui/ash/chrome_launcher_prefs.cc +++ b/chrome/browser/ui/ash/chrome_launcher_prefs.cc
@@ -12,6 +12,8 @@ #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/app_mode/app_mode_utils.h" +#include "chrome/browser/chromeos/arc/arc_auth_service.h" +#include "chrome/browser/chromeos/arc/arc_support_host.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" #include "chrome/common/extensions/extension_constants.h" @@ -368,6 +370,11 @@ } } + if (arc::ArcAuthService::IsAllowedForProfile(helper->profile()) && + helper->IsValidIDForCurrentUser(ArcSupportHost::kHostAppId)) { + apps.push_back(ArcSupportHost::kHostAppId); + } + // If not added yet, the chrome item will be the last item in the list. if (!chrome_listed) apps.push_back(extension_misc::kChromeAppId);
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc index 14e4046..ae446cc7 100644 --- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc +++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
@@ -7,7 +7,10 @@ #include <stddef.h> #include "ash/wm/window_util.h" +#include "chrome/browser/chromeos/arc/arc_support_host.h" #include "chrome/browser/extensions/launch_util.h" +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" @@ -58,6 +61,15 @@ } // namespace +// static +AppShortcutLauncherItemController* AppShortcutLauncherItemController::Create( + const std::string& app_id, + ChromeLauncherController* controller) { + if (app_id == ArcSupportHost::kHostAppId || app_id == arc::kPlayStoreAppId) + return new ArcPlaystoreShortcutLauncherItemController(controller); + return new AppShortcutLauncherItemController(app_id, controller); +} + // Item controller for an app shortcut. Shortcuts track app and launcher ids, // but do not have any associated windows (opening a shortcut will replace the // item with the appropriate LauncherItemController type).
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h index 20165a4..a71c1822 100644 --- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
@@ -27,11 +27,12 @@ // item with the appropriate LauncherItemController type). class AppShortcutLauncherItemController : public LauncherItemController { public: - AppShortcutLauncherItemController(const std::string& app_id, - ChromeLauncherController* controller); - ~AppShortcutLauncherItemController() override; + static AppShortcutLauncherItemController* Create( + const std::string& app_id, + ChromeLauncherController* controller); + std::vector<content::WebContents*> GetRunningApplications(); // LauncherItemController overrides: @@ -56,6 +57,12 @@ // Set the refocus url pattern. Used by unit tests. void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; } + ChromeLauncherController* controller() { return chrome_launcher_controller_; } + + protected: + AppShortcutLauncherItemController(const std::string& app_id, + ChromeLauncherController* controller); + private: // Get the last running application. content::WebContents* GetLRUApplication();
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc index 260080a9..71d7fb0 100644 --- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
@@ -8,7 +8,10 @@ #include "ash/wm/window_state_aura.h" #include "ash/wm/window_util.h" #include "base/bind.h" +#include "chrome/browser/chromeos/arc/arc_auth_service.h" +#include "chrome/browser/chromeos/arc/arc_support_host.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "components/arc/arc_bridge_service.h" @@ -270,10 +273,14 @@ DCHECK_EQ(controller->app_id(), app_id); shelf_id = controller->shelf_id(); } else { - controller = new ArcAppWindowLauncherItemController(app_id, owner()); - shelf_id = owner()->GetShelfIDForAppID(app_id); + const std::string shelf_app_id = + app_id == arc::kPlayStoreAppId ? ArcSupportHost::kHostAppId : app_id; + controller = + new ArcAppWindowLauncherItemController(shelf_app_id, app_id, owner()); + shelf_id = owner()->GetShelfIDForAppID(shelf_app_id); if (shelf_id == 0) { - shelf_id = owner()->CreateAppLauncherItem(controller, app_id, + // Map Play Store shelf icon to Arc Support host, to share one entry. + shelf_id = owner()->CreateAppLauncherItem(controller, shelf_app_id, ash::STATUS_RUNNING); } else { owner()->SetItemController(shelf_id, controller);
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc index ce054cfc..d4bda04 100644 --- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc +++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc
@@ -11,9 +11,13 @@ #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( - const std::string& app_id, + const std::string& shelf_app_id, + const std::string& arc_app_id, ChromeLauncherController* controller) - : AppWindowLauncherItemController(TYPE_APP, app_id, app_id, controller) {} + : AppWindowLauncherItemController(TYPE_APP, + shelf_app_id, + arc_app_id, + controller) {} ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {}
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.h index e6c13de..d59ef9e 100644 --- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.h
@@ -15,7 +15,8 @@ class ArcAppWindowLauncherItemController : public AppWindowLauncherItemController { public: - ArcAppWindowLauncherItemController(const std::string& app_id, + ArcAppWindowLauncherItemController(const std::string& shelf_app_id, + const std::string& arc_app_id, ChromeLauncherController* controller); ~ArcAppWindowLauncherItemController() override;
diff --git a/chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.cc new file mode 100644 index 0000000..d3083622 --- /dev/null +++ b/chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.cc
@@ -0,0 +1,35 @@ +// 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_service.h" +#include "chrome/browser/chromeos/arc/arc_support_host.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h" +#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" + +ArcPlaystoreShortcutLauncherItemController:: + ArcPlaystoreShortcutLauncherItemController( + ChromeLauncherController* controller) + : AppShortcutLauncherItemController(ArcSupportHost::kHostAppId, + controller) {} + +ArcPlaystoreShortcutLauncherItemController:: + ~ArcPlaystoreShortcutLauncherItemController() {} + +ash::ShelfItemDelegate::PerformedAction +ArcPlaystoreShortcutLauncherItemController::Activate(ash::LaunchSource source) { + arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); + DCHECK(auth_service->IsAllowed()); + + if (!auth_service->IsArcEnabled()) + auth_service->EnableArc(); + + // Deferred launcher. + playstore_launcher_.reset( + new ArcAppLauncher(controller()->profile(), arc::kPlayStoreAppId, true)); + + return kNoAction; +}
diff --git a/chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h new file mode 100644 index 0000000..a8dcc68 --- /dev/null +++ b/chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h
@@ -0,0 +1,34 @@ +// 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_UI_ASH_LAUNCHER_ARC_PLAYSTORE_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ +#define CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_PLAYSTORE_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ + +#include <memory> + +#include "base/macros.h" +#include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h" +#include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" + +class ArcAppLauncher; +class ChromeLauncherController; + +class ArcPlaystoreShortcutLauncherItemController + : public AppShortcutLauncherItemController { + public: + ArcPlaystoreShortcutLauncherItemController( + ChromeLauncherController* controller); + ~ArcPlaystoreShortcutLauncherItemController() override; + + // LauncherItemController overrides: + ash::ShelfItemDelegate::PerformedAction Activate( + ash::LaunchSource source) override; + + private: + std::unique_ptr<ArcAppLauncher> playstore_launcher_; + + DISALLOW_COPY_AND_ASSIGN(ArcPlaystoreShortcutLauncherItemController); +}; + +#endif // CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_PLAYSTORE_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc index 8067e6c..61f9175 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -27,6 +27,7 @@ #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" +#include "chrome/browser/chromeos/arc/arc_support_host.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_app_icon_loader.h" #include "chrome/browser/extensions/extension_util.h" @@ -37,6 +38,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/ash/app_sync_ui_state.h" #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" #include "chrome/browser/ui/ash/chrome_shell_delegate.h" @@ -181,7 +183,7 @@ } const char* const kPinProhibitedExtensionIds[] = { - "cnbgggchhmkkdmeppjobngjoejnihlei", // Arc Support + ArcSupportHost::kHostAppId, arc::kPlayStoreAppId, }; const size_t kPinProhibitedExtensionIdsLength = @@ -445,7 +447,7 @@ CHECK(iter != id_to_item_controller_map_.end()); SetItemStatus(id, ash::STATUS_CLOSED); std::string app_id = iter->second->app_id(); - iter->second = new AppShortcutLauncherItemController(app_id, this); + iter->second = AppShortcutLauncherItemController::Create(app_id, this); iter->second->set_shelf_id(id); // Existing controller is destroyed and replaced by registering again. SetShelfItemDelegate(id, iter->second); @@ -633,7 +635,7 @@ // Create a temporary application launcher item and use it to see if there are // running instances. std::unique_ptr<AppShortcutLauncherItemController> app_controller( - new AppShortcutLauncherItemController(app_id, this)); + AppShortcutLauncherItemController::Create(app_id, this)); if (!app_controller->GetRunningApplications().empty()) app_controller->Activate(source); else @@ -803,7 +805,11 @@ if (model_->items()[i].type == ash::TYPE_APP_SHORTCUT) { ash::ShelfID id = model_->items()[i].id; LauncherItemController* controller = GetLauncherItemController(id); - if (controller && IsPinned(id)) { + // Don't persist pinning state for apps that are handled internally and + // have pinnable state AppListControllerDelegate::NO_PIN. + if (controller && IsPinned(id) && + GetPinnable(controller->app_id()) != + AppListControllerDelegate::NO_PIN) { base::DictionaryValue* app_value = ash::CreateAppDict( controller->app_id()); if (app_value) { @@ -1298,7 +1304,7 @@ int index, ash::ShelfItemType shelf_item_type) { AppShortcutLauncherItemController* controller = - new AppShortcutLauncherItemController(app_id, this); + AppShortcutLauncherItemController::Create(app_id, this); ash::ShelfID shelf_id = InsertAppLauncherItem( controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); return shelf_id;
diff --git a/chrome/browser/ui/ash/launcher/launcher_controller_helper.h b/chrome/browser/ui/ash/launcher/launcher_controller_helper.h index d457c8d1..dec8e96 100644 --- a/chrome/browser/ui/ash/launcher/launcher_controller_helper.h +++ b/chrome/browser/ui/ash/launcher/launcher_controller_helper.h
@@ -50,6 +50,8 @@ virtual ArcAppListPrefs* GetArcAppListPrefs() const; + const Profile* profile() const { return profile_; } + private: // ExtensionEnableFlowDelegate: void ExtensionEnableFlowFinished() override;
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index e2bd5ce..c599839c 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc
@@ -89,6 +89,7 @@ #include "chrome/browser/extensions/api/commands/command_service.h" #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" #include "chrome/browser/extensions/tab_helper.h" +#include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/extensions/extension_metrics.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" @@ -467,6 +468,9 @@ url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); } + + if (disposition == CURRENT_TAB || disposition == NEW_FOREGROUND_TAB) + extensions::MaybeShowExtensionControlledHomeNotification(browser); #endif OpenURLParams params(
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm index e6ed066..043e0d7 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
@@ -1137,7 +1137,7 @@ CGFloat lineWidth = 0; BOOL isRetina = NO; - BOOL reduceHeight = YES; + BOOL reduceHeight = NO; switch (currentState_) { case BookmarkBar::SHOW: @@ -1149,10 +1149,9 @@ lineWidth = [[self view] cr_lineWidth]; isRetina = (lineWidth < 1); - // If Material Design and Retina, no height adjustment is needed. - if (ui::MaterialDesignController::IsModeMaterial() && isRetina) { - reduceHeight = NO; - } + // Only adjust the height if Retina and not Material Design. + reduceHeight = + isRetina && !ui::MaterialDesignController::IsModeMaterial(); return reduceHeight ? chrome::kBookmarkBarHeight + 1 : chrome::kBookmarkBarHeight;
diff --git a/chrome/browser/ui/cocoa/browser_window_layout.h b/chrome/browser/ui/cocoa/browser_window_layout.h index 6f43d0e..82cf1f9c 100644 --- a/chrome/browser/ui/cocoa/browser_window_layout.h +++ b/chrome/browser/ui/cocoa/browser_window_layout.h
@@ -11,8 +11,8 @@ namespace chrome { -// Returns the height of the tab strip. -CGFloat TabStripHeight(); +// The height of the tab strip. +extern const CGFloat kTabStripHeight; // The parameters used to calculate the layout of the views managed by the // BrowserWindowController.
diff --git a/chrome/browser/ui/cocoa/browser_window_layout.mm b/chrome/browser/ui/cocoa/browser_window_layout.mm index 3a571684..23ca75e 100644 --- a/chrome/browser/ui/cocoa/browser_window_layout.mm +++ b/chrome/browser/ui/cocoa/browser_window_layout.mm
@@ -10,20 +10,11 @@ #include "base/logging.h" #include "base/mac/mac_util.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" -#include "ui/base/material_design/material_design_controller.h" namespace chrome { // The height of the tab strip. const CGFloat kTabStripHeight = 37; -const CGFloat kMaterialTabStripHeight = 35; - -CGFloat TabStripHeight() { - if (ui::MaterialDesignController::IsModeMaterial()) - return kMaterialTabStripHeight; - - return kTabStripHeight; -} } // namespace chrome @@ -204,8 +195,8 @@ // Lay out the tab strip. maxY_ = parameters_.windowSize.height + fullscreenYOffset_; CGFloat width = parameters_.contentViewSize.width; - layout.frame = NSMakeRect(0, maxY_ - chrome::TabStripHeight(), width, - chrome::TabStripHeight()); + layout.frame = NSMakeRect( + 0, maxY_ - chrome::kTabStripHeight, width, chrome::kTabStripHeight); maxY_ = NSMinY(layout.frame); // In Yosemite, there is no longer an exit fullscreen button in the top-right @@ -235,14 +226,14 @@ // Center the button, but make sure that it's pixel aligned on non-retina // displays. Use trunc() instead of round() to mimic the behavior of // autoresizesSubviews. - badgeYOffset = trunc((chrome::TabStripHeight() - buttonHeight) / 2); + badgeYOffset = trunc((chrome::kTabStripHeight - buttonHeight) / 2); } else { // Actually place the badge *above* |maxY|, by +2 to miss the divider. badgeYOffset = 2 * parameters_.avatarLineWidth; } NSSize size = NSMakeSize(parameters_.avatarSize.width, - std::min(buttonHeight, chrome::TabStripHeight())); + std::min(buttonHeight, chrome::kTabStripHeight)); NSPoint origin = NSMakePoint(width - parameters_.avatarSize.width + badgeXOffset, maxY_ + badgeYOffset); @@ -386,7 +377,7 @@ CGFloat totalHeight = 0; if (parameters_.hasTabStrip) - totalHeight += chrome::TabStripHeight(); + totalHeight += chrome::kTabStripHeight; if (parameters_.hasToolbar) { totalHeight += parameters_.toolbarHeight;
diff --git a/chrome/browser/ui/cocoa/browser_window_layout_unittest.mm b/chrome/browser/ui/cocoa/browser_window_layout_unittest.mm index 1523172..8389fc8 100644 --- a/chrome/browser/ui/cocoa/browser_window_layout_unittest.mm +++ b/chrome/browser/ui/cocoa/browser_window_layout_unittest.mm
@@ -9,22 +9,6 @@ #import "chrome/browser/ui/cocoa/browser_window_layout.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" -#include "ui/base/material_design/material_design_controller.h" - -namespace { - -// In Material Design, the tabstrip's height is 2px smaller. As such, the -// expected y values in the tests need to take account of the offset. - -int TabStripYOffset() { - return ui::MaterialDesignController::IsModeMaterial() ? 2 : 0; -} - -int AvatarYOffset() { - return ui::MaterialDesignController::IsModeMaterial() ? 1 : 0; -} - -} // namespace class BrowserWindowLayoutTest : public testing::Test { public: @@ -72,46 +56,39 @@ }; TEST_F(BrowserWindowLayoutTest, TestAllViews) { - int yOffset = TabStripYOffset(); chrome::LayoutOutput output = [layout computeLayout]; - EXPECT_NSEQ(NSMakeRect(0, 585 + yOffset, 600, 37 - yOffset), - output.tabStripLayout.frame); - EXPECT_NSEQ(NSMakeRect(502, 589 + AvatarYOffset(), 63, 28), - output.tabStripLayout.avatarFrame); + EXPECT_NSEQ(NSMakeRect(0, 585, 600, 37), output.tabStripLayout.frame); + EXPECT_NSEQ(NSMakeRect(502, 589, 63, 28), output.tabStripLayout.avatarFrame); EXPECT_EQ(70, output.tabStripLayout.leftIndent); EXPECT_EQ(98, output.tabStripLayout.rightIndent); - - EXPECT_NSEQ(NSMakeRect(0, 553 + yOffset, 600, 32), output.toolbarFrame); - EXPECT_NSEQ(NSMakeRect(0, 527 + yOffset, 600, 26), output.bookmarkFrame); + EXPECT_NSEQ(NSMakeRect(0, 553, 600, 32), output.toolbarFrame); + EXPECT_NSEQ(NSMakeRect(0, 527, 600, 26), output.bookmarkFrame); EXPECT_NSEQ(NSZeroRect, output.fullscreenBackingBarFrame); - EXPECT_EQ(527 + yOffset, output.findBarMaxY); - EXPECT_NSEQ(NSMakeRect(0, 455 + yOffset, 600, 111), output.infoBarFrame); + EXPECT_EQ(527, output.findBarMaxY); + EXPECT_NSEQ(NSMakeRect(0, 455, 600, 111), output.infoBarFrame); EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame); - EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411 + yOffset), output.contentAreaFrame); + EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame); } TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreen) { ApplyStandardFullscreenLayoutParameters(); - int yOffset = TabStripYOffset(); + chrome::LayoutOutput output = [layout computeLayout]; - EXPECT_NSEQ(NSMakeRect(0, 585 + yOffset, 600, 37 - yOffset), - output.tabStripLayout.frame); - EXPECT_NSEQ(NSMakeRect(533, 589 + AvatarYOffset(), 63, 28), - output.tabStripLayout.avatarFrame); + EXPECT_NSEQ(NSMakeRect(0, 585, 600, 37), output.tabStripLayout.frame); + EXPECT_NSEQ(NSMakeRect(533, 589, 63, 28), output.tabStripLayout.avatarFrame); EXPECT_EQ(0, output.tabStripLayout.leftIndent); EXPECT_FALSE(output.tabStripLayout.addCustomWindowControls); EXPECT_EQ(67, output.tabStripLayout.rightIndent); - EXPECT_NSEQ(NSMakeRect(0, 553 + yOffset, 600, 32), output.toolbarFrame); - EXPECT_NSEQ(NSMakeRect(0, 527 + yOffset, 600, 26), output.bookmarkFrame); - EXPECT_NSEQ(NSMakeRect(0, 527 + yOffset, 600, 95 - yOffset), - output.fullscreenBackingBarFrame); - EXPECT_EQ(527 + yOffset, output.findBarMaxY); - EXPECT_EQ(527 + yOffset, output.fullscreenExitButtonMaxY); - EXPECT_NSEQ(NSMakeRect(0, 455 + yOffset, 600, 111), output.infoBarFrame); + EXPECT_NSEQ(NSMakeRect(0, 553, 600, 32), output.toolbarFrame); + EXPECT_NSEQ(NSMakeRect(0, 527, 600, 26), output.bookmarkFrame); + EXPECT_NSEQ(NSMakeRect(0, 527, 600, 95), output.fullscreenBackingBarFrame); + EXPECT_EQ(527, output.findBarMaxY); + EXPECT_EQ(527, output.fullscreenExitButtonMaxY); + EXPECT_NSEQ(NSMakeRect(0, 455, 600, 111), output.infoBarFrame); EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame); - EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411 + yOffset), output.contentAreaFrame); + EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame); } // In fullscreen mode for Yosemite, the tab strip's left indent should be @@ -130,25 +107,21 @@ ApplyStandardFullscreenLayoutParameters(); [layout setFullscreenMenubarOffset:-10]; - int yOffset = TabStripYOffset(); chrome::LayoutOutput output = [layout computeLayout]; - EXPECT_NSEQ(NSMakeRect(0, 575 + yOffset, 600, 37 - yOffset), - output.tabStripLayout.frame); - EXPECT_NSEQ(NSMakeRect(533, 579 + AvatarYOffset(), 63, 28), - output.tabStripLayout.avatarFrame); + EXPECT_NSEQ(NSMakeRect(0, 575, 600, 37), output.tabStripLayout.frame); + EXPECT_NSEQ(NSMakeRect(533, 579, 63, 28), output.tabStripLayout.avatarFrame); EXPECT_EQ(0, output.tabStripLayout.leftIndent); EXPECT_FALSE(output.tabStripLayout.addCustomWindowControls); EXPECT_EQ(67, output.tabStripLayout.rightIndent); - EXPECT_NSEQ(NSMakeRect(0, 543 + yOffset, 600, 32), output.toolbarFrame); - EXPECT_NSEQ(NSMakeRect(0, 517 + yOffset, 600, 26), output.bookmarkFrame); - EXPECT_NSEQ(NSMakeRect(0, 517 + yOffset, 600, 95 - yOffset), - output.fullscreenBackingBarFrame); - EXPECT_EQ(517 + yOffset, output.findBarMaxY); - EXPECT_EQ(517 + yOffset, output.fullscreenExitButtonMaxY); - EXPECT_NSEQ(NSMakeRect(0, 445 + yOffset, 600, 111), output.infoBarFrame); + EXPECT_NSEQ(NSMakeRect(0, 543, 600, 32), output.toolbarFrame); + EXPECT_NSEQ(NSMakeRect(0, 517, 600, 26), output.bookmarkFrame); + EXPECT_NSEQ(NSMakeRect(0, 517, 600, 95), output.fullscreenBackingBarFrame); + EXPECT_EQ(517, output.findBarMaxY); + EXPECT_EQ(517, output.fullscreenExitButtonMaxY); + EXPECT_NSEQ(NSMakeRect(0, 445, 600, 111), output.infoBarFrame); EXPECT_NSEQ(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame); - EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411 + yOffset), output.contentAreaFrame); + EXPECT_NSEQ(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame); } TEST_F(BrowserWindowLayoutTest, TestPopupWindow) { @@ -238,6 +211,5 @@ chrome::LayoutOutput output = [layout computeLayout]; - EXPECT_NSEQ(NSMakeRect(537, 589 + AvatarYOffset(), 28, 28), - output.tabStripLayout.avatarFrame); + EXPECT_NSEQ(NSMakeRect(537, 589, 28, 28), output.tabStripLayout.avatarFrame); }
diff --git a/chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa_unittest.mm b/chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa_unittest.mm index 35720f1..918ced6b 100644 --- a/chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa_unittest.mm +++ b/chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa_unittest.mm
@@ -121,6 +121,7 @@ ShowBubble(false); EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance()); EXPECT_TRUE([bubbleWindow() isVisible]); + EXPECT_TRUE([bubbleWindow() autorecalculatesKeyViewLoop]); } TEST_F(ManagePasswordsBubbleCocoaTest, CloseShouldCloseAndDeleteBubble) {
diff --git a/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.mm b/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.mm index 4afa92bd..254014a 100644 --- a/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.mm
@@ -92,6 +92,7 @@ NSButton* button = [currentController_ defaultButton]; if (button && [self shouldOpenAsKeyWindow]) [window setDefaultButtonCell:[button cell]]; + [window setAutorecalculatesKeyViewLoop:YES]; NSPoint anchorPoint; info_bubble::BubbleArrowLocation arrow;
diff --git a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm index f869c54..dba85d4 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
@@ -93,8 +93,8 @@ [self insertTabStripBackgroundViewIntoWindow:window titleBar:hasTitleBar]; tabStripView_.reset([[TabStripView alloc] - initWithFrame:NSMakeRect(0, 0, kDefaultWidth, - chrome::TabStripHeight())]); + initWithFrame:NSMakeRect( + 0, 0, kDefaultWidth, chrome::kTabStripHeight)]); [tabStripView_ setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; if (hasTabStrip)
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm index 7e289b0..ddd36637 100644 --- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm +++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
@@ -1068,12 +1068,10 @@ // https://crbug.com/326245 . const CGFloat kLineWidth = [[self view] cr_lineWidth]; const BOOL kIsRetina = (kLineWidth < 1); - BOOL reduceHeight = YES; + BOOL reduceHeight = NO; - // If Material Design and Retina, no height adjustment is needed. - if (kIsModeMaterial && kIsRetina) { - reduceHeight = NO; - } + // Only adjust the height if Retina and not Material Design. + reduceHeight = kIsRetina && !kIsModeMaterial; return reduceHeight ? kBaseToolbarHeightNormal - 1 : kBaseToolbarHeightNormal;
diff --git a/chrome/browser/ui/extensions/extension_message_bubble_browsertest.cc b/chrome/browser/ui/extensions/extension_message_bubble_browsertest.cc index 00ce49a..27c3e60 100644 --- a/chrome/browser/ui/extensions/extension_message_bubble_browsertest.cc +++ b/chrome/browser/ui/extensions/extension_message_bubble_browsertest.cc
@@ -6,10 +6,18 @@ #include "base/bind_helpers.h" #include "base/run_loop.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/extensions/extension_action_test_util.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/test_extension_dir.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" +#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" +#include "chrome/browser/ui/location_bar/location_bar.h" #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" +#include "chrome/common/pref_names.h" +#include "components/omnibox/browser/omnibox_view.h" #include "extensions/common/feature_switch.h" #include "extensions/test/extension_test_message_listener.h" @@ -39,6 +47,24 @@ BrowserActionsBarBrowserTest::TearDownOnMainThread(); } +void ExtensionMessageBubbleBrowserTest::AddSettingsOverrideExtension( + const std::string& settings_override_value) { + DCHECK(!custom_extension_dir_); + custom_extension_dir_.reset(new extensions::TestExtensionDir()); + std::string manifest = base::StringPrintf( + "{\n" + " 'name': 'settings override',\n" + " 'version': '0.1',\n" + " 'manifest_version': 2,\n" + " 'description': 'controls settings',\n" + " 'chrome_settings_overrides': {\n" + " %s\n" + " }\n" + "}", settings_override_value.c_str()); + custom_extension_dir_->WriteManifestWithSingleQuotes(manifest); + ASSERT_TRUE(LoadExtension(custom_extension_dir_->unpacked_path())); +} + void ExtensionMessageBubbleBrowserTest::TestBubbleAnchoredToExtensionAction() { scoped_refptr<const extensions::Extension> action_extension = extensions::extension_action_test_util::CreateActionExtension( @@ -143,3 +169,56 @@ base::RunLoop().RunUntilIdle(); CheckBubbleIsNotPresent(third_browser); } + +void ExtensionMessageBubbleBrowserTest::TestControlledNewTabPageBubbleShown() { + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test") + .AppendASCII("override") + .AppendASCII("newtab"))); + CheckBubbleIsNotPresent(browser()); + chrome::NewTab(browser()); + base::RunLoop().RunUntilIdle(); + CheckBubble(browser(), ANCHOR_BROWSER_ACTION); + CloseBubble(browser()); +} + +void ExtensionMessageBubbleBrowserTest::TestControlledHomeBubbleShown() { + browser()->profile()->GetPrefs()->SetBoolean(prefs::kShowHomeButton, true); + + const char kHomePage[] = "'homepage': 'https://www.google.com'\n"; + AddSettingsOverrideExtension(kHomePage); + + CheckBubbleIsNotPresent(browser()); + + chrome::ExecuteCommandWithDisposition(browser(), + IDC_HOME, NEW_FOREGROUND_TAB); + base::RunLoop().RunUntilIdle(); + + CheckBubble(browser(), ANCHOR_BROWSER_ACTION); + CloseBubble(browser()); +} + +void ExtensionMessageBubbleBrowserTest::TestControlledSearchBubbleShown() { + const char kSearchProvider[] = + "'search_provider': {\n" + " 'search_url': 'https://www.google.com/search?q={searchTerms}',\n" + " 'is_default': true,\n" + " 'favicon_url': 'https://www.google.com/favicon.icon',\n" + " 'keyword': 'TheGoogs',\n" + " 'name': 'Google',\n" + " 'encoding': 'UTF-8'\n" + "}\n"; + AddSettingsOverrideExtension(kSearchProvider); + + CheckBubbleIsNotPresent(browser()); + + OmniboxView* omnibox = + browser()->window()->GetLocationBar()->GetOmniboxView(); + omnibox->OnBeforePossibleChange(); + omnibox->SetUserText(base::ASCIIToUTF16("search for this")); + omnibox->OnAfterPossibleChange(true); + omnibox->model()->AcceptInput(CURRENT_TAB, false); + base::RunLoop().RunUntilIdle(); + + CheckBubble(browser(), ANCHOR_BROWSER_ACTION); + CloseBubble(browser()); +}
diff --git a/chrome/browser/ui/extensions/extension_message_bubble_browsertest.h b/chrome/browser/ui/extensions/extension_message_bubble_browsertest.h index 98d2980..3a2b876 100644 --- a/chrome/browser/ui/extensions/extension_message_bubble_browsertest.h +++ b/chrome/browser/ui/extensions/extension_message_bubble_browsertest.h
@@ -10,6 +10,10 @@ #include "base/macros.h" #include "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h" +namespace extensions { +class TestExtensionDir; +} + class ExtensionMessageBubbleBrowserTest : public BrowserActionsBarBrowserTest { protected: @@ -35,6 +39,10 @@ // Checks that there is no active bubble for the given |browser|. virtual void CheckBubbleIsNotPresent(Browser* browser) = 0; + // Adds a new extension that uses the chrome_settings_overrides api to + // override a setting specified in |settings_override_value|. + void AddSettingsOverrideExtension(const std::string& settings_override_value); + // The following are essentially the different tests, but we can't define the // tests in this file, since it relies on platform-specific implementation // (the above virtual methods). @@ -68,10 +76,26 @@ // Regression test for crbug.com/607099. void TestDevModeBubbleIsntShownTwice(); + // Tests that the bubble indicating an extension is controlling a user's + // new tab page is shown. + void TestControlledNewTabPageBubbleShown(); + + // Tests that the bubble indicating an extension is controlling a user's + // home page is shown. + void TestControlledHomeBubbleShown(); + + // Tests that the bubble indicating an extension is controlling a user's + // search engine is shown. + void TestControlledSearchBubbleShown(); + private: std::unique_ptr<extensions::FeatureSwitch::ScopedOverride> dev_mode_bubble_override_; + // The backing directory for a custom extension loaded during a test. Null if + // no custom extension is loaded. + std::unique_ptr<extensions::TestExtensionDir> custom_extension_dir_; + DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleBrowserTest); };
diff --git a/chrome/browser/ui/extensions/settings_api_bubble_helpers.cc b/chrome/browser/ui/extensions/settings_api_bubble_helpers.cc new file mode 100644 index 0000000..94b194a --- /dev/null +++ b/chrome/browser/ui/extensions/settings_api_bubble_helpers.cc
@@ -0,0 +1,105 @@ +// Copyright (c) 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 "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" + +#include <utility> + +#include "build/build_config.h" +#include "chrome/browser/extensions/ntp_overridden_bubble_delegate.h" +#include "chrome/browser/extensions/settings_api_bubble_delegate.h" +#include "chrome/browser/extensions/settings_api_helpers.h" +#include "chrome/browser/ui/browser_finder.h" +#include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" +#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h" +#include "chrome/common/url_constants.h" +#include "content/public/browser/browser_url_handler.h" +#include "content/public/browser/navigation_entry.h" +#include "extensions/common/constants.h" + +namespace extensions { + +namespace { + +void ShowSettingsApiBubble(SettingsApiOverrideType type, + Browser* browser) { + std::unique_ptr<ExtensionMessageBubbleController> settings_api_bubble( + new ExtensionMessageBubbleController( + new SettingsApiBubbleDelegate(browser->profile(), type), browser)); + if (!settings_api_bubble->ShouldShow()) + return; + + ToolbarActionsBar* toolbar_actions_bar = + browser->window()->GetToolbarActionsBar(); + std::unique_ptr<ToolbarActionsBarBubbleDelegate> bridge( + new ExtensionMessageBubbleBridge(std::move(settings_api_bubble))); + toolbar_actions_bar->ShowToolbarActionBubbleAsync(std::move(bridge)); +} + +} // namespace + +void MaybeShowExtensionControlledHomeNotification(Browser* browser) { +#if !defined(OS_WIN) + return; +#endif + + ShowSettingsApiBubble(BUBBLE_TYPE_HOME_PAGE, browser); +} + +void MaybeShowExtensionControlledSearchNotification( + Profile* profile, + content::WebContents* web_contents, + AutocompleteMatch::Type match_type) { +#if !defined(OS_WIN) + return; +#endif + + if (AutocompleteMatch::IsSearchType(match_type) && + match_type != AutocompleteMatchType::SEARCH_OTHER_ENGINE) { + Browser* browser = chrome::FindBrowserWithWebContents(web_contents); + ShowSettingsApiBubble(BUBBLE_TYPE_SEARCH_ENGINE, browser); + } +} + +void MaybeShowExtensionControlledNewTabPage( + Browser* browser, content::WebContents* web_contents) { +#if !defined(OS_WIN) + return; +#endif + + content::NavigationEntry* entry = + web_contents->GetController().GetActiveEntry(); + if (!entry) + return; + GURL active_url = entry->GetURL(); + if (!active_url.SchemeIs(extensions::kExtensionScheme)) + return; // Not a URL that we care about. + + // See if the current active URL matches a transformed NewTab URL. + GURL ntp_url(chrome::kChromeUINewTabURL); + bool ignored_param; + content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( + &ntp_url, + web_contents->GetBrowserContext(), + &ignored_param); + if (ntp_url != active_url) + return; // Not being overridden by an extension. + + std::unique_ptr<ExtensionMessageBubbleController> ntp_overridden_bubble( + new ExtensionMessageBubbleController( + new NtpOverriddenBubbleDelegate(browser->profile()), browser)); + if (!ntp_overridden_bubble->ShouldShow()) + return; + + ToolbarActionsBar* toolbar_actions_bar = + browser->window()->GetToolbarActionsBar(); + std::unique_ptr<ToolbarActionsBarBubbleDelegate> bridge( + new ExtensionMessageBubbleBridge(std::move(ntp_overridden_bubble))); + toolbar_actions_bar->ShowToolbarActionBubbleAsync(std::move(bridge)); +} + +} // namespace extensions
diff --git a/chrome/browser/ui/views/settings_api_bubble_helper_views.h b/chrome/browser/ui/extensions/settings_api_bubble_helpers.h similarity index 81% rename from chrome/browser/ui/views/settings_api_bubble_helper_views.h rename to chrome/browser/ui/extensions/settings_api_bubble_helpers.h index 74d51e0..08f69e6 100644 --- a/chrome/browser/ui/views/settings_api_bubble_helper_views.h +++ b/chrome/browser/ui/extensions/settings_api_bubble_helpers.h
@@ -1,9 +1,9 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// 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_UI_VIEWS_SETTINGS_API_BUBBLE_HELPER_VIEWS_H_ -#define CHROME_BROWSER_UI_VIEWS_SETTINGS_API_BUBBLE_HELPER_VIEWS_H_ +#ifndef CHROME_BROWSER_UI_EXTENSIONS_SETTINGS_API_BUBBLE_HELPERS_H_ +#define CHROME_BROWSER_UI_EXTENSIONS_SETTINGS_API_BUBBLE_HELPERS_H_ #include "components/omnibox/browser/autocomplete_match.h" @@ -38,4 +38,4 @@ } // namespace extensions -#endif // CHROME_BROWSER_UI_VIEWS_SETTINGS_API_BUBBLE_HELPER_VIEWS_H_ +#endif // CHROME_BROWSER_UI_EXTENSIONS_SETTINGS_API_BUBBLE_HELPERS_H_
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc index 4cc6f73..180b01e 100644 --- a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
@@ -21,6 +21,7 @@ #include "chrome/browser/ui/extensions/extension_action_view_controller.h" #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" +#include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" @@ -136,9 +137,12 @@ popped_out_action_(nullptr), is_popped_out_sticky_(false), is_showing_bubble_(false), + tab_strip_observer_(this), weak_ptr_factory_(this) { if (model_) // |model_| can be null in unittests. model_observer_.Add(model_); + + tab_strip_observer_.Add(browser_->tab_strip_model()); } ToolbarActionsBar::~ToolbarActionsBar() { @@ -610,6 +614,14 @@ } } +void ToolbarActionsBar::ShowToolbarActionBubbleAsync( + std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) { + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ToolbarActionsBar::ShowToolbarActionBubble, + weak_ptr_factory_.GetWeakPtr(), + base::Passed(std::move(bubble)))); +} + void ToolbarActionsBar::MaybeShowExtensionBubble( std::unique_ptr<extensions::ExtensionMessageBubbleController> controller) { if (!controller->ShouldShow()) @@ -803,6 +815,13 @@ ResizeDelegate(gfx::Tween::EASE_OUT, false); } +void ToolbarActionsBar::TabInsertedAt(content::WebContents* contents, + int index, + bool foreground) { + if (foreground) + extensions::MaybeShowExtensionControlledNewTabPage(browser_, contents); +} + void ToolbarActionsBar::ReorderActions() { if (toolbar_actions_.empty()) return;
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.h b/chrome/browser/ui/toolbar/toolbar_actions_bar.h index 21304085..b4d36e0 100644 --- a/chrome/browser/ui/toolbar/toolbar_actions_bar.h +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.h
@@ -15,6 +15,7 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/scoped_observer.h" +#include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" #include "ui/gfx/animation/tween.h" @@ -48,7 +49,8 @@ // app menu. The main bar can have only a single row of icons with flexible // width, whereas the overflow bar has multiple rows of icons with a fixed // width (the width of the menu). -class ToolbarActionsBar : public ToolbarActionsModel::Observer { +class ToolbarActionsBar : public ToolbarActionsModel::Observer, + public TabStripModelObserver { public: // A struct to contain the platform settings. struct PlatformSettings { @@ -219,6 +221,9 @@ // Displays the given |bubble| once the toolbar is no longer animating. void ShowToolbarActionBubble( std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble); + // Same as above, but uses PostTask() in all cases. + void ShowToolbarActionBubbleAsync( + std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble); // Returns the underlying toolbar actions, but does not order them. Primarily // for use in testing. @@ -267,6 +272,11 @@ void OnToolbarHighlightModeChanged(bool is_highlighting) override; void OnToolbarModelInitialized() override; + // TabStripModelObserver: + void TabInsertedAt(content::WebContents* contents, + int index, + bool foreground) override; + // Resizes the delegate (if necessary) to the preferred size using the given // |tween_type| and optionally suppressing the chevron. void ResizeDelegate(gfx::Tween::Type tween_type, bool suppress_chevron); @@ -352,6 +362,8 @@ // True if a bubble is currently being shown. bool is_showing_bubble_; + ScopedObserver<TabStripModel, TabStripModelObserver> tab_strip_observer_; + base::ObserverList<ToolbarActionsBarObserver> observers_; base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_;
diff --git a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc index 0db2e9e..248cb1f 100644 --- a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc
@@ -60,6 +60,15 @@ DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleViewBrowserTest); }; +class ExtensionMessageBubbleViewBrowserTestRedesign + : public ExtensionMessageBubbleViewBrowserTest { + protected: + void SetUpCommandLine(base::CommandLine* command_line) override { + ExtensionMessageBubbleViewBrowserTest::SetUpCommandLine(command_line); + override_redesign_.reset(); + } +}; + void ExtensionMessageBubbleViewBrowserTest::CheckBubble(Browser* browser, AnchorPosition anchor) { ToolbarView* toolbar_view = GetToolbarViewForBrowser(browser); @@ -68,6 +77,7 @@ views::View* anchor_view = nullptr; switch (anchor) { case ANCHOR_BROWSER_ACTION: + DCHECK_GT(container->num_toolbar_actions(), 0u); anchor_view = container->GetToolbarActionViewAt(0); break; case ANCHOR_APP_MENU: @@ -127,3 +137,22 @@ TestDevModeBubbleIsntShownTwice) { TestDevModeBubbleIsntShownTwice(); } + +// Tests for the extension bubble and settings overrides. These bubbles are +// currently only shown on Windows. +#if defined(OS_WIN) +IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleViewBrowserTestRedesign, + TestControlledNewTabPageMessageBubble) { + TestControlledNewTabPageBubbleShown(); +} + +IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleViewBrowserTestRedesign, + TestControlledHomeMessageBubble) { + TestControlledHomeBubbleShown(); +} + +IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleViewBrowserTestRedesign, + TestControlledSearchMessageBubble) { + TestControlledSearchBubbleShown(); +} +#endif // defined(OS_WIN)
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index ed2a15b..c318f8e 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -86,7 +86,6 @@ #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" #include "chrome/browser/ui/views/session_crashed_bubble_view.h" -#include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" #include "chrome/browser/ui/views/status_bubble_views.h" #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/tab.h" @@ -1549,9 +1548,6 @@ } #endif web_contents_close_handler_->TabInserted(); - - if (foreground) - extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); } void BrowserView::TabDetachedAt(WebContents* contents, int index) {
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index dd9cdba..4813a30 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -22,7 +22,6 @@ #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" -#include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" #include "chrome/grit/generated_resources.h" #include "components/bookmarks/browser/bookmark_node_data.h" #include "components/omnibox/browser/autocomplete_input.h" @@ -64,6 +63,10 @@ #include "chrome/browser/browser_process.h" #endif +#if defined(ENABLE_EXTENSIONS) +#include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" +#endif + using bookmarks::BookmarkNodeData; namespace { @@ -602,8 +605,10 @@ } void OmniboxViewViews::OnMatchOpened(AutocompleteMatch::Type match_type) { +#if defined(ENABLE_EXTENSIONS) extensions::MaybeShowExtensionControlledSearchNotification( profile_, location_bar_view_->GetWebContents(), match_type); +#endif } int OmniboxViewViews::GetOmniboxTextLength() const {
diff --git a/chrome/browser/ui/views/settings_api_bubble_helper_views.cc b/chrome/browser/ui/views/settings_api_bubble_helper_views.cc deleted file mode 100644 index 589e53f..0000000 --- a/chrome/browser/ui/views/settings_api_bubble_helper_views.cc +++ /dev/null
@@ -1,127 +0,0 @@ -// Copyright (c) 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 "chrome/browser/ui/views/settings_api_bubble_helper_views.h" - -#include <utility> - -#include "build/build_config.h" -#include "chrome/browser/extensions/ntp_overridden_bubble_delegate.h" -#include "chrome/browser/extensions/settings_api_bubble_delegate.h" -#include "chrome/browser/extensions/settings_api_helpers.h" -#include "chrome/browser/ui/browser_finder.h" -#include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/views/toolbar/app_menu_button.h" -#include "chrome/browser/ui/views/toolbar/home_button.h" -#include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" -#include "chrome/browser/ui/views/toolbar/toolbar_view.h" -#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/browser_url_handler.h" -#include "content/public/browser/navigation_entry.h" - -namespace extensions { - -namespace { - -void ShowSettingsApiBubble(SettingsApiOverrideType type, - Browser* browser, - views::View* anchor_view, - views::BubbleBorder::Arrow arrow) { - std::unique_ptr<ExtensionMessageBubbleController> settings_api_bubble( - new ExtensionMessageBubbleController( - new SettingsApiBubbleDelegate(browser->profile(), type), browser)); - if (!settings_api_bubble->ShouldShow()) - return; - - // TODO(devlin): This should go through the ToolbarActionsBar. - ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews( - anchor_view, - std::unique_ptr<ToolbarActionsBarBubbleDelegate>( - new ExtensionMessageBubbleBridge(std::move(settings_api_bubble)))); - bubble->set_arrow(arrow); - views::BubbleDialogDelegateView::CreateBubble(bubble); - bubble->Show(); -} - -} // namespace - -void MaybeShowExtensionControlledHomeNotification(Browser* browser) { -#if !defined(OS_WIN) - return; -#endif - - // The bubble will try to anchor itself against the home button - views::View* anchor_view = BrowserView::GetBrowserViewForBrowser(browser)-> - toolbar()->home_button(); - ShowSettingsApiBubble(BUBBLE_TYPE_HOME_PAGE, - browser, - anchor_view, - views::BubbleBorder::TOP_LEFT); -} - -void MaybeShowExtensionControlledSearchNotification( - Profile* profile, - content::WebContents* web_contents, - AutocompleteMatch::Type match_type) { -#if !defined(OS_WIN) - return; -#endif - - if (AutocompleteMatch::IsSearchType(match_type) && - match_type != AutocompleteMatchType::SEARCH_OTHER_ENGINE) { - Browser* browser = chrome::FindBrowserWithWebContents(web_contents); - ToolbarView* toolbar = - BrowserView::GetBrowserViewForBrowser(browser)->toolbar(); - ShowSettingsApiBubble(BUBBLE_TYPE_SEARCH_ENGINE, browser, - toolbar->app_menu_button(), - views::BubbleBorder::TOP_RIGHT); - } -} - -void MaybeShowExtensionControlledNewTabPage( - Browser* browser, content::WebContents* web_contents) { -#if !defined(OS_WIN) - return; -#endif - - content::NavigationEntry* entry = - web_contents->GetController().GetActiveEntry(); - if (!entry) - return; - GURL active_url = entry->GetURL(); - if (!active_url.SchemeIs("chrome-extension")) - return; // Not a URL that we care about. - - // See if the current active URL matches a transformed NewTab URL. - GURL ntp_url(chrome::kChromeUINewTabURL); - bool ignored_param; - content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( - &ntp_url, - web_contents->GetBrowserContext(), - &ignored_param); - if (ntp_url != active_url) - return; // Not being overridden by an extension. - - std::unique_ptr<ExtensionMessageBubbleController> ntp_overridden_bubble( - new ExtensionMessageBubbleController( - new NtpOverriddenBubbleDelegate(browser->profile()), browser)); - if (!ntp_overridden_bubble->ShouldShow()) - return; - - ToolbarActionsBarBubbleViews* bubble = - new ToolbarActionsBarBubbleViews( - BrowserView::GetBrowserViewForBrowser(browser) - ->toolbar() - ->app_menu_button(), - std::unique_ptr<ToolbarActionsBarBubbleDelegate>( - new ExtensionMessageBubbleBridge(std::move(ntp_overridden_bubble)))); - bubble->set_arrow(views::BubbleBorder::TOP_RIGHT); - views::BubbleDialogDelegateView::CreateBubble(bubble); - bubble->Show(); -} - -} // namespace extensions
diff --git a/chrome/browser/ui/views/toolbar/home_button.cc b/chrome/browser/ui/views/toolbar/home_button.cc index 4d8f32a3..2a2e6826 100644 --- a/chrome/browser/ui/views/toolbar/home_button.cc +++ b/chrome/browser/ui/views/toolbar/home_button.cc
@@ -7,7 +7,6 @@ #include "base/macros.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" #include "components/prefs/pref_service.h" @@ -184,8 +183,3 @@ } return ui::DragDropTypes::DRAG_NONE; } - -void HomeButton::NotifyClick(const ui::Event& event) { - ToolbarButton::NotifyClick(event); - extensions::MaybeShowExtensionControlledHomeNotification(browser_); -}
diff --git a/chrome/browser/ui/views/toolbar/home_button.h b/chrome/browser/ui/views/toolbar/home_button.h index a5914ef..d66167c 100644 --- a/chrome/browser/ui/views/toolbar/home_button.h +++ b/chrome/browser/ui/views/toolbar/home_button.h
@@ -26,9 +26,6 @@ int OnDragUpdated(const ui::DropTargetEvent& event) override; int OnPerformDrop(const ui::DropTargetEvent& event) override; - // ToolbarButton: - void NotifyClick(const ui::Event& event) override; - Browser* browser_; DISALLOW_COPY_AND_ASSIGN(HomeButton);
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index e6382cff..4d9254f 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi
@@ -539,6 +539,8 @@ 'browser/ui/ash/launcher/app_window_launcher_controller.h', 'browser/ui/ash/launcher/app_window_launcher_item_controller.cc', 'browser/ui/ash/launcher/app_window_launcher_item_controller.h', + 'browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.cc', + 'browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h', 'browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc', 'browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h', 'browser/ui/ash/launcher/browser_status_monitor.cc', @@ -2391,8 +2393,6 @@ 'browser/ui/views/sad_tab_view.h', 'browser/ui/views/session_crashed_bubble_view.cc', 'browser/ui/views/session_crashed_bubble_view.h', - 'browser/ui/views/settings_api_bubble_helper_views.cc', - 'browser/ui/views/settings_api_bubble_helper_views.h', 'browser/ui/views/simple_message_box_views.cc', 'browser/ui/views/ssl_client_certificate_selector.cc', 'browser/ui/views/ssl_client_certificate_selector.h', @@ -2717,6 +2717,8 @@ 'browser/ui/extensions/hosted_app_browser_controller.h', 'browser/ui/extensions/icon_with_badge_image_source.cc', 'browser/ui/extensions/icon_with_badge_image_source.h', + 'browser/ui/extensions/settings_api_bubble_helpers.cc', + 'browser/ui/extensions/settings_api_bubble_helpers.h', 'browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc', 'browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h', 'browser/ui/webui/extensions/extension_basic_info.cc',
diff --git a/chrome/chrome_installer.gypi b/chrome/chrome_installer.gypi index bc5dc90..325f0b3 100644 --- a/chrome/chrome_installer.gypi +++ b/chrome/chrome_installer.gypi
@@ -190,6 +190,7 @@ 'installer/util/work_item_list_unittest.cc', 'installer/util/work_item_mocks.cc', 'installer/util/work_item_mocks.h', + 'installer/util/work_item_unittest.cc', ], 'msvs_settings': { 'VCManifestTool': {
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 658e79ee..c69f3971 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi
@@ -2671,10 +2671,6 @@ 'sources': [ '<@(chrome_browser_tests_supervised_user_sources)' ], }], ['enable_pepper_cdms==1', { - 'sources' : [ - 'browser/media/pepper_cdm_test_helper.cc', - 'browser/media/pepper_cdm_test_helper.h', - ], 'dependencies': [ # Runtime dependencies. '../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',
diff --git a/chrome/installer/setup/app_launcher_installer.cc b/chrome/installer/setup/app_launcher_installer.cc index 46670fa..e119699 100644 --- a/chrome/installer/setup/app_launcher_installer.cc +++ b/chrome/installer/setup/app_launcher_installer.cc
@@ -45,11 +45,11 @@ WorkItemList* list) { // Ignore failures since this is a clean-up operation and shouldn't block // install or update. - list->AddDeleteRegKeyWorkItem( - installer_state.root_key(), - GetRegistrationDataCommandKey(reg_data, name), - KEY_WOW64_32KEY) - ->set_ignore_failure(true); + auto* delete_reg_key_work_item = list->AddDeleteRegKeyWorkItem( + installer_state.root_key(), GetRegistrationDataCommandKey(reg_data, name), + KEY_WOW64_32KEY); + delete_reg_key_work_item->set_best_effort(true); + delete_reg_key_work_item->set_rollback_enabled(false); } } // namespace @@ -79,9 +79,10 @@ const base::FilePath& temp_path, WorkItemList* list) { DCHECK(!InstallUtil::IsChromeSxSProcess()); - list->AddDeleteTreeWorkItem( - target_path.Append(kLegacyChromeAppHostExe), - temp_path)->set_ignore_failure(true); + auto* delete_tree_work_item = list->AddDeleteTreeWorkItem( + target_path.Append(kLegacyChromeAppHostExe), temp_path); + delete_tree_work_item->set_best_effort(true); + delete_tree_work_item->set_rollback_enabled(false); } void AddRemoveLegacyAppCommandsWorkItems(const InstallerState& installer_state,
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index af966232..43a8ed2 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc
@@ -756,9 +756,12 @@ bool force) { DCHECK(chrome.is_chrome()); - NoRollbackWorkItemList cleanup_list; - AddCleanupDeprecatedPerUserRegistrationsWorkItems(chrome, &cleanup_list); - cleanup_list.Do(); + std::unique_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList()); + cleanup_list->set_log_message("Cleanup deprecated per-user registrations"); + cleanup_list->set_rollback_enabled(false); + cleanup_list->set_best_effort(true); + AddCleanupDeprecatedPerUserRegistrationsWorkItems(chrome, cleanup_list.get()); + cleanup_list->Do(); // Only create shortcuts on Active Setup if the first run sentinel is not // present for this user (as some shortcuts used to be installed on first
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc index fd74265..cc479761 100644 --- a/chrome/installer/setup/install_worker.cc +++ b/chrome/installer/setup/install_worker.cc
@@ -273,7 +273,7 @@ WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem( reg_root, uninstall_reg, KEY_WOW64_32KEY); - delete_reg_key->set_ignore_failure(true); + delete_reg_key->set_best_effort(true); } // Adds Chrome specific install work items to |install_list|. @@ -290,17 +290,20 @@ const base::FilePath& target_path = installer_state.target_path(); if (current_version) { - // Delete the archive from an existing install to save some disk space. We - // make this an unconditional work item since there's no need to roll this - // back; if installation fails we'll be moved to the "-full" channel anyway. + // Delete the archive from an existing install to save some disk space. base::FilePath old_installer_dir( installer_state.GetInstallerDirectory(*current_version)); base::FilePath old_archive( old_installer_dir.Append(installer::kChromeArchive)); // Don't delete the archive that we are actually installing from. if (archive_path != old_archive) { - install_list->AddDeleteTreeWorkItem(old_archive, temp_path)-> - set_ignore_failure(true); + auto* delete_old_archive_work_item = + install_list->AddDeleteTreeWorkItem(old_archive, temp_path); + // Don't cause failure of |install_list| if this WorkItem fails. + delete_old_archive_work_item->set_best_effort(true); + // No need to roll this back; if installation fails we'll be moved to the + // "-full" channel anyway. + delete_old_archive_work_item->set_rollback_enabled(false); } } @@ -375,9 +378,10 @@ WorkItem::ALWAYS_MOVE); // Delete any old_chrome.exe if present (ignore failure if it's in use). - install_list->AddDeleteTreeWorkItem( - target_path.Append(installer::kChromeOldExe), temp_path)-> - set_ignore_failure(true); + install_list + ->AddDeleteTreeWorkItem(target_path.Append(installer::kChromeOldExe), + temp_path) + ->set_best_effort(true); } // Adds work items to remove COM registration for |product|'s deprecated @@ -1149,7 +1153,7 @@ const std::vector<base::FilePath>& dll_list, bool system_level, bool do_register, - bool ignore_failures, + bool best_effort, WorkItemList* work_item_list) { DCHECK(work_item_list); if (dll_list.empty()) { @@ -1161,7 +1165,7 @@ WorkItem* work_item = work_item_list->AddSelfRegWorkItem( dll_path.value(), do_register, !system_level); DCHECK(work_item); - work_item->set_ignore_failure(ignore_failures); + work_item->set_best_effort(best_effort); } } } @@ -1180,7 +1184,7 @@ msi_value, true); DCHECK(set_msi_work_item); - set_msi_work_item->set_ignore_failure(true); + set_msi_work_item->set_best_effort(true); set_msi_work_item->set_log_message("Could not write MSI marker!"); }
diff --git a/chrome/installer/setup/install_worker.h b/chrome/installer/setup/install_worker.h index a2fc7f3..11d7e11 100644 --- a/chrome/installer/setup/install_worker.h +++ b/chrome/installer/setup/install_worker.h
@@ -119,14 +119,13 @@ // |system_level| specifies whether to call the system or user level DLL // registration entry points. // |do_register| says whether to register or unregister. -// |may_fail| states whether this is best effort or not. If |may_fail| is true -// then |work_item_list| will still succeed if the registration fails and -// no registration rollback will be performed. +// If |best_effort| is true, registration or unregistration failure doesn't +// cause failure of |work_item_list|. void AddRegisterComDllWorkItems(const base::FilePath& dll_folder, const std::vector<base::FilePath>& dll_files, bool system_level, bool do_register, - bool ignore_failures, + bool best_effort, WorkItemList* work_item_list); void AddSetMsiMarkerWorkItem(const InstallerState& installer_state,
diff --git a/chrome/installer/setup/install_worker_unittest.cc b/chrome/installer/setup/install_worker_unittest.cc index 8907a53a..030cc7c 100644 --- a/chrome/installer/setup/install_worker_unittest.cc +++ b/chrome/installer/setup/install_worker_unittest.cc
@@ -66,10 +66,6 @@ MOCK_METHOD4( AddDeleteRegValueWorkItem, WorkItem*(HKEY, const std::wstring&, REGSAM, const std::wstring&)); - MOCK_METHOD3(AddDeleteTreeWorkItem, - WorkItem*(const base::FilePath&, - const base::FilePath&, - const std::vector<base::FilePath>&)); MOCK_METHOD2(AddDeleteTreeWorkItem, WorkItem*(const base::FilePath&, const base::FilePath&)); MOCK_METHOD4(AddMoveTreeWorkItem, @@ -463,8 +459,7 @@ WorkItem::CreateSetRegValueWorkItem( kRegRoot, kRegKeyPath, WorkItem::kWow64Default, L"", L"", false)); std::unique_ptr<DeleteTreeWorkItem> delete_tree_work_item( - WorkItem::CreateDeleteTreeWorkItem(base::FilePath(), base::FilePath(), - std::vector<base::FilePath>())); + WorkItem::CreateDeleteTreeWorkItem(base::FilePath(), base::FilePath())); std::unique_ptr<DeleteRegKeyWorkItem> delete_reg_key_work_item( WorkItem::CreateDeleteRegKeyWorkItem(kRegRoot, kRegKeyPath, WorkItem::kWow64Default));
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 368cd93..87eacc6 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc
@@ -430,10 +430,8 @@ google_update::kRegRenameCmdField); } // old_chrome.exe is still in use in most cases, so ignore failures here. - // Make sure this is the last item in the list because it cannot be rolled - // back. - install_list->AddDeleteTreeWorkItem(chrome_old_exe, temp_path.path())-> - set_ignore_failure(true); + install_list->AddDeleteTreeWorkItem(chrome_old_exe, temp_path.path()) + ->set_best_effort(true); installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; if (!install_list->Do()) {
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index 2ff7b1d6..75cc8a6 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc
@@ -36,7 +36,7 @@ #include "chrome/installer/util/master_preferences_constants.h" #include "chrome/installer/util/util_constants.h" #include "courgette/courgette.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include "third_party/bspatch/mbspatch.h" namespace installer {
diff --git a/chrome/installer/setup/setup_util.h b/chrome/installer/setup/setup_util.h index c48a0b74..96a7679 100644 --- a/chrome/installer/setup/setup_util.h +++ b/chrome/installer/setup/setup_util.h
@@ -45,7 +45,7 @@ // Applies a patch file to source file using bsdiff. This function uses // Courgette's flavor of bsdiff. Returns 0 in case of success, or // kBsdiffErrorOffset + a bsdiff status code in case of errors. -// See courgette/third_party/bsdiff.h for details. +// See courgette/third_party/bsdiff/bsdiff.h for details. int BsdiffPatchFiles(const base::FilePath& src, const base::FilePath& patch, const base::FilePath& dest);
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 3bd54a7e..4eb2347 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc
@@ -138,8 +138,10 @@ // Apply the new channel value to all other products and to the multi package. if (modified) { - std::unique_ptr<WorkItemList> update_list( - WorkItem::CreateNoRollbackWorkItemList()); + std::unique_ptr<WorkItemList> update_list(WorkItem::CreateWorkItemList()); + update_list->set_log_message("Channel Value Update"); + update_list->set_best_effort(true); + update_list->set_rollback_enabled(false); std::vector<BrowserDistribution::Type> dist_types; for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { BrowserDistribution::Type other_dist_type = @@ -150,16 +152,18 @@ AddChannelValueUpdateWorkItems(original_state, installer_state, channel_info, dist_types, update_list.get()); - bool success = update_list->Do(); - LOG_IF(ERROR, !success) << "Failed updating channel values."; + update_list->Do(); } } // Processes uninstall WorkItems from install_worker in no-rollback-list. void ProcessChromeWorkItems(const InstallerState& installer_state, const Product& product) { - std::unique_ptr<WorkItemList> work_item_list( - WorkItem::CreateNoRollbackWorkItemList()); + std::unique_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); + work_item_list->set_log_message( + "Cleanup OS upgrade command and deprecated per-user registrations"); + work_item_list->set_best_effort(true); + work_item_list->set_rollback_enabled(false); AddOsUpgradeWorkItems(installer_state, base::FilePath(), Version(), product, work_item_list.get()); // Perform a best-effort cleanup of per-user keys. On system-level installs @@ -168,13 +172,14 @@ // for all users solely for this cleanup). AddCleanupDeprecatedPerUserRegistrationsWorkItems(product, work_item_list.get()); - if (!work_item_list->Do()) - LOG(ERROR) << "Failed to process Chrome WorkItems."; + work_item_list->Do(); } void ProcessIELowRightsPolicyWorkItems(const InstallerState& installer_state) { - std::unique_ptr<WorkItemList> work_items( - WorkItem::CreateNoRollbackWorkItemList()); + std::unique_ptr<WorkItemList> work_items(WorkItem::CreateWorkItemList()); + work_items->set_log_message("Delete old IE low rights policy"); + work_items->set_best_effort(true); + work_items->set_rollback_enabled(false); AddDeleteOldIELowRightsPolicyWorkItems(installer_state, work_items.get()); work_items->Do(); RefreshElevationPolicy();
diff --git a/chrome/installer/setup/update_active_setup_version_work_item.cc b/chrome/installer/setup/update_active_setup_version_work_item.cc index 7372675a..50761eec 100644 --- a/chrome/installer/setup/update_active_setup_version_work_item.cc +++ b/chrome/installer/setup/update_active_setup_version_work_item.cc
@@ -38,11 +38,13 @@ operation_(operation) { } -bool UpdateActiveSetupVersionWorkItem::Do() { +bool UpdateActiveSetupVersionWorkItem::DoImpl() { + set_reg_value_work_item_.set_best_effort(best_effort()); + set_reg_value_work_item_.set_rollback_enabled(rollback_enabled()); return set_reg_value_work_item_.Do(); } -void UpdateActiveSetupVersionWorkItem::Rollback() { +void UpdateActiveSetupVersionWorkItem::RollbackImpl() { set_reg_value_work_item_.Rollback(); }
diff --git a/chrome/installer/setup/update_active_setup_version_work_item.h b/chrome/installer/setup/update_active_setup_version_work_item.h index bb962ac..2a7fb525 100644 --- a/chrome/installer/setup/update_active_setup_version_work_item.h +++ b/chrome/installer/setup/update_active_setup_version_work_item.h
@@ -43,11 +43,11 @@ UpdateActiveSetupVersionWorkItem(const base::string16& active_setup_path, Operation operation); - // Overriden from WorkItem. - bool Do() override; - void Rollback() override; - private: + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Returns the updated Active Setup version to be used based on the // |existing_version|. base::string16 GetUpdatedActiveSetupVersion(
diff --git a/chrome/installer/util/BUILD.gn b/chrome/installer/util/BUILD.gn index baa1a44e..7bed742c 100644 --- a/chrome/installer/util/BUILD.gn +++ b/chrome/installer/util/BUILD.gn
@@ -331,6 +331,7 @@ "work_item_list_unittest.cc", "work_item_mocks.cc", "work_item_mocks.h", + "work_item_unittest.cc", ] deps = [
diff --git a/chrome/installer/util/callback_work_item.cc b/chrome/installer/util/callback_work_item.cc index e2dbbec3..34376ea 100644 --- a/chrome/installer/util/callback_work_item.cc +++ b/chrome/installer/util/callback_work_item.cc
@@ -17,7 +17,7 @@ CallbackWorkItem::~CallbackWorkItem() { } -bool CallbackWorkItem::Do() { +bool CallbackWorkItem::DoImpl() { DCHECK_EQ(roll_state_, RS_UNDEFINED); roll_state_ = RS_FORWARD; @@ -27,7 +27,7 @@ return result; } -void CallbackWorkItem::Rollback() { +void CallbackWorkItem::RollbackImpl() { DCHECK_EQ(roll_state_, RS_UNDEFINED); roll_state_ = RS_BACKWARD;
diff --git a/chrome/installer/util/callback_work_item.h b/chrome/installer/util/callback_work_item.h index 3cc22f6..bcfd56c 100644 --- a/chrome/installer/util/callback_work_item.h +++ b/chrome/installer/util/callback_work_item.h
@@ -35,9 +35,6 @@ public: ~CallbackWorkItem() override; - bool Do() override; - void Rollback() override; - bool IsRollback() const; private: @@ -49,7 +46,12 @@ RS_BACKWARD, }; - CallbackWorkItem(base::Callback<bool(const CallbackWorkItem&)> callback); + explicit CallbackWorkItem( + base::Callback<bool(const CallbackWorkItem&)> callback); + + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; base::Callback<bool(const CallbackWorkItem&)> callback_; RollState roll_state_;
diff --git a/chrome/installer/util/conditional_work_item_list.cc b/chrome/installer/util/conditional_work_item_list.cc index fcf1955..d3495e3 100644 --- a/chrome/installer/util/conditional_work_item_list.cc +++ b/chrome/installer/util/conditional_work_item_list.cc
@@ -13,20 +13,20 @@ ConditionalWorkItemList::~ConditionalWorkItemList() {} -bool ConditionalWorkItemList::Do() { +bool ConditionalWorkItemList::DoImpl() { VLOG(1) << "Evaluating " << log_message_ << " condition..."; if (condition_.get() && condition_->ShouldRun()) { VLOG(1) << "Beginning conditional work item list"; - return WorkItemList::Do(); + return WorkItemList::DoImpl(); } VLOG(1) << "No work to do in condition work item list " << log_message_; return true; } -void ConditionalWorkItemList::Rollback() { +void ConditionalWorkItemList::RollbackImpl() { VLOG(1) << "Rolling back conditional list " << log_message_; - WorkItemList::Rollback(); + WorkItemList::RollbackImpl(); } // Pre-defined conditions:
diff --git a/chrome/installer/util/conditional_work_item_list.h b/chrome/installer/util/conditional_work_item_list.h index 834b1e0..ba28ca2 100644 --- a/chrome/installer/util/conditional_work_item_list.h +++ b/chrome/installer/util/conditional_work_item_list.h
@@ -17,15 +17,17 @@ explicit ConditionalWorkItemList(Condition* condition); ~ConditionalWorkItemList() override; + private: + // WorkItemList: + // If condition_->ShouldRun() returns true, then execute the items in this // list and return true iff they all succeed. If condition_->ShouldRun() // returns false, does nothing and returns true. - bool Do() override; + bool DoImpl() override; // Does a rollback of the items (if any) that were run in Do. - void Rollback() override; + void RollbackImpl() override; - protected: // Pointer to a Condition that is used to determine whether to run this // WorkItemList. std::unique_ptr<Condition> condition_;
diff --git a/chrome/installer/util/conditional_work_item_list_unittest.cc b/chrome/installer/util/conditional_work_item_list_unittest.cc index 1268f5d..cf38d343 100644 --- a/chrome/installer/util/conditional_work_item_list_unittest.cc +++ b/chrome/installer/util/conditional_work_item_list_unittest.cc
@@ -33,12 +33,12 @@ // Expect all three items to be done in order then undone. InSequence s; - EXPECT_CALL(*item1, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item2, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item3, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item3, Rollback()); - EXPECT_CALL(*item2, Rollback()); - EXPECT_CALL(*item1, Rollback()); + EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item3, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item3, RollbackImpl()); + EXPECT_CALL(*item2, RollbackImpl()); + EXPECT_CALL(*item1, RollbackImpl()); } // Add the items to the list. @@ -68,10 +68,10 @@ // Expect the two first work items to be done in order then undone. InSequence s; - EXPECT_CALL(*item1, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item2, Do()).WillOnce(Return(false)); - EXPECT_CALL(*item2, Rollback()); - EXPECT_CALL(*item1, Rollback()); + EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(false)); + EXPECT_CALL(*item2, RollbackImpl()); + EXPECT_CALL(*item1, RollbackImpl()); } // Add the items to the list.
diff --git a/chrome/installer/util/copy_tree_work_item.cc b/chrome/installer/util/copy_tree_work_item.cc index 57ef3dc..156d797 100644 --- a/chrome/installer/util/copy_tree_work_item.cc +++ b/chrome/installer/util/copy_tree_work_item.cc
@@ -28,7 +28,7 @@ copied_to_alternate_path_(false) { } -bool CopyTreeWorkItem::Do() { +bool CopyTreeWorkItem::DoImpl() { if (!base::PathExists(source_path_)) { LOG(ERROR) << source_path_.value() << " does not exist"; return false; @@ -103,7 +103,7 @@ return true; } -void CopyTreeWorkItem::Rollback() { +void CopyTreeWorkItem::RollbackImpl() { // Normally the delete operations below should not fail unless some // programs like anti-virus are inspecting the files we just copied. // If this does happen sometimes, we may consider using Move instead of
diff --git a/chrome/installer/util/copy_tree_work_item.h b/chrome/installer/util/copy_tree_work_item.h index 9aa426a9..dbfdfcc 100644 --- a/chrome/installer/util/copy_tree_work_item.h +++ b/chrome/installer/util/copy_tree_work_item.h
@@ -27,10 +27,6 @@ public: ~CopyTreeWorkItem() override; - bool Do() override; - - void Rollback() override; - private: friend class WorkItem; @@ -45,6 +41,10 @@ CopyOverWriteOption overwrite_option, const base::FilePath& alternative_path); + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Checks if the path specified is in use (and hence can not be deleted) bool IsFileInUse(const base::FilePath& path);
diff --git a/chrome/installer/util/create_dir_work_item.cc b/chrome/installer/util/create_dir_work_item.cc index b2667c12..34215b9 100644 --- a/chrome/installer/util/create_dir_work_item.cc +++ b/chrome/installer/util/create_dir_work_item.cc
@@ -29,7 +29,7 @@ return; } -bool CreateDirWorkItem::Do() { +bool CreateDirWorkItem::DoImpl() { VLOG(1) << "creating directory " << path_.value(); GetTopDirToCreate(); if (top_path_.empty()) @@ -44,7 +44,7 @@ return result; } -void CreateDirWorkItem::Rollback() { +void CreateDirWorkItem::RollbackImpl() { if (!rollback_needed_) return;
diff --git a/chrome/installer/util/create_dir_work_item.h b/chrome/installer/util/create_dir_work_item.h index 217196d..d0718d1 100644 --- a/chrome/installer/util/create_dir_work_item.h +++ b/chrome/installer/util/create_dir_work_item.h
@@ -16,18 +16,19 @@ public: ~CreateDirWorkItem() override; - bool Do() override; + private: + friend class WorkItem; + + explicit CreateDirWorkItem(const base::FilePath& path); + + // WorkItem: + bool DoImpl() override; // Rollback tries to remove all directories created along the path. // If the leaf directory or one of the intermediate directories are not // empty, the non-empty directory and its parent directories will not be // removed. - void Rollback() override; - - private: - friend class WorkItem; - - explicit CreateDirWorkItem(const base::FilePath& path); + void RollbackImpl() override; // Get the top most directory that needs to be created in order to create // "path_", and set "top_path_" accordingly. if "path_" already exists,
diff --git a/chrome/installer/util/create_reg_key_work_item.cc b/chrome/installer/util/create_reg_key_work_item.cc index 4319631..dbf46b20 100644 --- a/chrome/installer/util/create_reg_key_work_item.cc +++ b/chrome/installer/util/create_reg_key_work_item.cc
@@ -46,7 +46,7 @@ wow64_access == KEY_WOW64_64KEY); } -bool CreateRegKeyWorkItem::Do() { +bool CreateRegKeyWorkItem::DoImpl() { if (!InitKeyList()) { // Nothing needs to be done here. VLOG(1) << "no key to create"; @@ -90,7 +90,7 @@ return true; } -void CreateRegKeyWorkItem::Rollback() { +void CreateRegKeyWorkItem::RollbackImpl() { if (!key_created_) return;
diff --git a/chrome/installer/util/create_reg_key_work_item.h b/chrome/installer/util/create_reg_key_work_item.h index a55d941..93b3a0e 100644 --- a/chrome/installer/util/create_reg_key_work_item.h +++ b/chrome/installer/util/create_reg_key_work_item.h
@@ -18,10 +18,6 @@ public: ~CreateRegKeyWorkItem() override; - bool Do() override; - - void Rollback() override; - private: friend class WorkItem; @@ -29,6 +25,10 @@ const std::wstring& path, REGSAM wow64_access); + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Initialize key_list_ by adding all paths of keys from predefined_root_ // to path_. Returns true if key_list_ is non empty. bool InitKeyList();
diff --git a/chrome/installer/util/delete_reg_key_work_item.cc b/chrome/installer/util/delete_reg_key_work_item.cc index 9f482311..c0e13d9 100644 --- a/chrome/installer/util/delete_reg_key_work_item.cc +++ b/chrome/installer/util/delete_reg_key_work_item.cc
@@ -29,34 +29,32 @@ wow64_access == KEY_WOW64_64KEY); } -bool DeleteRegKeyWorkItem::Do() { +bool DeleteRegKeyWorkItem::DoImpl() { + DCHECK(!backup_initialized_); + if (path_.empty()) return false; - RegistryKeyBackup backup; - - // Only try to make a backup if we're not configured to ignore failures. - if (!ignore_failure_) { - if (!backup.Initialize(predefined_root_, path_.c_str(), wow64_access_)) { + // Only try to make a backup if rollback is enabled. + if (rollback_enabled()) { + if (!backup_.Initialize(predefined_root_, path_.c_str(), wow64_access_)) { LOG(ERROR) << "Failed to backup destination for registry key copy."; return false; } + backup_initialized_ = true; } // Delete the key. if (!InstallUtil::DeleteRegistryKey( predefined_root_, path_.c_str(), wow64_access_)) { - return ignore_failure_; + return false; } - // We've succeeded, so remember any backup we may have made. - backup_.swap(backup); - return true; } -void DeleteRegKeyWorkItem::Rollback() { - if (ignore_failure_) +void DeleteRegKeyWorkItem::RollbackImpl() { + if (!backup_initialized_) return; // Delete anything in the key before restoring the backup in case someone else
diff --git a/chrome/installer/util/delete_reg_key_work_item.h b/chrome/installer/util/delete_reg_key_work_item.h index 6af588a..524228f8 100644 --- a/chrome/installer/util/delete_reg_key_work_item.h +++ b/chrome/installer/util/delete_reg_key_work_item.h
@@ -23,10 +23,6 @@ public: ~DeleteRegKeyWorkItem() override; - bool Do() override; - - void Rollback() override; - private: friend class WorkItem; @@ -34,6 +30,10 @@ const std::wstring& path, REGSAM wow64_access); + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Root key from which we delete the key. The root key can only be // one of the predefined keys on Windows. HKEY predefined_root_; @@ -47,6 +47,9 @@ // Backup of the deleted key. RegistryKeyBackup backup_; + // True if |backup_| has been initialized. + bool backup_initialized_ = false; + DISALLOW_COPY_AND_ASSIGN(DeleteRegKeyWorkItem); };
diff --git a/chrome/installer/util/delete_reg_value_work_item.cc b/chrome/installer/util/delete_reg_value_work_item.cc index b5b0b189..f111f93f 100644 --- a/chrome/installer/util/delete_reg_value_work_item.cc +++ b/chrome/installer/util/delete_reg_value_work_item.cc
@@ -29,12 +29,8 @@ DeleteRegValueWorkItem::~DeleteRegValueWorkItem() { } -bool DeleteRegValueWorkItem::Do() { - if (status_ != DELETE_VALUE) { - // we already did something. - LOG(ERROR) << "multiple calls to Do()"; - return false; - } +bool DeleteRegValueWorkItem::DoImpl() { + DCHECK_EQ(DELETE_VALUE, status_); status_ = VALUE_UNCHANGED; @@ -48,8 +44,8 @@ result = key.ReadValue(value_name_.c_str(), NULL, &size, &type); if (result == ERROR_FILE_NOT_FOUND) { - LOG(INFO) << "(delete value) Key: " << key_path_ << " or Value: " - << value_name_ << " does not exist."; + VLOG(1) << "(delete value) Key: " << key_path_ + << " or Value: " << value_name_ << " does not exist."; status_ = VALUE_NOT_FOUND; return true; } @@ -78,9 +74,10 @@ return true; } -void DeleteRegValueWorkItem::Rollback() { - if (status_ == DELETE_VALUE || status_ == VALUE_ROLLED_BACK) - return; +void DeleteRegValueWorkItem::RollbackImpl() { + DCHECK_NE(DELETE_VALUE, status_); + DCHECK_NE(VALUE_ROLLED_BACK, status_); + if (status_ == VALUE_UNCHANGED || status_ == VALUE_NOT_FOUND) { status_ = VALUE_ROLLED_BACK; VLOG(1) << "rollback: setting unchanged, nothing to do"; @@ -88,6 +85,8 @@ } // At this point only possible state is VALUE_DELETED. + DCHECK_EQ(VALUE_DELETED, status_); + RegKey key; LONG result = key.Open(predefined_root_, key_path_.c_str(),
diff --git a/chrome/installer/util/delete_reg_value_work_item.h b/chrome/installer/util/delete_reg_value_work_item.h index f1bd50a..440780d 100644 --- a/chrome/installer/util/delete_reg_value_work_item.h +++ b/chrome/installer/util/delete_reg_value_work_item.h
@@ -18,10 +18,6 @@ public: ~DeleteRegValueWorkItem() override; - bool Do() override; - - void Rollback() override; - private: friend class WorkItem; @@ -43,6 +39,10 @@ REGSAM wow64_acccess, const std::wstring& value_name); + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Root key of the target key under which the value is set. The root key can // only be one of the predefined keys on Windows. HKEY predefined_root_;
diff --git a/chrome/installer/util/delete_tree_work_item.cc b/chrome/installer/util/delete_tree_work_item.cc index 7dbb9e7..8fc5dad 100644 --- a/chrome/installer/util/delete_tree_work_item.cc +++ b/chrome/installer/util/delete_tree_work_item.cc
@@ -4,158 +4,38 @@ #include "chrome/installer/util/delete_tree_work_item.h" -#include <algorithm> -#include <limits> - #include "base/files/file_util.h" #include "base/logging.h" -namespace { +DeleteTreeWorkItem::DeleteTreeWorkItem(const base::FilePath& root_path, + const base::FilePath& temp_path) + : root_path_(root_path), temp_path_(temp_path) {} -// Casts a value of an unsigned type to a signed type of the same size provided -// that there is no overflow. -template<typename L, typename R> -bool SafeCast(L left, R* right) { - DCHECK(right); - static_assert(sizeof(left) == sizeof(right), - "Items SafeCast is used with must be of the same size"); - if (left > static_cast<L>(std::numeric_limits<R>::max())) - return false; - *right = static_cast<L>(left); - return true; -} +DeleteTreeWorkItem::~DeleteTreeWorkItem() = default; -} // namespace - -DeleteTreeWorkItem::DeleteTreeWorkItem( - const base::FilePath& root_path, - const base::FilePath& temp_path, - const std::vector<base::FilePath>& key_paths) - : root_path_(root_path), - temp_path_(temp_path), - moved_to_backup_(false) { - if (!SafeCast(key_paths.size(), &num_key_files_)) { - NOTREACHED() << "Impossibly large key_paths collection"; - } else if (num_key_files_ != 0) { - key_paths_.reset(new base::FilePath[num_key_files_]); - key_backup_paths_.reset(new base::ScopedTempDir[num_key_files_]); - std::copy(key_paths.begin(), key_paths.end(), &key_paths_[0]); - } -} - -DeleteTreeWorkItem::~DeleteTreeWorkItem() { -} - -// We first try to move key_path_ to backup_path. If it succeeds, we go ahead -// and move the rest. -bool DeleteTreeWorkItem::Do() { - // Go through all the key files and see if we can open them exclusively - // with only the FILE_SHARE_DELETE flag. Once we know we have all of them, - // we can delete them. - std::vector<HANDLE> opened_key_files; - opened_key_files.reserve(num_key_files_); - bool abort = false; - for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { - base::FilePath& key_file = key_paths_[i]; - base::ScopedTempDir& backup = key_backup_paths_[i]; - if (!ignore_failure_) { - if (!backup.CreateUniqueTempDirUnderPath(temp_path_)) { - PLOG(ERROR) << "Could not create temp dir in " << temp_path_.value(); - abort = true; - } else if (!base::CopyFile(key_file, - backup.path().Append(key_file.BaseName()))) { - PLOG(ERROR) << "Could not back up " << key_file.value() - << " to directory " << backup.path().value(); - abort = true; - if (!backup.Delete()) { - PLOG(ERROR) << "Could not clean up temp dir in " - << temp_path_.value(); - } - } - } - if (!abort) { - HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS, - FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, - NULL); - if (file != INVALID_HANDLE_VALUE) { - VLOG(1) << "Acquired exclusive lock for key file: " << key_file.value(); - opened_key_files.push_back(file); - } else { - if (::GetLastError() != ERROR_FILE_NOT_FOUND) - abort = true; - PLOG(INFO) << "Failed to open " << key_file.value(); - } - } - } - - if (!abort) { - // We now hold exclusive locks with "share delete" permissions for each - // of the key files and also have created backups of those files. - // We can safely delete the key files now. - for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { - base::FilePath& key_file = key_paths_[i]; - if (!base::DeleteFile(key_file, true)) { - // This should not really be possible because of the above. - PLOG(DFATAL) << "Unexpectedly could not delete " << key_file.value(); - abort = true; - } - } - } - - std::for_each(opened_key_files.begin(), opened_key_files.end(), CloseHandle); - opened_key_files.clear(); - - if (abort) { - LOG(ERROR) << "Could not exclusively hold all key files."; - return ignore_failure_; - } - - // Now that we've taken care of the key files, take care of the rest. +bool DeleteTreeWorkItem::DoImpl() { if (root_path_.empty() || !base::PathExists(root_path_)) return true; - if (ignore_failure_) { - if (DeleteRoot()) - return true; - // The file cannot be removed, but perhaps it can be moved into - // the temporary backup path. Consumers are responsible for making - // a best-effort attempt to remove the backup path. SelfCleaningTempDir - // is generally used for the backup path, so in the - // worst case the file(s) will be removed after the next reboot. - MoveRootToBackup(); + // If rollback is not enabled, try to delete the root without making a backup. + // When that fails, fall back to moving the root to the temporary backup path. + // Consumers are responsible for making a best-effort attempt to remove the + // backup path. SelfCleaningTempDir is generally used for the backup path, so + // in the worst case the file(s) will be removed after the next reboot. + if (!rollback_enabled() && DeleteRoot()) return true; - } // Attempt to move the root to the backup. return MoveRootToBackup(); } -// If there are files in backup paths move them back. -void DeleteTreeWorkItem::Rollback() { - if (ignore_failure_) - return; - +void DeleteTreeWorkItem::RollbackImpl() { if (moved_to_backup_) { base::FilePath backup = GetBackupPath(); DCHECK(!backup.empty()); if (base::PathExists(backup)) base::Move(backup, root_path_); } - - for (ptrdiff_t i = 0; i != num_key_files_; ++i) { - base::ScopedTempDir& backup_dir = key_backup_paths_[i]; - if (!backup_dir.path().empty()) { - base::FilePath& key_file = key_paths_[i]; - base::FilePath backup_file = - backup_dir.path().Append(key_file.BaseName()); - if (base::PathExists(backup_file) && - !base::Move(backup_file, key_file)) { - // This could happen if we could not delete the key file to begin with. - PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " - << backup_file.value() << " to " << key_file.value(); - } - } - } } base::FilePath DeleteTreeWorkItem::GetBackupPath() {
diff --git a/chrome/installer/util/delete_tree_work_item.h b/chrome/installer/util/delete_tree_work_item.h index 9af8fdf..9a144e89 100644 --- a/chrome/installer/util/delete_tree_work_item.h +++ b/chrome/installer/util/delete_tree_work_item.h
@@ -5,11 +5,6 @@ #ifndef CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ #define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ -#include <stddef.h> - -#include <memory> -#include <vector> - #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "chrome/installer/util/work_item.h" @@ -23,10 +18,6 @@ public: ~DeleteTreeWorkItem() override; - bool Do() override; - - void Rollback() override; - private: friend class WorkItem; @@ -35,8 +26,11 @@ // should be on the same volume; otherwise, the move will be simulated // by a copy-and-delete operation. DeleteTreeWorkItem(const base::FilePath& root_path, - const base::FilePath& temp_path, - const std::vector<base::FilePath>& key_paths); + const base::FilePath& temp_path); + + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; // Return temporary path for work based on |backup_path_| and |root_path_|. base::FilePath GetBackupPath(); @@ -48,28 +42,16 @@ bool MoveRootToBackup(); // Root path to delete. - base::FilePath root_path_; + const base::FilePath root_path_; // Temporary directory that can be used. - base::FilePath temp_path_; - - // The number of key files. - ptrdiff_t num_key_files_; - - // Contains the paths to the key files. If specified, deletion will be - // performed only if none of the key files are in use. - std::unique_ptr<base::FilePath[]> key_paths_; - - // Contains the temp directories for the backed-up key files. The directories - // are created and populated in Do() as-needed. We don't use a standard - // container for this since base::ScopedTempDir isn't CopyConstructible. - std::unique_ptr<base::ScopedTempDir[]> key_backup_paths_; + const base::FilePath temp_path_; // The temporary directory into which the original root_path_ has been moved. base::ScopedTempDir backup_path_; // Set to true once root_path_ has been moved into backup_path_. - bool moved_to_backup_; + bool moved_to_backup_ = false; }; #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_
diff --git a/chrome/installer/util/delete_tree_work_item_unittest.cc b/chrome/installer/util/delete_tree_work_item_unittest.cc index cc7ae2d1..43a456d 100644 --- a/chrome/installer/util/delete_tree_work_item_unittest.cc +++ b/chrome/installer/util/delete_tree_work_item_unittest.cc
@@ -4,230 +4,108 @@ #include "chrome/installer/util/delete_tree_work_item.h" -#include <windows.h> - -#include <fstream> #include <memory> -#include "base/base_paths.h" +#include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/logging.h" -#include "base/strings/string_util.h" +#include "base/macros.h" #include "chrome/installer/util/work_item.h" #include "testing/gtest/include/gtest/gtest.h" namespace { +constexpr char kTextContent[] = "delete me"; + class DeleteTreeWorkItemTest : public testing::Test { protected: - void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } + DeleteTreeWorkItemTest() = default; + + void SetUp() override { + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + + dir_name_ = temp_dir_.path().Append(FILE_PATH_LITERAL("to_be_deleted")); + ASSERT_TRUE(base::CreateDirectory(dir_name_)); + ASSERT_TRUE(base::PathExists(dir_name_)); + + dir_name_1_ = dir_name_.Append(FILE_PATH_LITERAL("1")); + ASSERT_TRUE(base::CreateDirectory(dir_name_1_)); + ASSERT_TRUE(base::PathExists(dir_name_1_)); + + dir_name_2_ = dir_name_.Append(FILE_PATH_LITERAL("2")); + ASSERT_TRUE(base::CreateDirectory(dir_name_2_)); + ASSERT_TRUE(base::PathExists(dir_name_2_)); + + file_name_1_ = dir_name_1_.Append(FILE_PATH_LITERAL("File_1.txt")); + ASSERT_TRUE( + base::WriteFile(file_name_1_, kTextContent, sizeof(kTextContent))); + ASSERT_TRUE(base::PathExists(file_name_1_)); + + file_name_2_ = dir_name_2_.Append(FILE_PATH_LITERAL("File_2.txt")); + ASSERT_TRUE( + base::WriteFile(file_name_2_, kTextContent, sizeof(kTextContent))); + ASSERT_TRUE(base::PathExists(file_name_2_)); + } + + void ExpectAllFilesExist() { + EXPECT_TRUE(base::PathExists(dir_name_)); + EXPECT_TRUE(base::PathExists(dir_name_1_)); + EXPECT_TRUE(base::PathExists(dir_name_2_)); + EXPECT_TRUE(base::PathExists(file_name_1_)); + EXPECT_TRUE(base::PathExists(file_name_2_)); + } + + void ExpectAllFilesDeleted() { + EXPECT_FALSE(base::PathExists(dir_name_)); + EXPECT_FALSE(base::PathExists(dir_name_1_)); + EXPECT_FALSE(base::PathExists(dir_name_2_)); + EXPECT_FALSE(base::PathExists(file_name_1_)); + EXPECT_FALSE(base::PathExists(file_name_2_)); + } // The temporary directory used to contain the test operations. base::ScopedTempDir temp_dir_; + + base::FilePath dir_name_; + base::FilePath dir_name_1_; + base::FilePath dir_name_2_; + base::FilePath file_name_1_; + base::FilePath file_name_2_; + + DISALLOW_COPY_AND_ASSIGN(DeleteTreeWorkItemTest); }; -// Simple function to dump some text into a new file. -void CreateTextFile(const std::wstring& filename, - const std::wstring& contents) { - std::ofstream file; - file.open(filename.c_str()); - ASSERT_TRUE(file.is_open()); - file << contents; - file.close(); -} - -const wchar_t text_content_1[] = L"delete me"; - } // namespace -// Delete a tree without key path. Everything should be deleted. -TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) { - // Create tree to be deleted. - base::FilePath dir_name_delete(temp_dir_.path()); - dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); - base::CreateDirectory(dir_name_delete); - ASSERT_TRUE(base::PathExists(dir_name_delete)); - - base::FilePath dir_name_delete_1(dir_name_delete); - dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); - base::CreateDirectory(dir_name_delete_1); - ASSERT_TRUE(base::PathExists(dir_name_delete_1)); - - base::FilePath dir_name_delete_2(dir_name_delete); - dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); - base::CreateDirectory(dir_name_delete_2); - ASSERT_TRUE(base::PathExists(dir_name_delete_2)); - - base::FilePath file_name_delete_1(dir_name_delete_1); - file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); - CreateTextFile(file_name_delete_1.value(), text_content_1); - ASSERT_TRUE(base::PathExists(file_name_delete_1)); - - base::FilePath file_name_delete_2(dir_name_delete_2); - file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); - CreateTextFile(file_name_delete_2.value(), text_content_1); - ASSERT_TRUE(base::PathExists(file_name_delete_2)); - - // Test Do(). +// Delete a tree with rollback enabled and no file in use. Do() should delete +// everything and Rollback() should bring back everything. +TEST_F(DeleteTreeWorkItemTest, Delete) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - std::vector<base::FilePath> key_files; std::unique_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, temp_dir.path(), - key_files)); - EXPECT_TRUE(work_item->Do()); + WorkItem::CreateDeleteTreeWorkItem(dir_name_, temp_dir.path())); - // everything should be gone - EXPECT_FALSE(base::PathExists(file_name_delete_1)); - EXPECT_FALSE(base::PathExists(file_name_delete_2)); - EXPECT_FALSE(base::PathExists(dir_name_delete)); + EXPECT_TRUE(work_item->Do()); + ExpectAllFilesDeleted(); work_item->Rollback(); - // everything should come back - EXPECT_TRUE(base::PathExists(file_name_delete_1)); - EXPECT_TRUE(base::PathExists(file_name_delete_2)); - EXPECT_TRUE(base::PathExists(dir_name_delete)); + ExpectAllFilesExist(); } - -// Delete a tree with keypath but not in use. Everything should be gone. -// Rollback should bring back everything -TEST_F(DeleteTreeWorkItemTest, DeleteTree) { - // Create tree to be deleted - base::FilePath dir_name_delete(temp_dir_.path()); - dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); - base::CreateDirectory(dir_name_delete); - ASSERT_TRUE(base::PathExists(dir_name_delete)); - - base::FilePath dir_name_delete_1(dir_name_delete); - dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); - base::CreateDirectory(dir_name_delete_1); - ASSERT_TRUE(base::PathExists(dir_name_delete_1)); - - base::FilePath dir_name_delete_2(dir_name_delete); - dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); - base::CreateDirectory(dir_name_delete_2); - ASSERT_TRUE(base::PathExists(dir_name_delete_2)); - - base::FilePath file_name_delete_1(dir_name_delete_1); - file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); - CreateTextFile(file_name_delete_1.value(), text_content_1); - ASSERT_TRUE(base::PathExists(file_name_delete_1)); - - base::FilePath file_name_delete_2(dir_name_delete_2); - file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); - CreateTextFile(file_name_delete_2.value(), text_content_1); - ASSERT_TRUE(base::PathExists(file_name_delete_2)); - - // test Do() +// Delete a tree with rollback disabled and no file in use. Do() should delete +// everything and Rollback() shouldn't bring back anything. +TEST_F(DeleteTreeWorkItemTest, DeleteRollbackDisabled) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - std::vector<base::FilePath> key_files(1, file_name_delete_1); std::unique_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, temp_dir.path(), - key_files)); - EXPECT_TRUE(work_item->Do()); + WorkItem::CreateDeleteTreeWorkItem(dir_name_, temp_dir.path())); + work_item->set_rollback_enabled(false); - // everything should be gone - EXPECT_FALSE(base::PathExists(file_name_delete_1)); - EXPECT_FALSE(base::PathExists(file_name_delete_2)); - EXPECT_FALSE(base::PathExists(dir_name_delete)); + EXPECT_TRUE(work_item->Do()); + ExpectAllFilesDeleted(); work_item->Rollback(); - // everything should come back - EXPECT_TRUE(base::PathExists(file_name_delete_1)); - EXPECT_TRUE(base::PathExists(file_name_delete_2)); - EXPECT_TRUE(base::PathExists(dir_name_delete)); -} - -// Delete a tree with key_path in use. Everything should still be there. -TEST_F(DeleteTreeWorkItemTest, DeleteTreeInUse) { - // Create tree to be deleted - base::FilePath dir_name_delete(temp_dir_.path()); - dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); - base::CreateDirectory(dir_name_delete); - ASSERT_TRUE(base::PathExists(dir_name_delete)); - - base::FilePath dir_name_delete_1(dir_name_delete); - dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); - base::CreateDirectory(dir_name_delete_1); - ASSERT_TRUE(base::PathExists(dir_name_delete_1)); - - base::FilePath dir_name_delete_2(dir_name_delete); - dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); - base::CreateDirectory(dir_name_delete_2); - ASSERT_TRUE(base::PathExists(dir_name_delete_2)); - - base::FilePath file_name_delete_1(dir_name_delete_1); - file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); - CreateTextFile(file_name_delete_1.value(), text_content_1); - ASSERT_TRUE(base::PathExists(file_name_delete_1)); - - base::FilePath file_name_delete_2(dir_name_delete_2); - file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); - CreateTextFile(file_name_delete_2.value(), text_content_1); - ASSERT_TRUE(base::PathExists(file_name_delete_2)); - - // Create a key path file. - base::FilePath key_path(dir_name_delete); - key_path = key_path.AppendASCII("key_file.exe"); - - wchar_t exe_full_path_str[MAX_PATH]; - ::GetModuleFileNameW(NULL, exe_full_path_str, MAX_PATH); - base::FilePath exe_full_path(exe_full_path_str); - - base::CopyFile(exe_full_path, key_path); - ASSERT_TRUE(base::PathExists(key_path)); - - VLOG(1) << "copy ourself from " << exe_full_path.value() - << " to " << key_path.value(); - - // Run the key path file to keep it in use. - STARTUPINFOW si = {sizeof(si)}; - PROCESS_INFORMATION pi = {0}; - base::FilePath::StringType writable_key_path = key_path.value(); - ASSERT_TRUE( - ::CreateProcessW(NULL, &writable_key_path[0], - NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, - NULL, NULL, &si, &pi)); - - // test Do(). - { - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - - std::vector<base::FilePath> key_paths(1, key_path); - std::unique_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, temp_dir.path(), - key_paths)); - - // delete should fail as file in use. - EXPECT_FALSE(work_item->Do()); - } - - { - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - - // No key paths, the deletion should succeed. - std::vector<base::FilePath> key_paths; - std::unique_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, temp_dir.path(), - key_paths)); - - EXPECT_TRUE(work_item->Do()); - work_item->Rollback(); - } - - // verify everything is still there. - EXPECT_TRUE(base::PathExists(key_path)); - EXPECT_TRUE(base::PathExists(file_name_delete_1)); - EXPECT_TRUE(base::PathExists(file_name_delete_2)); - - TerminateProcess(pi.hProcess, 0); - // make sure the handle is closed. - WaitForSingleObject(pi.hProcess, INFINITE); + ExpectAllFilesDeleted(); }
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 8b6dfa7..c5568048 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc
@@ -285,6 +285,9 @@ const base::string16* const launch_cmd, WorkItemList* install_list) { DCHECK(install_list); + DCHECK(install_list->best_effort()); + DCHECK(!install_list->rollback_enabled()); + const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; install_list->AddCreateRegKeyWorkItem(root, state_key, KEY_WOW64_32KEY);
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h index 79b8e2a..da7b379 100644 --- a/chrome/installer/util/install_util.h +++ b/chrome/installer/util/install_util.h
@@ -72,9 +72,9 @@ // This function checks if the current OS is supported for Chromium. static bool IsOSSupported(); - // Adds work items to |install_list|, which should be a - // NoRollbackWorkItemList, to set installer error information in the registry - // for consumption by Google Update. |state_key| must be the full path to an + // Adds work items to |install_list| to set installer error information in the + // registry for consumption by Google Update. |install_list| must be best- + // effort with rollback disabled. |state_key| must be the full path to an // app's ClientState key. See InstallerState::WriteInstallerResult for more // details. static void AddInstallerResultItems(bool system_install,
diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index 56b701d0..d9d9faec 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc
@@ -671,8 +671,10 @@ int string_resource_id, const std::wstring* const launch_cmd) const { // Use a no-rollback list since this is a best-effort deal. - std::unique_ptr<WorkItemList> install_list( - WorkItem::CreateNoRollbackWorkItemList()); + std::unique_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); + install_list->set_log_message("Write Installer Result"); + install_list->set_best_effort(true); + install_list->set_rollback_enabled(false); const bool system_install = this->system_install(); // Write the value for all products upon which we're operating. Products::const_iterator end = products().end(); @@ -688,8 +690,7 @@ system_install, multi_package_binaries_distribution()->GetStateKey(), status, string_resource_id, launch_cmd, install_list.get()); } - if (!install_list->Do()) - LOG(ERROR) << "Failed to record installer error information in registry."; + install_list->Do(); } bool InstallerState::RequiresActiveSetup() const {
diff --git a/chrome/installer/util/move_tree_work_item.cc b/chrome/installer/util/move_tree_work_item.cc index a21db30..ef68234 100644 --- a/chrome/installer/util/move_tree_work_item.cc +++ b/chrome/installer/util/move_tree_work_item.cc
@@ -27,7 +27,7 @@ duplicate_option_(duplicate_option) { } -bool MoveTreeWorkItem::Do() { +bool MoveTreeWorkItem::DoImpl() { if (!base::PathExists(source_path_)) { LOG(ERROR) << source_path_.value() << " does not exist"; return false; @@ -99,7 +99,7 @@ return true; } -void MoveTreeWorkItem::Rollback() { +void MoveTreeWorkItem::RollbackImpl() { if (moved_to_dest_path_ && !base::Move(dest_path_, source_path_)) { PLOG(ERROR) << "Can not move " << dest_path_.value() << " to " << source_path_.value();
diff --git a/chrome/installer/util/move_tree_work_item.h b/chrome/installer/util/move_tree_work_item.h index eea5cda..38383d49 100644 --- a/chrome/installer/util/move_tree_work_item.h +++ b/chrome/installer/util/move_tree_work_item.h
@@ -22,10 +22,6 @@ public: ~MoveTreeWorkItem() override; - bool Do() override; - - void Rollback() override; - private: friend class WorkItem; FRIEND_TEST_ALL_PREFIXES(MoveTreeWorkItemTest, @@ -47,6 +43,10 @@ const base::FilePath& temp_dir, MoveTreeOption duplicate_option); + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Source path to move files from. base::FilePath source_path_;
diff --git a/chrome/installer/util/self_reg_work_item.cc b/chrome/installer/util/self_reg_work_item.cc index 7157d6e..dc7e722 100644 --- a/chrome/installer/util/self_reg_work_item.cc +++ b/chrome/installer/util/self_reg_work_item.cc
@@ -90,15 +90,10 @@ return success; } -bool SelfRegWorkItem::Do() { - bool success = RegisterDll(do_register_); - if (ignore_failure_) - success = true; - return success; +bool SelfRegWorkItem::DoImpl() { + return RegisterDll(do_register_); } -void SelfRegWorkItem::Rollback() { - if (!ignore_failure_) { - RegisterDll(!do_register_); - } +void SelfRegWorkItem::RollbackImpl() { + RegisterDll(!do_register_); }
diff --git a/chrome/installer/util/self_reg_work_item.h b/chrome/installer/util/self_reg_work_item.h index 544621c..5f3a3d4 100644 --- a/chrome/installer/util/self_reg_work_item.h +++ b/chrome/installer/util/self_reg_work_item.h
@@ -15,9 +15,6 @@ public: ~SelfRegWorkItem() override; - bool Do() override; - void Rollback() override; - private: friend class WorkItem; @@ -32,6 +29,10 @@ SelfRegWorkItem(const std::wstring& dll_path, bool do_register, bool user_level_registration); + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Examines the DLL at dll_path looking for either DllRegisterServer (if // do_register is true) or DllUnregisterServer (if do_register is false). // Returns true if the DLL exports the function and it a call to it
diff --git a/chrome/installer/util/set_reg_value_work_item.cc b/chrome/installer/util/set_reg_value_work_item.cc index b134aec..492fa4b 100644 --- a/chrome/installer/util/set_reg_value_work_item.cc +++ b/chrome/installer/util/set_reg_value_work_item.cc
@@ -129,23 +129,17 @@ // Nothing to do, |get_value_callback| will fill |value_| later. } -bool SetRegValueWorkItem::Do() { - LONG result = ERROR_SUCCESS; - base::win::RegKey key; - if (status_ != SET_VALUE) { - // we already did something. - VLOG(1) << "multiple calls to Do()"; - result = ERROR_CANTWRITE; - return ignore_failure_; - } +bool SetRegValueWorkItem::DoImpl() { + DCHECK_EQ(SET_VALUE, status_); status_ = VALUE_UNCHANGED; - result = key.Open(predefined_root_, - key_path_.c_str(), - KEY_READ | KEY_SET_VALUE | wow64_access_); + + base::win::RegKey key; + LONG result = key.Open(predefined_root_, key_path_.c_str(), + KEY_READ | KEY_SET_VALUE | wow64_access_); if (result != ERROR_SUCCESS) { VLOG(1) << "can not open " << key_path_ << " error: " << result; - return ignore_failure_; + return false; } DWORD type = 0; @@ -191,19 +185,16 @@ static_cast<DWORD>(value_.size()), type_); if (result != ERROR_SUCCESS) { VLOG(1) << "Failed to write value " << key_path_ << " error: " << result; - return ignore_failure_; + return false; } status_ = previous_type_ ? VALUE_OVERWRITTEN : NEW_VALUE_CREATED; return true; } -void SetRegValueWorkItem::Rollback() { - if (ignore_failure_) - return; - - if (status_ == SET_VALUE || status_ == VALUE_ROLL_BACK) - return; +void SetRegValueWorkItem::RollbackImpl() { + DCHECK_NE(SET_VALUE, status_); + DCHECK_NE(VALUE_ROLL_BACK, status_); if (status_ == VALUE_UNCHANGED) { status_ = VALUE_ROLL_BACK;
diff --git a/chrome/installer/util/set_reg_value_work_item.h b/chrome/installer/util/set_reg_value_work_item.h index 60104c4e..c8fdc2b 100644 --- a/chrome/installer/util/set_reg_value_work_item.h +++ b/chrome/installer/util/set_reg_value_work_item.h
@@ -49,10 +49,6 @@ ~SetRegValueWorkItem() override; - bool Do() override; - - void Rollback() override; - private: enum SettingStatus { // The status before Do is called. @@ -70,6 +66,10 @@ VALUE_ROLL_BACK }; + // WorkItem: + bool DoImpl() override; + void RollbackImpl() override; + // Root key of the target key under which the value is set. The root key can // only be one of the predefined keys on Windows. HKEY predefined_root_;
diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc index e38413d..988a471 100644 --- a/chrome/installer/util/work_item.cc +++ b/chrome/installer/util/work_item.cc
@@ -6,6 +6,7 @@ #include <windows.h> +#include "base/logging.h" #include "chrome/installer/util/callback_work_item.h" #include "chrome/installer/util/conditional_work_item_list.h" #include "chrome/installer/util/copy_tree_work_item.h" @@ -19,11 +20,8 @@ #include "chrome/installer/util/set_reg_value_work_item.h" #include "chrome/installer/util/work_item_list.h" -WorkItem::WorkItem() : ignore_failure_(false) { -} - -WorkItem::~WorkItem() { -} +WorkItem::WorkItem() = default; +WorkItem::~WorkItem() = default; CallbackWorkItem* WorkItem::CreateCallbackWorkItem( base::Callback<bool(const CallbackWorkItem&)> callback) { @@ -70,9 +68,8 @@ DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem( const base::FilePath& root_path, - const base::FilePath& temp_path, - const std::vector<base::FilePath>& key_paths) { - return new DeleteTreeWorkItem(root_path, temp_path, key_paths); + const base::FilePath& temp_path) { + return new DeleteTreeWorkItem(root_path, temp_path); } MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem( @@ -154,11 +151,30 @@ return new WorkItemList(); } -// static -WorkItemList* WorkItem::CreateNoRollbackWorkItemList() { - return new NoRollbackWorkItemList(); -} - WorkItemList* WorkItem::CreateConditionalWorkItemList(Condition* condition) { return new ConditionalWorkItemList(condition); } + +bool WorkItem::Do() { + DCHECK_EQ(BEFORE_DO, state_); + const bool success = DoImpl(); + state_ = AFTER_DO; + return best_effort() ? true : success; +} + +void WorkItem::Rollback() { + DCHECK_EQ(AFTER_DO, state_); + if (rollback_enabled()) + RollbackImpl(); + state_ = AFTER_ROLLBACK; +} + +void WorkItem::set_best_effort(bool best_effort) { + DCHECK_EQ(BEFORE_DO, state()); + best_effort_ = best_effort; +} + +void WorkItem::set_rollback_enabled(bool rollback_enabled) { + DCHECK_EQ(BEFORE_DO, state()); + rollback_enabled_ = rollback_enabled; +}
diff --git a/chrome/installer/util/work_item.h b/chrome/installer/util/work_item.h index 446b491..e28bedf 100644 --- a/chrome/installer/util/work_item.h +++ b/chrome/installer/util/work_item.h
@@ -35,6 +35,22 @@ // A base class that defines APIs to perform/rollback an action or a // sequence of actions during install/update/uninstall. +// +// Subclasses must implement DoImpl() and RollbackImpl(). +// +// Do() calls DoImpl(). When the "best-effort" flag is true, it always returns +// true. Otherwise, it returns the value returned by DoImpl(). Implementations +// of DoImpl() may use the "best-effort" flag as an indication that they should +// do as much work as possible (i.e., shouldn't abort as soon as one of the +// actions they have to perform fails). By default, the "best-effort" flag is +// false. +// +// Rollback() calls RollbackImpl() when the "rollback enabled" flag is true. +// Otherwise, it's a no-op. Implementations of DoImpl() may read the "rollback +// enabled" flag to determine whether they should save state to support +// rollback. By default, the "rollback enabled" flag is true. +// +// The "best-effort" and "rollback enabled" must be set before Do() is invoked. class WorkItem { public: // A callback that returns the desired value based on the |existing_value|. @@ -119,12 +135,10 @@ const std::wstring& value_name); // Create a DeleteTreeWorkItem that recursively deletes a file system - // hierarchy at the given root path. A key file can be optionally specified - // by key_path. + // hierarchy at the given root path. static DeleteTreeWorkItem* CreateDeleteTreeWorkItem( const base::FilePath& root_path, - const base::FilePath& temp_path, - const std::vector<base::FilePath>& key_paths); + const base::FilePath& temp_path); // Create a MoveTreeWorkItem that recursively moves a file system hierarchy // from source path to destination path. @@ -184,38 +198,24 @@ // a list of WorkItems. static WorkItemList* CreateWorkItemList(); - // Create an empty WorkItemList that cannot be rolled back. - // Such a work item list executes all items on a best effort basis and does - // not abort execution if an item in the list fails. - static WorkItemList* CreateNoRollbackWorkItemList(); - // Create a conditional work item list that will execute only if // condition->ShouldRun() returns true. The WorkItemList instance // assumes ownership of condition. static WorkItemList* CreateConditionalWorkItemList(Condition* condition); - // Perform the actions of WorkItem. Returns true if success, returns false - // otherwise. - // If the WorkItem is transactional, then Do() is done as a transaction. - // If it returns false, there will be no change on the system. - virtual bool Do() = 0; + // Perform the actions of WorkItem. Returns true if success or if + // best_effort(). Can only be called once per instance. + bool Do(); - // Rollback any actions previously carried out by this WorkItem. If the - // WorkItem is transactional, then the previous actions can be fully - // rolled back. If the WorkItem is non-transactional, the rollback is a - // best effort. - virtual void Rollback() = 0; + // Rollback any actions previously carried out by this WorkItem if + // rollback_enabled(). Can only be called once per instance, after Do() has + // returned. + void Rollback(); - // If called with true, this WorkItem may return true from its Do() method - // even on failure and Rollback will have no effect. - void set_ignore_failure(bool ignore_failure) { - ignore_failure_ = ignore_failure; - } - - // Returns true if this WorkItem should ignore failures. - bool ignore_failure() const { - return ignore_failure_; - } + void set_best_effort(bool best_effort); + bool best_effort() const { return best_effort_; } + void set_rollback_enabled(bool rollback_enabled); + bool rollback_enabled() const { return rollback_enabled_; } // Sets an optional log message that a work item may use to print additional // instance-specific information. @@ -227,13 +227,30 @@ const std::string& log_message() const { return log_message_; } protected: + enum State { + BEFORE_DO, + AFTER_DO, + AFTER_ROLLBACK, + }; + WorkItem(); - // Specifies whether this work item my fail to complete and yet still - // return true from Do(). - bool ignore_failure_; + State state() const { return state_; } std::string log_message_; + + private: + // Called by Do(). Performs the actions of the Workitem. + virtual bool DoImpl() = 0; + + // Called by Rollback() if rollback_enabled() is true. Rollbacks the actions + // performed by DoImpl(). Implementations must support invocation of this even + // when DoImpl() returned false. + virtual void RollbackImpl() = 0; + + State state_ = BEFORE_DO; + bool best_effort_ = false; + bool rollback_enabled_ = true; }; #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_H_
diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc index 6099330..58489dd 100644 --- a/chrome/installer/util/work_item_list.cc +++ b/chrome/installer/util/work_item_list.cc
@@ -28,19 +28,22 @@ } } -WorkItemList::WorkItemList() - : status_(ADD_ITEM) { -} +WorkItemList::WorkItemList() = default; -bool WorkItemList::Do() { - if (status_ != ADD_ITEM) - return false; +bool WorkItemList::DoImpl() { + VLOG(1) << "Beginning execution of work item list " << log_message(); bool result = true; while (!list_.empty()) { WorkItem* work_item = list_.front(); list_.pop_front(); executed_list_.push_front(work_item); + + if (best_effort()) + work_item->set_best_effort(true); + if (!rollback_enabled()) + work_item->set_rollback_enabled(false); + if (!work_item->Do()) { LOG(ERROR) << "item execution failed " << work_item->log_message(); result = false; @@ -49,27 +52,22 @@ } if (result) - VLOG(1) << "list execution succeeded"; + VLOG(1) << "Successful execution of work item list " << log_message(); + else + LOG(ERROR) << "Failed execution of work item list " << log_message(); - status_ = LIST_EXECUTED; return result; } -void WorkItemList::Rollback() { - if (status_ != LIST_EXECUTED) - return; - +void WorkItemList::RollbackImpl() { for (WorkItemIterator itr = executed_list_.begin(); itr != executed_list_.end(); ++itr) { (*itr)->Rollback(); } - - status_ = LIST_ROLLED_BACK; - return; } void WorkItemList::AddWorkItem(WorkItem* work_item) { - DCHECK(status_ == ADD_ITEM); + DCHECK_EQ(BEFORE_DO, state()); list_.push_back(work_item); } @@ -131,20 +129,11 @@ return item; } -WorkItem* WorkItemList::AddDeleteTreeWorkItem( - const base::FilePath& root_path, - const base::FilePath& temp_path, - const std::vector<base::FilePath>& key_paths) { - WorkItem* item = WorkItem::CreateDeleteTreeWorkItem(root_path, temp_path, - key_paths); - AddWorkItem(item); - return item; -} - WorkItem* WorkItemList::AddDeleteTreeWorkItem(const base::FilePath& root_path, const base::FilePath& temp_path) { - std::vector<base::FilePath> no_key_files; - return AddDeleteTreeWorkItem(root_path, temp_path, no_key_files); + WorkItem* item = WorkItem::CreateDeleteTreeWorkItem(root_path, temp_path); + AddWorkItem(item); + return item; } WorkItem* WorkItemList::AddMoveTreeWorkItem(const std::wstring& source_path, @@ -231,35 +220,3 @@ AddWorkItem(item); return item; } - -//////////////////////////////////////////////////////////////////////////////// -NoRollbackWorkItemList::~NoRollbackWorkItemList() { -} - -bool NoRollbackWorkItemList::Do() { - if (status_ != ADD_ITEM) - return false; - - bool result = true; - while (!list_.empty()) { - WorkItem* work_item = list_.front(); - list_.pop_front(); - executed_list_.push_front(work_item); - work_item->set_ignore_failure(true); - if (!work_item->Do()) { - LOG(ERROR) << "NoRollbackWorkItemList: item execution failed " - << work_item->log_message(); - result = false; - } - } - - if (result) - VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; - - status_ = LIST_EXECUTED; - return result; -} - -void NoRollbackWorkItemList::Rollback() { - // Ignore rollback. -}
diff --git a/chrome/installer/util/work_item_list.h b/chrome/installer/util/work_item_list.h index 983ad0c5..8141e7f 100644 --- a/chrome/installer/util/work_item_list.h +++ b/chrome/installer/util/work_item_list.h
@@ -24,17 +24,13 @@ // provides functionalities to carry out or roll back the sequence of actions // defined by the list of WorkItems it contains. // The WorkItems are executed in the same order as they are added to the list. +// The "best-effort" flag of the WorkItemList is propagated to the WorkItems +// when it's true. Likewise, the "rollback enabled" flag of the WorkItemList is +// propagated to the WorkItems when it's false. class WorkItemList : public WorkItem { public: ~WorkItemList() override; - // Execute the WorkItems in the same order as they are added to the list. - // It aborts as soon as one WorkItem fails. - bool Do() override; - - // Rollback the WorkItems in the reverse order as they are executed. - void Rollback() override; - // Add a WorkItem to the list. // A WorkItem can only be added to the list before the list's DO() is called. // Once a WorkItem is added to the list. The list owns the WorkItem. @@ -76,15 +72,8 @@ REGSAM wow64_access, const std::wstring& value_name); - // Add a DeleteTreeWorkItem that recursively deletes a file system - // hierarchy at the given root path. A key file can be optionally specified - // by key_path. - virtual WorkItem* AddDeleteTreeWorkItem( - const base::FilePath& root_path, - const base::FilePath& temp_path, - const std::vector<base::FilePath>& key_paths); - - // Same as above but without support for key files. + // Add a DeleteTreeWorkItem that recursively deletes a file system hierarchy + // at the given root path. virtual WorkItem* AddDeleteTreeWorkItem(const base::FilePath& root_path, const base::FilePath& temp_path); @@ -144,18 +133,16 @@ typedef std::list<WorkItem*> WorkItems; typedef WorkItems::iterator WorkItemIterator; - enum ListStatus { - // List has not been executed. Ok to add new WorkItem. - ADD_ITEM, - // List has been executed. Can not add new WorkItem. - LIST_EXECUTED, - // List has been executed and rolled back. No further action is acceptable. - LIST_ROLLED_BACK - }; - WorkItemList(); - ListStatus status_; + // WorkItem: + + // Execute the WorkItems in the same order as they are added to the list. It + // aborts as soon as one WorkItem fails, unless the best-effort flag is true. + bool DoImpl() override; + + // Rollback the WorkItems in the reverse order as they are executed. + void RollbackImpl() override; // The list of WorkItems, in the order of them being added. WorkItems list_; @@ -165,21 +152,4 @@ WorkItems executed_list_; }; -// A specialization of WorkItemList that executes items in the list on a -// best-effort basis. Failure of individual items to execute does not prevent -// subsequent items from being executed. -// Also, as the class name suggests, Rollback is not possible. -class NoRollbackWorkItemList : public WorkItemList { - public: - ~NoRollbackWorkItemList() override; - - // Execute the WorkItems in the same order as they are added to the list. - // If a WorkItem fails, the function will return failure but all other - // WorkItems will still be executed. - bool Do() override; - - // No-op. - void Rollback() override; -}; - #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_
diff --git a/chrome/installer/util/work_item_list_unittest.cc b/chrome/installer/util/work_item_list_unittest.cc index 2d028eb..d09071b 100644 --- a/chrome/installer/util/work_item_list_unittest.cc +++ b/chrome/installer/util/work_item_list_unittest.cc
@@ -28,12 +28,12 @@ // Expect all three items to be done in order then undone. InSequence s; - EXPECT_CALL(*item1, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item2, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item3, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item3, Rollback()); - EXPECT_CALL(*item2, Rollback()); - EXPECT_CALL(*item1, Rollback()); + EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item3, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item3, RollbackImpl()); + EXPECT_CALL(*item2, RollbackImpl()); + EXPECT_CALL(*item1, RollbackImpl()); } // Add the items to the list. @@ -59,10 +59,10 @@ // Expect the two first work items to be done in order then undone. InSequence s; - EXPECT_CALL(*item1, Do()).WillOnce(Return(true)); - EXPECT_CALL(*item2, Do()).WillOnce(Return(false)); - EXPECT_CALL(*item2, Rollback()); - EXPECT_CALL(*item1, Rollback()); + EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(false)); + EXPECT_CALL(*item2, RollbackImpl()); + EXPECT_CALL(*item1, RollbackImpl()); } // Add the items to the list.
diff --git a/chrome/installer/util/work_item_mocks.h b/chrome/installer/util/work_item_mocks.h index 37c9a6a..79ea6f1e 100644 --- a/chrome/installer/util/work_item_mocks.h +++ b/chrome/installer/util/work_item_mocks.h
@@ -15,8 +15,8 @@ MockWorkItem(); ~MockWorkItem(); - MOCK_METHOD0(Do, bool()); - MOCK_METHOD0(Rollback, void()); + MOCK_METHOD0(DoImpl, bool()); + MOCK_METHOD0(RollbackImpl, void()); private: DISALLOW_COPY_AND_ASSIGN(MockWorkItem);
diff --git a/chrome/installer/util/work_item_unittest.cc b/chrome/installer/util/work_item_unittest.cc new file mode 100644 index 0000000..ac1789e --- /dev/null +++ b/chrome/installer/util/work_item_unittest.cc
@@ -0,0 +1,104 @@ +// 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/installer/util/work_item.h" + +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class MockWorkItem : public WorkItem { + public: + MOCK_METHOD0(DoImpl, bool()); + MOCK_METHOD0(RollbackImpl, void()); +}; + +using StrictMockWorkItem = testing::StrictMock<MockWorkItem>; +using testing::Return; + +} // namespace + +// Verify that Do() calls DoImpl() and returns its return value for a +// non-best-effort WorkItem. +TEST(WorkItemTest, Do) { + { + StrictMockWorkItem item_success; + item_success.set_best_effort(false); + EXPECT_CALL(item_success, DoImpl()).WillOnce(Return(true)); + EXPECT_TRUE(item_success.Do()); + } + + { + StrictMockWorkItem item_failure; + item_failure.set_best_effort(false); + EXPECT_CALL(item_failure, DoImpl()).WillOnce(Return(false)); + EXPECT_FALSE(item_failure.Do()); + } +} + +// Verify that Do() calls DoImpl() and returns true for a best-effort WorkItem. +TEST(WorkItemTest, DoBestEffort) { + { + StrictMockWorkItem item_success; + item_success.set_best_effort(true); + EXPECT_CALL(item_success, DoImpl()).WillOnce(Return(true)); + EXPECT_TRUE(item_success.Do()); + } + + { + StrictMockWorkItem item_failure; + item_failure.set_best_effort(true); + EXPECT_CALL(item_failure, DoImpl()).WillOnce(Return(false)); + EXPECT_TRUE(item_failure.Do()); + testing::Mock::VerifyAndClearExpectations(&item_failure); + } +} + +// Verify that Rollback() calls RollbackImpl() for a WorkItem with rollback +// enabled. +TEST(WorkItemTest, Rollback) { + StrictMockWorkItem item; + item.set_rollback_enabled(true); + EXPECT_TRUE(item.rollback_enabled()); + + { + testing::InSequence s; + EXPECT_CALL(item, DoImpl()).WillOnce(Return(true)); + EXPECT_CALL(item, RollbackImpl()); + } + + item.Do(); + item.Rollback(); +} + +// Verify that Rollback() doesn't call RollbackImpl() for a WorkItem with +// rollback disabled. +TEST(WorkItemTest, RollbackNotAllowed) { + StrictMockWorkItem item; + item.set_rollback_enabled(false); + + EXPECT_CALL(item, DoImpl()).WillOnce(Return(true)); + + item.Do(); + item.Rollback(); +} + +// Verify that the default value of the "best-effort" flag is false and that the +// setter works. +TEST(WorkItemTest, BestEffortDefaultValueAndSetter) { + MockWorkItem work_item; + EXPECT_FALSE(work_item.best_effort()); + work_item.set_best_effort(true); + EXPECT_TRUE(work_item.best_effort()); +} + +// Verify that the default value of the "enable rollback" flag is true and that +// the setter works. +TEST(WorkItemTest, EnableRollbackDefaultValueAndSetter) { + MockWorkItem work_item; + EXPECT_TRUE(work_item.rollback_enabled()); + work_item.set_rollback_enabled(false); + EXPECT_FALSE(work_item.rollback_enabled()); +}
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 3bbf49e..a1a4f74 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -1351,11 +1351,6 @@ "//chrome") } if (enable_pepper_cdms) { - sources += [ - "../browser/media/pepper_cdm_test_helper.cc", - "../browser/media/pepper_cdm_test_helper.h", - ] - # Runtime dependencies. data_deps += [ "//media/cdm/ppapi:clearkeycdmadapter",
diff --git a/chrome/tools/build/mac/run_verify_order.py b/chrome/tools/build/mac/run_verify_order.py new file mode 100644 index 0000000..70802464 --- /dev/null +++ b/chrome/tools/build/mac/run_verify_order.py
@@ -0,0 +1,30 @@ +# 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 argparse +import os.path +import sys +import subprocess + +# Wraps chrome/tools/build/mac/verify_order for the GN build so that it can +# write a stamp file, rather than operate as a postbuild. + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='A wrapper around verify_order that writes a stamp file.') + parser.add_argument('--stamp', action='store', type=str, + help='Touch this stamp file on success.') + + args, unknown_args = parser.parse_known_args() + + this_script_dir = os.path.dirname(sys.argv[0]) + rv = subprocess.check_call( + [ os.path.join(this_script_dir, 'verify_order') ] + unknown_args) + + if rv == 0 and args.stamp: + if os.path.exists(args.stamp): + os.unlink(args.stamp) + open(args.stamp, 'w+').close() + + sys.exit(rv)
diff --git a/chrome/tools/build/win/resedit.py b/chrome/tools/build/win/resedit.py index bc1eb62..e0971cf 100755 --- a/chrome/tools/build/win/resedit.py +++ b/chrome/tools/build/win/resedit.py
@@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# 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. @@ -204,22 +204,28 @@ def UpdateResource(self, res_type, res_lang, res_name, file_path): """Inserts or updates a given resource with the contents of a file. + This is a legacy version of UpdateResourceData, where the data arg is read + from a file , rather than passed directly. + """ + _LOGGER.info('Writing resource from file %s', file_path) + with open(file_path, 'rb') as f: + self.UpdateResourceData(res_type, res_lang, res_name, f.read()) + + def UpdateResourceData(self, res_type, res_lang, res_name, data): + """Inserts or updates a given resource with the given data. + Args: res_type: the type of the resource, e.g. "B7". res_lang: the language id of the resource, e.g. 1033. res_name: the name of the resource, e.g. "SETUP.EXE". - file_path: path to the file containing the new resource data. + data: the new resource data. """ - _LOGGER.info('Writing resource "%s:%s" from file %s.', - res_type, res_name, file_path) - - with open(file_path, 'rb') as f: - win32api.UpdateResource(self.update_handle, - res_type, - res_name, - f.read(), - res_lang); - + _LOGGER.info('Writing resource "%s:%s"', res_type, res_name) + win32api.UpdateResource(self.update_handle, + res_type, + res_name, + data, + res_lang) self._modified = True def Commit(self): @@ -256,29 +262,29 @@ %prog mini_installer.exe \\ --remove BL 1033 SETUP.EXE \\ --update B7 1033 SETUP.EXE.packed.7z setup.packed.7z \\ - --output-file mini_installer_packed.exe + --output_file mini_installer_packed.exe """ def _ParseArgs(): parser = optparse.OptionParser(_USAGE) - parser.add_option('', '--verbose', action='store_true', + parser.add_option('--verbose', action='store_true', help='Enable verbose logging.') - parser.add_option('', '--extract_all', + parser.add_option('--extract_all', help='Path to a folder which will be created, in which all resources ' 'from the input_file will be stored, each in a file named ' '"res_type/lang_id/res_name".') - parser.add_option('', '--extract', action='append', default=[], nargs=4, + parser.add_option('--extract', action='append', default=[], nargs=4, help='Extract the resource with the given type, language id and name ' 'to the given file.', metavar='type langid name file_path') - parser.add_option('', '--remove', action='append', default=[], nargs=3, + parser.add_option('--remove', action='append', default=[], nargs=3, help='Remove the resource with the given type, langid and name.', metavar='type langid name') - parser.add_option('', '--update', action='append', default=[], nargs=4, + parser.add_option('--update', action='append', default=[], nargs=4, help='Insert or update the resource with the given type, langid and ' 'name with the contents of the file given.', metavar='type langid name file_path') - parser.add_option('', '--output_file', + parser.add_option('--output_file', help='On success, OUTPUT_FILE will be written with a copy of the ' 'input file with the edits specified by any remove or update ' 'options.') @@ -295,6 +301,17 @@ return options, args +def _ConvertInts(*args): + """Return args with any all-digit strings converted to ints.""" + results = [] + for arg in args: + if isinstance(arg, basestring) and arg.isdigit(): + results.append(int(arg)) + else: + results.append(arg) + return results + + def main(options, args): """Main program for the script.""" if options.verbose: @@ -307,13 +324,16 @@ editor.ExtractAllToDir(options.extract_all) for res_type, res_lang, res_name, dest_file in options.extract: - editor.ExtractResource(res_type, int(res_lang), res_name, dest_file) + res_type, res_lang, res_name = _ConvertInts(res_type, res_lang, res_name) + editor.ExtractResource(res_type, res_lang, res_name, dest_file) for res_type, res_lang, res_name in options.remove: - editor.RemoveResource(res_type, int(res_lang), res_name) + res_type, res_lang, res_name = _ConvertInts(res_type, res_lang, res_name) + editor.RemoveResource(res_type, res_lang, res_name) for res_type, res_lang, res_name, src_file in options.update: - editor.UpdateResource(res_type, int(res_lang), res_name, src_file) + res_type, res_lang, res_name = _ConvertInts(res_type, res_lang, res_name) + editor.UpdateResource(res_type, res_lang, res_name, src_file) if editor.modified: editor.Commit()
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc index 5110d26..85aa43e 100644 --- a/chrome/utility/chrome_content_utility_client.cc +++ b/chrome/utility/chrome_content_utility_client.cc
@@ -24,7 +24,7 @@ #include "content/public/common/service_registry.h" #include "content/public/utility/utility_thread.h" #include "courgette/courgette.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include "ipc/ipc_channel.h" #include "third_party/zlib/google/zip.h" #include "ui/gfx/geometry/size.h"
diff --git a/components/BUILD.gn b/components/BUILD.gn index 9efab1e..40715d6b 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn
@@ -167,6 +167,7 @@ "//components/cast_certificate:unit_tests", "//components/certificate_transparency:unit_tests", "//components/crash/content/app:unit_tests", + "//components/crash/core/common:unit_tests", "//components/data_reduction_proxy/content/browser:unit_tests", "//components/data_use_measurement/content:unit_tests", "//components/devtools_http_handler:unit_tests",
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/UploadDataProvidersTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/UploadDataProvidersTest.java index 1d6d923f..fa7a540 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/UploadDataProvidersTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/UploadDataProvidersTest.java
@@ -224,6 +224,7 @@ System.arraycopy(uploadData, 0, uploadDataWithPadding, offset, uploadData.length); UploadDataProvider dataProvider = UploadDataProviders.create(uploadDataWithPadding, offset, uploadData.length); + assertEquals(uploadData.length, dataProvider.getLength()); builder.setUploadDataProvider(dataProvider, callback.getExecutor()); UrlRequest urlRequest = builder.build(); urlRequest.start();
diff --git a/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationClientService.java b/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationClientService.java index a92d3cc..c8f2a101 100644 --- a/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationClientService.java +++ b/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationClientService.java
@@ -222,7 +222,7 @@ @Override public void writeState(byte[] data) { - InvalidationPreferences invPreferences = new InvalidationPreferences(this); + InvalidationPreferences invPreferences = new InvalidationPreferences(); EditContext editContext = invPreferences.edit(); invPreferences.setInternalNotificationClientState(editContext, data); invPreferences.commit(editContext); @@ -230,7 +230,7 @@ @Override @Nullable public byte[] readState() { - return new InvalidationPreferences(this).getInternalNotificationClientState(); + return new InvalidationPreferences().getInternalNotificationClientState(); } /** @@ -256,7 +256,7 @@ if (intendedAccount == null) { return; } - InvalidationPreferences invPrefs = new InvalidationPreferences(this); + InvalidationPreferences invPrefs = new InvalidationPreferences(); if (!intendedAccount.equals(invPrefs.getSavedSyncedAccount())) { if (sIsClientStarted) { stopClient(); @@ -286,7 +286,7 @@ /** Sets the saved sync account in {@link InvalidationPreferences} to {@code owningAccount}. */ private void setAccount(Account owningAccount) { - InvalidationPreferences invPrefs = new InvalidationPreferences(this); + InvalidationPreferences invPrefs = new InvalidationPreferences(); EditContext editContext = invPrefs.edit(); invPrefs.setAccount(editContext, owningAccount); invPrefs.commit(editContext); @@ -297,7 +297,7 @@ * corresponding object ids. */ private Set<ObjectId> readSyncRegistrationsFromPrefs() { - Set<String> savedTypes = new InvalidationPreferences(this).getSavedSyncedTypes(); + Set<String> savedTypes = new InvalidationPreferences().getSavedSyncedTypes(); if (savedTypes == null) return Collections.emptySet(); return ModelTypeHelper.notificationTypesToObjectIds(savedTypes); } @@ -307,7 +307,7 @@ * corresponding object ids. */ private Set<ObjectId> readNonSyncRegistrationsFromPrefs() { - Set<ObjectId> objectIds = new InvalidationPreferences(this).getSavedObjectIds(); + Set<ObjectId> objectIds = new InvalidationPreferences().getSavedObjectIds(); if (objectIds == null) return Collections.emptySet(); return objectIds; } @@ -359,7 +359,7 @@ ? null : readNonSyncRegistrationsFromPrefs(); // Write the new sync types/object ids to preferences. - InvalidationPreferences prefs = new InvalidationPreferences(this); + InvalidationPreferences prefs = new InvalidationPreferences(); EditContext editContext = prefs.edit(); if (syncTypes != null) { prefs.setSyncTypes(editContext, syncTypes);
diff --git a/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationService.java b/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationService.java index 74557c0..fb4289f 100644 --- a/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationService.java +++ b/components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationService.java
@@ -65,7 +65,7 @@ @VisibleForTesting @CalledByNative public void setRegisteredObjectIds(int[] objectSources, String[] objectNames) { - InvalidationPreferences invalidationPreferences = new InvalidationPreferences(mContext); + InvalidationPreferences invalidationPreferences = new InvalidationPreferences(); Account account = invalidationPreferences.getSavedSyncedAccount(); Intent registerIntent = InvalidationIntentProtocol.createRegisterIntent( account, objectSources, objectNames);
diff --git a/components/invalidation/impl/android/javatests/src/org/chromium/components/invalidation/InvalidationClientServiceTest.java b/components/invalidation/impl/android/javatests/src/org/chromium/components/invalidation/InvalidationClientServiceTest.java index cc376b4..a3853ae 100644 --- a/components/invalidation/impl/android/javatests/src/org/chromium/components/invalidation/InvalidationClientServiceTest.java +++ b/components/invalidation/impl/android/javatests/src/org/chromium/components/invalidation/InvalidationClientServiceTest.java
@@ -142,7 +142,7 @@ */ // Persist some registrations. - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); EditContext editContext = invPrefs.edit(); invPrefs.setSyncTypes(editContext, CollectionUtil.newArrayList("BOOKMARK", "SESSION")); ObjectId objectId = ObjectId.newInstance(1, "obj".getBytes()); @@ -177,7 +177,7 @@ assertTrue(getService().mRegistrations.isEmpty()); // Persist some registrations. - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); EditContext editContext = invPrefs.edit(); invPrefs.setSyncTypes(editContext, CollectionUtil.newArrayList("BOOKMARK", "SESSION")); ObjectId objectId = ObjectId.newInstance(1, "obj".getBytes()); @@ -205,7 +205,7 @@ * 4. Unregistration of desired object. Registration issued. */ // Initial test setup: persist a single registration into preferences. - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); EditContext editContext = invPrefs.edit(); invPrefs.setSyncTypes(editContext, CollectionUtil.newArrayList("SESSION")); ObjectId desiredObjectId = ObjectId.newInstance(1, "obj1".getBytes()); @@ -266,7 +266,7 @@ */ // Initial test setup: persist a single registration into preferences. - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); EditContext editContext = invPrefs.edit(); invPrefs.setSyncTypes(editContext, CollectionUtil.newArrayList("SESSION")); ObjectId desiredObjectId = ObjectId.newInstance(1, "obj1".getBytes()); @@ -536,7 +536,7 @@ // Verify client started and state written. assertTrue(InvalidationClientService.getIsClientStartedForTest()); - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); assertEquals(account, invPrefs.getSavedSyncedAccount()); assertEquals(modelTypesToNotificationTypes(desiredRegistrations), invPrefs.getSavedSyncedTypes()); @@ -576,7 +576,7 @@ Set<ObjectId> expectedObjectIds, boolean isReady) { // Get synced types saved to preferences. Set<String> expectedSyncTypes = modelTypesToNotificationTypes(expectedTypes); - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); Set<String> actualSyncTypes = invPrefs.getSavedSyncedTypes(); if (actualSyncTypes == null) { actualSyncTypes = new HashSet<String>(); @@ -688,7 +688,7 @@ // Verify client started and state written. assertTrue(InvalidationClientService.getIsClientStartedForTest()); - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); assertEquals(account, invPrefs.getSavedSyncedAccount()); assertEquals( CollectionUtil.newHashSet("PROXY_TABS", "SESSION"), invPrefs.getSavedSyncedTypes()); @@ -719,7 +719,7 @@ // Verify client started and state written. assertTrue(InvalidationClientService.getIsClientStartedForTest()); - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); assertEquals(account, invPrefs.getSavedSyncedAccount()); assertEquals(new HashSet<String>(), invPrefs.getSavedSyncedTypes()); assertEquals(1, mStartServiceIntents.size()); @@ -759,7 +759,7 @@ // Verify state written but client not started. assertFalse(InvalidationClientService.getIsClientStartedForTest()); - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); assertEquals(account, invPrefs.getSavedSyncedAccount()); assertEquals(modelTypesToNotificationTypes(desiredRegistrations), invPrefs.getSavedSyncedTypes()); @@ -788,7 +788,7 @@ assertTrue(InvalidationClientService.getIsClientStartedForTest()); assertEquals(1, mStartServiceIntents.size()); assertTrue(isAndroidListenerStartIntent(mStartServiceIntents.get(0))); - InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); + InvalidationPreferences invPrefs = new InvalidationPreferences(); assertEquals(modelTypesToNotificationTypes(desiredRegistrations), invPrefs.getSavedSyncedTypes()); assertEquals(desiredObjectIds, getService().readRegistrationsFromPrefs());
diff --git a/components/mus/surfaces/surfaces_state.cc b/components/mus/surfaces/surfaces_state.cc index 51b7358..e3dfeb8 100644 --- a/components/mus/surfaces/surfaces_state.cc +++ b/components/mus/surfaces/surfaces_state.cc
@@ -6,8 +6,7 @@ namespace mus { -SurfacesState::SurfacesState() - : next_id_namespace_(1u), hit_tester_(nullptr, &manager_) {} +SurfacesState::SurfacesState() : next_id_namespace_(1u) {} SurfacesState::~SurfacesState() {}
diff --git a/components/mus/surfaces/surfaces_state.h b/components/mus/surfaces/surfaces_state.h index f7e2368b..daaf558 100644 --- a/components/mus/surfaces/surfaces_state.h +++ b/components/mus/surfaces/surfaces_state.h
@@ -9,7 +9,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "cc/surfaces/surface_hittest.h" #include "cc/surfaces/surface_manager.h" namespace cc { @@ -32,8 +31,6 @@ cc::SurfaceManager* manager() { return &manager_; } - cc::SurfaceHittest* hit_tester() { return &hit_tester_; } - private: friend class base::RefCounted<SurfacesState>; ~SurfacesState(); @@ -43,7 +40,6 @@ // that requested the Surface. uint32_t next_id_namespace_; cc::SurfaceManager manager_; - cc::SurfaceHittest hit_tester_; DISALLOW_COPY_AND_ASSIGN(SurfacesState); };
diff --git a/components/mus/ws/display.cc b/components/mus/ws/display.cc index 98531a1..8a745a6 100644 --- a/components/mus/ws/display.cc +++ b/components/mus/ws/display.cc
@@ -236,8 +236,8 @@ display_manager()->OnDisplayAcceleratedWidgetAvailable(this); if (binding_) { - std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState( - this, platform_display_.get(), top_level_surface_id_)); + std::unique_ptr<WindowManagerState> wms_ptr( + new WindowManagerState(this, platform_display_.get())); WindowManagerState* wms = wms_ptr.get(); // For this case we never create additional WindowManagerStates, so any // id works. @@ -259,9 +259,8 @@ void Display::CreateWindowManagerStateFromService( WindowManagerFactoryService* service) { - std::unique_ptr<WindowManagerState> wms_ptr( - new WindowManagerState(this, platform_display_.get(), - top_level_surface_id_, service->user_id())); + std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState( + this, platform_display_.get(), service->user_id())); WindowManagerState* wms = wms_ptr.get(); window_manager_state_map_[service->user_id()] = std::move(wms_ptr); wms->tree_ = window_server_->CreateTreeForWindowManager( @@ -316,12 +315,6 @@ window_server_->ProcessViewportMetricsChanged(this, old_metrics, new_metrics); } -void Display::OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) { - DCHECK(!root_); - // This should only be called once, and before we've created root_. - top_level_surface_id_ = surface_id; -} - void Display::OnCompositorFrameDrawn() { std::set<ServerWindow*> windows; windows.swap(windows_needing_frame_destruction_);
diff --git a/components/mus/ws/display.h b/components/mus/ws/display.h index 869ed24..e81937f 100644 --- a/components/mus/ws/display.h +++ b/components/mus/ws/display.h
@@ -165,7 +165,6 @@ void OnViewportMetricsChanged( const mojom::ViewportMetrics& old_metrics, const mojom::ViewportMetrics& new_metrics) override; - void OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) override; void OnCompositorFrameDrawn() override; // FocusControllerDelegate: @@ -210,8 +209,6 @@ WindowManagerStateMap window_manager_state_map_; - cc::SurfaceId top_level_surface_id_; - DISALLOW_COPY_AND_ASSIGN(Display); };
diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc index 877cfa5..96f7ddb 100644 --- a/components/mus/ws/event_dispatcher.cc +++ b/components/mus/ws/event_dispatcher.cc
@@ -7,8 +7,6 @@ #include <algorithm> #include "base/time/time.h" -#include "cc/surfaces/surface_hittest.h" -#include "components/mus/surfaces/surfaces_state.h" #include "components/mus/ws/accelerator.h" #include "components/mus/ws/display.h" #include "components/mus/ws/event_dispatcher_delegate.h" @@ -208,8 +206,7 @@ void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { if (mouse_cursor_source_window_) { gfx::Point location = mouse_pointer_last_location_; - ServerWindow* target = - FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); + ServerWindow* target = FindDeepestVisibleWindowForEvents(root_, &location); if (target == mouse_cursor_source_window_) { mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_ @@ -223,7 +220,7 @@ if (!mouse_button_down_) { gfx::Point location = mouse_pointer_last_location_; mouse_cursor_source_window_ = - FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); + FindDeepestVisibleWindowForEvents(root_, &location); mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_ @@ -419,7 +416,7 @@ PointerTarget pointer_target; gfx::Point location(event.location()); ServerWindow* target_window = - FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); + FindDeepestVisibleWindowForEvents(root_, &location); pointer_target.window = modal_window_controller_.GetTargetForWindow(target_window); pointer_target.is_mouse_event = event.IsMousePointerEvent(); @@ -449,7 +446,7 @@ mouse_cursor_in_non_client_area_ = target.in_nonclient_area; gfx::Point location(event.location()); - gfx::Transform transform(GetTransformToWindow(surface_id_, target.window)); + gfx::Transform transform(GetTransformToWindow(target.window)); transform.TransformPoint(&location); std::unique_ptr<ui::Event> clone = ui::Event::Clone(event); clone->AsLocatedEvent()->set_location(location);
diff --git a/components/mus/ws/event_dispatcher.h b/components/mus/ws/event_dispatcher.h index ca7e6a6..cea8aad7 100644 --- a/components/mus/ws/event_dispatcher.h +++ b/components/mus/ws/event_dispatcher.h
@@ -12,7 +12,6 @@ #include <utility> #include "base/macros.h" -#include "cc/surfaces/surface_id.h" #include "components/mus/public/interfaces/event_matcher.mojom.h" #include "components/mus/ws/modal_window_controller.h" #include "components/mus/ws/server_window_observer.h" @@ -43,8 +42,6 @@ void set_root(ServerWindow* root) { root_ = root; } - void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } - // Cancels capture and stops tracking any pointer events. This does not send // any events to the delegate. void Reset(); @@ -207,8 +204,6 @@ // bounds of |mouse_cursor_source_window_|, which can capture the cursor. gfx::Point mouse_pointer_last_location_; - cc::SurfaceId surface_id_; - using Entry = std::pair<uint32_t, std::unique_ptr<Accelerator>>; std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_;
diff --git a/components/mus/ws/platform_display.cc b/components/mus/ws/platform_display.cc index e0a1e2ab..c0274e1 100644 --- a/components/mus/ws/platform_display.cc +++ b/components/mus/ws/platform_display.cc
@@ -423,7 +423,6 @@ display_compositor_.reset( new DisplayCompositor(base::ThreadTaskRunnerHandle::Get(), widget, gpu_state_, surfaces_state_)); - delegate_->OnTopLevelSurfaceChanged(display_compositor_->surface_id()); } UpdateMetrics(metrics_.size_in_pixels.To<gfx::Size>(), device_pixel_ratio); }
diff --git a/components/mus/ws/platform_display_delegate.h b/components/mus/ws/platform_display_delegate.h index a69857773..3ef3786 100644 --- a/components/mus/ws/platform_display_delegate.h +++ b/components/mus/ws/platform_display_delegate.h
@@ -8,10 +8,6 @@ #include "components/mus/public/interfaces/window_tree.mojom.h" #include "components/mus/ws/ids.h" -namespace cc { -struct SurfaceId; -} - namespace ui { class Event; } @@ -44,8 +40,6 @@ const mojom::ViewportMetrics& old_metrics, const mojom::ViewportMetrics& new_metrics) = 0; - virtual void OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) = 0; - // Called when a compositor frame is finished drawing. virtual void OnCompositorFrameDrawn() = 0;
diff --git a/components/mus/ws/window_finder.cc b/components/mus/ws/window_finder.cc index 592d753..116b52cf 100644 --- a/components/mus/ws/window_finder.cc +++ b/components/mus/ws/window_finder.cc
@@ -4,7 +4,6 @@ #include "components/mus/ws/window_finder.h" -#include "cc/surfaces/surface_id.h" #include "components/mus/surfaces/surfaces_state.h" #include "components/mus/ws/server_window.h" #include "components/mus/ws/server_window_delegate.h" @@ -17,7 +16,6 @@ namespace mus { namespace ws { -namespace { bool IsValidWindowForEvents(ServerWindow* window) { ServerWindowSurfaceManager* surface_manager = window->surface_manager(); @@ -25,8 +23,8 @@ surface_manager->HasSurfaceOfType(mojom::SurfaceType::DEFAULT); } -ServerWindow* FindDeepestVisibleWindowNonSurface(ServerWindow* window, - gfx::Point* location) { +ServerWindow* FindDeepestVisibleWindowForEvents(ServerWindow* window, + gfx::Point* location) { const ServerWindow::Windows children(window->GetChildren()); for (auto iter = children.rbegin(); iter != children.rend(); ++iter) { ServerWindow* child = *iter; @@ -43,8 +41,7 @@ -child->extended_hit_test_region().bottom()); if (child_bounds.Contains(child_location)) { *location = child_location; - ServerWindow* result = - FindDeepestVisibleWindowNonSurface(child, location); + ServerWindow* result = FindDeepestVisibleWindowForEvents(child, location); if (IsValidWindowForEvents(result)) return result; } @@ -52,7 +49,7 @@ return window; } -gfx::Transform GetTransformToWindowNonSurface(ServerWindow* window) { +gfx::Transform GetTransformToWindow(ServerWindow* window) { gfx::Transform transform; ServerWindow* current = window; while (current->parent()) { @@ -62,67 +59,5 @@ return transform; } -bool HitTestSurfaceOfType(cc::SurfaceId display_surface_id, - ServerWindow* window, - mus::mojom::SurfaceType surface_type, - gfx::Transform* transform) { - *transform = gfx::Transform(); - ServerWindowSurface* surface = - window->GetOrCreateSurfaceManager()->GetSurfaceByType(surface_type); - return surface && - window->delegate() - ->GetSurfacesState() - ->hit_tester() - ->GetTransformToTargetSurface(display_surface_id, surface->id(), - transform); -} - -} // namespace - -ServerWindow* FindDeepestVisibleWindowForEvents( - ServerWindow* root_window, - cc::SurfaceId display_surface_id, - gfx::Point* location) { - // TODO(sky): remove this when insets can be set on surface. - display_surface_id = cc::SurfaceId(); - - if (display_surface_id.is_null()) { - // Surface-based hit-testing will not return a valid target if no - // CompositorFrame has been submitted (e.g. in unit-tests). - return FindDeepestVisibleWindowNonSurface(root_window, location); - } - - gfx::Transform transform; - cc::SurfaceId target_surface = - root_window->delegate() - ->GetSurfacesState() - ->hit_tester() - ->GetTargetSurfaceAtPoint(display_surface_id, *location, &transform); - WindowId id = WindowIdFromTransportId( - cc::SurfaceIdAllocator::NamespaceForId(target_surface)); - // TODO(fsamuel): This should be a DCHECK but currently we use stale - // information to decide where to route input events. This should be fixed - // once we implement a UI scheduler. - ServerWindow* target = root_window->GetChildWindow(id); - if (target) - transform.TransformPoint(location); - return target; -} - -gfx::Transform GetTransformToWindow(cc::SurfaceId display_surface_id, - ServerWindow* window) { - if (!display_surface_id.is_null()) { - gfx::Transform transform; - if (HitTestSurfaceOfType(display_surface_id, window, - mus::mojom::SurfaceType::DEFAULT, &transform) || - HitTestSurfaceOfType(display_surface_id, window, - mus::mojom::SurfaceType::UNDERLAY, &transform)) { - return transform; - } - } - - return GetTransformToWindowNonSurface(window); -} - } // namespace ws } // namespace mus
diff --git a/components/mus/ws/window_finder.h b/components/mus/ws/window_finder.h index 470e735..0b587b95 100644 --- a/components/mus/ws/window_finder.h +++ b/components/mus/ws/window_finder.h
@@ -25,13 +25,11 @@ // value. ServerWindow* FindDeepestVisibleWindowForEvents( ServerWindow* root_window, - cc::SurfaceId display_surface_id, gfx::Point* location); // Retrieve the transform to the provided |window|'s coordinate space from the // root. -gfx::Transform GetTransformToWindow(cc::SurfaceId display_surface_id, - ServerWindow* window); +gfx::Transform GetTransformToWindow(ServerWindow* window); } // namespace ws } // namespace mus
diff --git a/components/mus/ws/window_finder_unittest.cc b/components/mus/ws/window_finder_unittest.cc index 2d4d42f..c0021d6 100644 --- a/components/mus/ws/window_finder_unittest.cc +++ b/components/mus/ws/window_finder_unittest.cc
@@ -34,19 +34,16 @@ child2.SetBounds(gfx::Rect(15, 15, 20, 20)); gfx::Point local_point(16, 16); - EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, cc::SurfaceId(), - &local_point)); + EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, &local_point)); EXPECT_EQ(gfx::Point(1, 1), local_point); local_point.SetPoint(13, 14); - EXPECT_EQ(&child1, FindDeepestVisibleWindowForEvents(&root, cc::SurfaceId(), - &local_point)); + EXPECT_EQ(&child1, FindDeepestVisibleWindowForEvents(&root, &local_point)); EXPECT_EQ(gfx::Point(3, 4), local_point); child2.set_extended_hit_test_region(gfx::Insets(10, 10, 10, 10)); local_point.SetPoint(13, 14); - EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, cc::SurfaceId(), - &local_point)); + EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, &local_point)); EXPECT_EQ(gfx::Point(-2, -1), local_point); }
diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc index b2da116..e89d838 100644 --- a/components/mus/ws/window_manager_state.cc +++ b/components/mus/ws/window_manager_state.cc
@@ -95,20 +95,16 @@ WindowManagerState::QueuedEvent::~QueuedEvent() {} WindowManagerState::WindowManagerState(Display* display, - PlatformDisplay* platform_display, - cc::SurfaceId surface_id) + PlatformDisplay* platform_display) : WindowManagerState(display, platform_display, - surface_id, false, shell::mojom::kRootUserID) {} WindowManagerState::WindowManagerState(Display* display, PlatformDisplay* platform_display, - cc::SurfaceId surface_id, const UserId& user_id) - : WindowManagerState(display, platform_display, surface_id, true, user_id) { -} + : WindowManagerState(display, platform_display, true, user_id) {} WindowManagerState::~WindowManagerState() {} @@ -167,7 +163,6 @@ WindowManagerState::WindowManagerState(Display* display, PlatformDisplay* platform_display, - cc::SurfaceId surface_id, bool is_user_id_valid, const UserId& user_id) : display_(display), @@ -191,7 +186,6 @@ display->root_window()->Add(root_.get()); event_dispatcher_.set_root(root_.get()); - event_dispatcher_.set_surface_id(surface_id); AddDebugAccelerators(); }
diff --git a/components/mus/ws/window_manager_state.h b/components/mus/ws/window_manager_state.h index fa0311d..04b82b7 100644 --- a/components/mus/ws/window_manager_state.h +++ b/components/mus/ws/window_manager_state.h
@@ -17,10 +17,6 @@ #include "components/mus/ws/user_id.h" #include "components/mus/ws/window_server.h" -namespace cc { -struct SurfaceId; -} - namespace mus { namespace ws { @@ -39,12 +35,9 @@ class WindowManagerState : public EventDispatcherDelegate { public: // Creates a WindowManagerState that can host content from any user. + WindowManagerState(Display* display, PlatformDisplay* platform_display); WindowManagerState(Display* display, PlatformDisplay* platform_display, - cc::SurfaceId surface_id); - WindowManagerState(Display* display, - PlatformDisplay* platform_display, - cc::SurfaceId surface_id, const UserId& user_id); ~WindowManagerState() override; @@ -127,7 +120,6 @@ WindowManagerState(Display* display, PlatformDisplay* platform_display, - cc::SurfaceId surface_id, bool is_user_id_valid, const UserId& user_id);
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.h b/components/ntp_snippets/ntp_snippets_fetcher.h index b3cd393f..8bc982d 100644 --- a/components/ntp_snippets/ntp_snippets_fetcher.h +++ b/components/ntp_snippets/ntp_snippets_fetcher.h
@@ -65,6 +65,9 @@ RESULT_MAX }; + // Enum listing all possible variants of dealing with personalization. + enum class Personalization { kPersonal, kNonPersonal, kBoth }; + NTPSnippetsFetcher( SigninManagerBase* signin_manager, OAuth2TokenService* oauth2_token_service, @@ -95,20 +98,24 @@ return last_fetch_json_; } + // Returns the personalization setting of the fetcher. + Personalization personalization() const { return personalization_; } + + // Does the fetcher use host restriction? + bool UseHostRestriction() const; + // Does the fetcher use authentication to get personalized results? + bool UseAuthentication() const; + // Overrides internal clock for testing purposes. void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) { tick_clock_ = std::move(tick_clock); } private: - enum class Personalization { kPersonal, kNonPersonal, kBoth }; - void FetchSnippetsImpl(const GURL& url, const std::string& auth_header, const std::string& request); std::string GetHostRestricts() const; - bool UseHostRestriction() const; - bool UseAuthentication() const; void FetchSnippetsNonAuthenticated(); void FetchSnippetsAuthenticated(const std::string& account_id, const std::string& oauth_access_token);
diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc index 555e1012..448c31a6 100644 --- a/components/ntp_snippets/ntp_snippets_service.cc +++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -20,11 +20,13 @@ #include "base/time/time.h" #include "base/values.h" #include "components/image_fetcher/image_fetcher.h" +#include "components/ntp_snippets/ntp_snippets_constants.h" #include "components/ntp_snippets/pref_names.h" #include "components/ntp_snippets/switches.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" #include "components/suggestions/proto/suggestions.pb.h" +#include "components/variations/variations_associated_data.h" using image_fetcher::ImageFetcher; using suggestions::ChromeSuggestion; @@ -39,9 +41,18 @@ // histograms with COUNTS() if this number increases beyond 50. const int kMaxSnippetCount = 10; -const int kFetchingIntervalWifiChargingSeconds = 30 * 60; -const int kFetchingIntervalWifiSeconds = 2 * 60 * 60; -const int kFetchingIntervalFallbackSeconds = 24 * 60 * 60; +// Default values for snippets fetching intervals. +const int kDefaultFetchingIntervalWifiChargingSeconds = 30 * 60; +const int kDefaultFetchingIntervalWifiSeconds = 2 * 60 * 60; +const int kDefaultFetchingIntervalFallbackSeconds = 24 * 60 * 60; + +// Variation parameters than can override the default fetching intervals. +const char kFetchingIntervalWifiChargingParamName[] = + "fetching_interval_wifi_charging_seconds"; +const char kFetchingIntervalWifiParamName[] = + "fetching_interval_wifi_seconds"; +const char kFetchingIntervalFallbackParamName[] = + "fetching_interval_fallback_seconds"; // These define the times of day during which we will fetch via Wifi (without // charging) - 6 AM to 10 PM. @@ -51,8 +62,20 @@ const int kDefaultExpiryTimeMins = 24 * 60; base::TimeDelta GetFetchingInterval(const char* switch_name, + const char* param_name, int default_value_seconds) { int value_seconds = default_value_seconds; + + // The default value can be overridden by a variation parameter. + std::string param_value_str = variations::GetVariationParamValue( + ntp_snippets::kStudyName, param_name); + int param_value_seconds = 0; + if (base::StringToInt(param_value_str, ¶m_value_seconds)) + value_seconds = param_value_seconds; + else + LOG(WARNING) << "Invalid value for variation parameter " << param_name; + + // A value from the command line parameter overrides anything else. const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); if (cmdline.HasSwitch(switch_name)) { std::string str = cmdline.GetSwitchValueASCII(switch_name); @@ -67,7 +90,8 @@ base::TimeDelta GetFetchingIntervalWifiCharging() { return GetFetchingInterval(switches::kFetchingIntervalWifiChargingSeconds, - kFetchingIntervalWifiChargingSeconds); + kFetchingIntervalWifiChargingParamName, + kDefaultFetchingIntervalWifiChargingSeconds); } base::TimeDelta GetFetchingIntervalWifi(const base::Time& now) { @@ -77,14 +101,16 @@ if (kWifiFetchingHourMin <= exploded.hour && exploded.hour < kWifiFetchingHourMax) { return GetFetchingInterval(switches::kFetchingIntervalWifiSeconds, - kFetchingIntervalWifiSeconds); + kFetchingIntervalWifiParamName, + kDefaultFetchingIntervalWifiSeconds); } return base::TimeDelta(); } base::TimeDelta GetFetchingIntervalFallback() { return GetFetchingInterval(switches::kFetchingIntervalFallbackSeconds, - kFetchingIntervalFallbackSeconds); + kFetchingIntervalFallbackParamName, + kDefaultFetchingIntervalFallbackSeconds); } base::Time GetRescheduleTime(const base::Time& now) { @@ -126,7 +152,7 @@ } std::unique_ptr<base::ListValue> SnippetsToListValue( - const NTPSnippetsService::NTPSnippetStorage& snippets) { + const NTPSnippet::PtrVector& snippets) { std::unique_ptr<base::ListValue> list(new base::ListValue); for (const auto& snippet : snippets) { std::unique_ptr<base::DictionaryValue> dict = snippet->ToDictionary(); @@ -135,7 +161,7 @@ return list; } -bool ContainsSnippet(const NTPSnippetsService::NTPSnippetStorage& haystack, +bool ContainsSnippet(const NTPSnippet::PtrVector& haystack, const std::unique_ptr<NTPSnippet>& needle) { const std::string& id = needle->id(); return std::find_if(haystack.begin(), haystack.end(), @@ -161,7 +187,8 @@ NTPSnippetsScheduler* scheduler, std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher, std::unique_ptr<ImageFetcher> image_fetcher) - : enabled_(false), + : state_(State::NOT_INITED), + enabled_(false), pref_service_(pref_service), suggestions_service_(suggestions_service), file_task_runner_(file_task_runner), @@ -173,7 +200,9 @@ &NTPSnippetsService::OnFetchFinished, base::Unretained(this))); } -NTPSnippetsService::~NTPSnippetsService() {} +NTPSnippetsService::~NTPSnippetsService() { + DCHECK(state_ == State::NOT_INITED || state_ == State::SHUT_DOWN); +} // static void NTPSnippetsService::RegisterProfilePrefs(PrefRegistrySimple* registry) { @@ -183,10 +212,13 @@ } void NTPSnippetsService::Init(bool enabled) { + DCHECK(state_ == State::NOT_INITED); + state_ = State::INITED; + enabled_ = enabled; if (enabled_) { // |suggestions_service_| can be null in tests. - if (suggestions_service_) { + if (snippets_fetcher_->UseHostRestriction() && suggestions_service_) { suggestions_service_subscription_ = suggestions_service_->AddCallback( base::Bind(&NTPSnippetsService::OnSuggestionsChanged, base::Unretained(this))); @@ -205,8 +237,12 @@ } void NTPSnippetsService::Shutdown() { + DCHECK(state_ == State::INITED); + state_ = State::SHUT_DOWN; + FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_, NTPSnippetsServiceShutdown()); + suggestions_service_subscription_.reset(); enabled_ = false; } @@ -355,7 +391,7 @@ LoadingSnippetsFinished(); } -void NTPSnippetsService::MergeSnippets(NTPSnippetStorage new_snippets) { +void NTPSnippetsService::MergeSnippets(NTPSnippet::PtrVector new_snippets) { // Remove new snippets that we already have, or that have been discarded. new_snippets.erase( std::remove_if(new_snippets.begin(), new_snippets.end(), @@ -405,7 +441,7 @@ } void NTPSnippetsService::LoadSnippetsFromPrefs() { - NTPSnippetStorage prefs_snippets; + NTPSnippet::PtrVector prefs_snippets; bool success = NTPSnippet::AddFromListValue( *pref_service_->GetList(prefs::kSnippets), &prefs_snippets); DCHECK(success) << "Failed to parse snippets from prefs";
diff --git a/components/ntp_snippets/ntp_snippets_service.h b/components/ntp_snippets/ntp_snippets_service.h index 7144e45..e5aba94 100644 --- a/components/ntp_snippets/ntp_snippets_service.h +++ b/components/ntp_snippets/ntp_snippets_service.h
@@ -46,8 +46,6 @@ // Stores and vends fresh content data for the NTP. class NTPSnippetsService : public KeyedService { public: - using NTPSnippetStorage = NTPSnippet::PtrVector; - using ImageFetchedCallback = base::Callback<void(const std::string& snippet_id, const SkBitmap*)>; @@ -79,11 +77,11 @@ void FetchSnippetsFromHosts(const std::set<std::string>& hosts); // Available snippets. - const NTPSnippetStorage& snippets() const { return snippets_; } + const NTPSnippet::PtrVector& snippets() const { return snippets_; } // Returns the list of snippets previously discarded by the user (that are // not expired yet). - const NTPSnippetStorage& discarded_snippets() const { + const NTPSnippet::PtrVector& discarded_snippets() const { return discarded_snippets_; } @@ -131,12 +129,8 @@ void OnSuggestionsChanged(const suggestions::SuggestionsProfile& suggestions); void OnFetchFinished(NTPSnippetsFetcher::OptionalSnippets snippets); - // Expects a top-level dictionary containing a "recos" list, each element of - // which will be parsed as a snippet. - bool LoadFromFetchedValue(const base::Value& value); - // Merges newly available snippets with the previously available list. - void MergeSnippets(NTPSnippetStorage new_snippets); + void MergeSnippets(NTPSnippet::PtrVector new_snippets); // TODO(treib): Investigate a better storage, maybe LevelDB or SQLite? void LoadSnippetsFromPrefs(); void StoreSnippetsToPrefs(); @@ -149,6 +143,12 @@ void LoadingSnippetsFinished(); + enum class State { + NOT_INITED, + INITED, + SHUT_DOWN + } state_; + bool enabled_; PrefService* pref_service_; @@ -159,11 +159,11 @@ scoped_refptr<base::SequencedTaskRunner> file_task_runner_; // All current suggestions (i.e. not discarded ones). - NTPSnippetStorage snippets_; + NTPSnippet::PtrVector snippets_; // Suggestions that the user discarded. We keep these around until they expire // so we won't re-add them on the next fetch. - NTPSnippetStorage discarded_snippets_; + NTPSnippet::PtrVector discarded_snippets_; // The ISO 639-1 code of the language used by the application. const std::string application_language_code_;
diff --git a/components/ntp_snippets/ntp_snippets_service_unittest.cc b/components/ntp_snippets/ntp_snippets_service_unittest.cc index dbaaed7..678fa81 100644 --- a/components/ntp_snippets/ntp_snippets_service_unittest.cc +++ b/components/ntp_snippets/ntp_snippets_service_unittest.cc
@@ -222,7 +222,10 @@ switches::kDontRestrict); } - ~NTPSnippetsServiceTest() override {} + ~NTPSnippetsServiceTest() override { + if (service_) + service_->Shutdown(); + } void SetUp() override { EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); @@ -230,6 +233,9 @@ } void CreateSnippetsService(bool enabled) { + if (service_) + service_->Shutdown(); + scoped_refptr<base::SingleThreadTaskRunner> task_runner( base::ThreadTaskRunnerHandle::Get()); scoped_refptr<net::TestURLRequestContextGetter> request_context_getter = @@ -474,8 +480,7 @@ // For the test, we need the snippet to get discarded. ASSERT_TRUE(service()->DiscardSnippet("http://localhost/foobar")); - const NTPSnippetsService::NTPSnippetStorage& snippets = - service()->discarded_snippets(); + const NTPSnippet::PtrVector& snippets = service()->discarded_snippets(); EXPECT_EQ(1u, snippets.size()); for (auto& snippet : snippets) { EXPECT_EQ("http://localhost/foobar", snippet->id());
diff --git a/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java b/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java index 64f886b..311bba61 100644 --- a/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java +++ b/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java
@@ -8,14 +8,13 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Parcel; -import android.preference.PreferenceManager; import android.util.Base64; +import org.chromium.base.ContextUtils; import org.chromium.base.Log; import org.chromium.base.ThreadUtils; import org.chromium.base.VisibleForTesting; @@ -39,7 +38,6 @@ private static Bundle sTestRestrictions = null; private final Context mContext; - private final SharedPreferences mSharedPreferences; private final BroadcastReceiver mAppRestrictionsChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -54,7 +52,6 @@ */ public AbstractAppRestrictionsProvider(Context context) { mContext = context; - mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); } /** @@ -138,13 +135,11 @@ p.writeBundle(policies); byte bytes[] = p.marshall(); String s = Base64.encodeToString(bytes, 0); - SharedPreferences.Editor ed = mSharedPreferences.edit(); - ed.putString(PREFERENCE_KEY, s); - ed.apply(); + ContextUtils.getAppSharedPreferences().edit().putString(PREFERENCE_KEY, s).apply(); } private Bundle getCachedPolicies() { - String s = mSharedPreferences.getString(PREFERENCE_KEY, null); + String s = ContextUtils.getAppSharedPreferences().getString(PREFERENCE_KEY, null); if (s == null) { return null; }
diff --git a/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java b/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java index 61d203db..33f26cf3 100644 --- a/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java +++ b/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
@@ -18,10 +18,9 @@ import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; +import org.chromium.base.ContextUtils; import org.chromium.testing.local.LocalRobolectricTestRunner; import org.junit.Assert; import org.junit.Test; @@ -81,12 +80,10 @@ Robolectric.getBackgroundScheduler().pause(); Context context = Robolectric.application; + ContextUtils.initApplicationContextForTests(context); // Clear the preferences - SharedPreferences sharedPreferences = PreferenceManager - .getDefaultSharedPreferences(context); - SharedPreferences.Editor ed = sharedPreferences.edit(); - ed.clear(); + ContextUtils.getAppSharedPreferences().edit().clear(); // Set up a bundle for testing. Bundle b1 = new Bundle();
diff --git a/components/translate/core/language_detection/DEPS b/components/translate/core/language_detection/DEPS index a8cdc15..eccda7a 100644 --- a/components/translate/core/language_detection/DEPS +++ b/components/translate/core/language_detection/DEPS
@@ -1,6 +1,4 @@ include_rules = [ # CLD library. - "+third_party/cld", - "+third_party/cld/encodings/compact_lang_det/win", "+third_party/cld_2/src", ]
diff --git a/components/update_client/component_patcher_operation.cc b/components/update_client/component_patcher_operation.cc index 2d2528ba6..2da622da 100644 --- a/components/update_client/component_patcher_operation.cc +++ b/components/update_client/component_patcher_operation.cc
@@ -16,7 +16,7 @@ #include "components/update_client/update_client.h" #include "components/update_client/utils.h" #include "courgette/courgette.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" namespace update_client {
diff --git a/components/update_client/component_patcher_unittest.cc b/components/update_client/component_patcher_unittest.cc index 074e4a23..ba8fafa 100644 --- a/components/update_client/component_patcher_unittest.cc +++ b/components/update_client/component_patcher_unittest.cc
@@ -17,7 +17,7 @@ #include "components/update_client/component_patcher_unittest.h" #include "components/update_client/test_installer.h" #include "courgette/courgette.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include "testing/gtest/include/gtest/gtest.h" namespace {
diff --git a/components/update_client/component_patcher_unittest.h b/components/update_client/component_patcher_unittest.h index a3b70f2..f21d104 100644 --- a/components/update_client/component_patcher_unittest.h +++ b/components/update_client/component_patcher_unittest.h
@@ -11,7 +11,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/message_loop/message_loop.h" #include "courgette/courgette.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include "testing/gtest/include/gtest/gtest.h" namespace update_client {
diff --git a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java index 64e2877..465809c1 100644 --- a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java +++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
@@ -5,9 +5,9 @@ package org.chromium.components.variations.firstrun; import android.content.Context; -import android.preference.PreferenceManager; import android.util.Base64; +import org.chromium.base.ContextUtils; import org.chromium.base.annotations.CalledByNative; /** @@ -30,7 +30,7 @@ "variations_seed_native_stored"; protected static String getVariationsFirstRunSeedPref(Context context, String prefName) { - return PreferenceManager.getDefaultSharedPreferences(context).getString(prefName, ""); + return ContextUtils.getAppSharedPreferences().getString(prefName, ""); } /** @@ -40,7 +40,7 @@ @CalledByNative public static void setVariationsFirstRunSeed(Context context, byte[] rawSeed, String signature, String country, String date, boolean isGzipCompressed) { - PreferenceManager.getDefaultSharedPreferences(context) + ContextUtils.getAppSharedPreferences() .edit() .putString(VARIATIONS_FIRST_RUN_SEED_BASE64, Base64.encodeToString(rawSeed, Base64.NO_WRAP)) @@ -53,7 +53,7 @@ @CalledByNative private static void clearFirstRunPrefs(Context context) { - PreferenceManager.getDefaultSharedPreferences(context) + ContextUtils.getAppSharedPreferences() .edit() .remove(VARIATIONS_FIRST_RUN_SEED_BASE64) .remove(VARIATIONS_FIRST_RUN_SEED_SIGNATURE) @@ -67,7 +67,7 @@ * Returns the status of the variations first run fetch: was it successful or not. */ public static boolean hasJavaPref(Context context) { - return !PreferenceManager.getDefaultSharedPreferences(context) + return !ContextUtils.getAppSharedPreferences() .getString(VARIATIONS_FIRST_RUN_SEED_BASE64, "") .isEmpty(); } @@ -76,13 +76,13 @@ * Returns the status of the variations seed storing on the C++ side: was it successful or not. */ public static boolean hasNativePref(Context context) { - return PreferenceManager.getDefaultSharedPreferences(context).getBoolean( + return ContextUtils.getAppSharedPreferences().getBoolean( VARIATIONS_FIRST_RUN_SEED_NATIVE_STORED, false); } @CalledByNative private static void markVariationsSeedAsStored(Context context) { - PreferenceManager.getDefaultSharedPreferences(context) + ContextUtils.getAppSharedPreferences() .edit() .putBoolean(VARIATIONS_FIRST_RUN_SEED_NATIVE_STORED, true) .apply(); @@ -112,7 +112,7 @@ @CalledByNative private static boolean getVariationsFirstRunSeedIsGzipCompressed(Context context) { - return PreferenceManager.getDefaultSharedPreferences(context).getBoolean( + return ContextUtils.getAppSharedPreferences().getBoolean( VARIATIONS_FIRST_RUN_SEED_IS_GZIP_COMPRESSED, false); } }
diff --git a/content/browser/DEPS b/content/browser/DEPS index cda1459..f92180c0 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS
@@ -110,3 +110,21 @@ # See https://sites.google.com/a/chromium.org/dev/developers/content-module # for more information. ] + +specific_include_rules = { + # See https://crbug.com/612337. + "power_save_blocker.*\.(cc|h)": [ + "-content", + + # These will move to //device/power_save_blocker. + "+content/browser/power_save_blocker_impl.h", + "+content/public/browser/power_save_blocker.h", + + # These dependencies need to be removed. + "!content/browser/android/content_view_core_impl.h", + "!content/browser/web_contents/web_contents_impl.h", + "!content/public/browser/android/content_view_core.h", + "!content/public/browser/browser_thread.h", + "!content/public/browser/web_contents_observer.h", + ] +}
diff --git a/content/browser/device_sensors/data_fetcher_shared_memory_win.cc b/content/browser/device_sensors/data_fetcher_shared_memory_win.cc index 40471ca0a..f567bb12 100644 --- a/content/browser/device_sensors/data_fetcher_shared_memory_win.cc +++ b/content/browser/device_sensors/data_fetcher_shared_memory_win.cc
@@ -114,12 +114,12 @@ double alpha, beta, gamma; bool has_alpha, has_beta, has_gamma; - GetSensorValue(SENSOR_DATA_TYPE_TILT_X_DEGREES, new_data, &alpha, - &has_alpha); - GetSensorValue(SENSOR_DATA_TYPE_TILT_Y_DEGREES, new_data, &beta, + GetSensorValue(SENSOR_DATA_TYPE_TILT_X_DEGREES, new_data, &beta, &has_beta); - GetSensorValue(SENSOR_DATA_TYPE_TILT_Z_DEGREES, new_data, &gamma, + GetSensorValue(SENSOR_DATA_TYPE_TILT_Y_DEGREES, new_data, &gamma, &has_gamma); + GetSensorValue(SENSOR_DATA_TYPE_TILT_Z_DEGREES, new_data, &alpha, + &has_alpha); if (buffer_) { buffer_->seqlock.WriteBegin();
diff --git a/content/common/OWNERS b/content/common/OWNERS index f7301e1..872aef9c 100644 --- a/content/common/OWNERS +++ b/content/common/OWNERS
@@ -91,10 +91,6 @@ per-file websocket.*=tyoshino@chromium.org per-file websocket.*=yhirano@chromium.org -# Compositor -per-file cc_messages_unittest.cc=danakj@chromium.org -per-file cc_messages_perftest.cc=danakj@chromium.org - # DirectWrite per-file dwrite_font_platform_win*=scottmg@chromium.org per-file font_warmup_win.cc=scottmg@chromium.org
diff --git a/content/content_tests.gypi b/content/content_tests.gypi index d8a7ea96..1239968 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi
@@ -669,7 +669,6 @@ 'child/worker_thread_registry_unittest.cc', 'common/android/address_parser_unittest.cc', 'common/android/gin_java_bridge_value_unittest.cc', - 'common/cc_messages_unittest.cc', 'common/common_param_traits_unittest.cc', 'common/cross_site_document_classifier_unittest.cc', 'common/cursors/webcursor_unittest.cc', @@ -1257,7 +1256,6 @@ ], 'sources': [ 'browser/renderer_host/input/input_router_impl_perftest.cc', - 'common/cc_messages_perftest.cc', 'common/discardable_shared_memory_heap_perftest.cc', 'test/run_all_perftests.cc', ],
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index 6a7bca7c..d8c321b 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc
@@ -338,6 +338,12 @@ return false; } +bool ContentBrowserClient::IsPepperVpnProviderAPIAllowed( + BrowserContext* browser_context, + const GURL& url) { + return false; +} + ui::SelectFilePolicy* ContentBrowserClient::CreateSelectFilePolicy( WebContents* web_contents) { return nullptr;
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index 5c6d4c53..7a61399c 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h
@@ -587,6 +587,11 @@ bool private_api, const SocketPermissionRequest* params); + // Returns true if the "vpnProvider" permission is allowed from the given + // |browser_context| and |url|. + virtual bool IsPepperVpnProviderAPIAllowed(BrowserContext* browser_context, + const GURL& url); + // Returns an implementation of a file selecition policy. Can return nullptr. virtual ui::SelectFilePolicy* CreateSelectFilePolicy( WebContents* web_contents);
diff --git a/content/public/browser/render_frame_host.h b/content/public/browser/render_frame_host.h index 86ac9d5..c49e9cb 100644 --- a/content/public/browser/render_frame_host.h +++ b/content/public/browser/render_frame_host.h
@@ -38,16 +38,6 @@ // Returns nullptr if the IDs do not correspond to a live RenderFrameHost. static RenderFrameHost* FromID(int render_process_id, int render_frame_id); - // Returns the current RenderFrameHost associated with the frame identified by - // the given FrameTreeNode ID, in any WebContents. The frame may change its - // current RenderFrameHost over time, so the returned RenderFrameHost can be - // different from the RenderFrameHost that returned the ID via - // GetFrameTreeNodeId(). See GetFrameTreeNodeId for more details. - // Use WebContents::FindFrameByFrameTreeNodeId to find a RenderFrameHost in - // a specific WebContents. - // Returns nullptr if the frame does not exist. - static RenderFrameHost* FromFrameTreeNodeId(int frame_tree_node_id); - #if defined(OS_ANDROID) // Globally allows for injecting JavaScript into the main world. This feature // is present only to support Android WebView and must not be used in other
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 4768b7d..698024c 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -881,7 +881,6 @@ sources = [ "../browser/renderer_host/input/input_router_impl_perftest.cc", - "../common/cc_messages_perftest.cc", "../common/discardable_shared_memory_heap_perftest.cc", "../test/run_all_perftests.cc", ]
diff --git a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py index 0865674..d4ec823 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py
@@ -261,6 +261,39 @@ self.Fail('conformance/textures/image_bitmap_from_canvas/' + 'tex-2d-rgba-rgba-unsigned_byte.html', ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_canvas/' + + 'tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_canvas/' + + 'tex-2d-rgba-rgba-unsigned_short_5_5_5_1.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_blob/' + + 'tex-2d-rgb-rgb-unsigned_byte.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_blob/' + + 'tex-2d-rgb-rgb-unsigned_short_5_6_5.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_blob/' + + 'tex-2d-rgba-rgba-unsigned_byte.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_blob/' + + 'tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_blob/' + + 'tex-2d-rgba-rgba-unsigned_short_5_5_5_1.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_image_bitmap/' + + 'tex-2d-rgb-rgb-unsigned_byte.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_image_bitmap/' + + 'tex-2d-rgb-rgb-unsigned_short_5_6_5.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_image_bitmap/' + + 'tex-2d-rgba-rgba-unsigned_byte.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) + self.Fail('conformance/textures/image_bitmap_from_image_bitmap/' + + 'tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html', + ['android', ('qualcomm', 'Adreno (TM) 418')], bug=610951) # Nexus 6 self.Fail('WebglExtension.EXT_sRGB', @@ -290,6 +323,8 @@ ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) self.Fail('conformance/glsl/misc/shader-uniform-packing-restrictions.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) + self.Fail('conformance/glsl/misc/shader-varying-packing-restrictions.html', + ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) # Nexus 9 self.Fail('WebglExtension.WEBGL_compressed_texture_atc',
diff --git a/courgette/BUILD.gn b/courgette/BUILD.gn index a5cb660..53cce77f4 100644 --- a/courgette/BUILD.gn +++ b/courgette/BUILD.gn
@@ -51,11 +51,11 @@ "simple_delta.h", "streams.cc", "streams.h", - "third_party/bsdiff.h", - "third_party/bsdiff_apply.cc", - "third_party/bsdiff_create.cc", - "third_party/paged_array.h", - "third_party/qsufsort.h", + "third_party/bsdiff/bsdiff.h", + "third_party/bsdiff/bsdiff_apply.cc", + "third_party/bsdiff/bsdiff_create.cc", + "third_party/bsdiff/paged_array.h", + "third_party/bsdiff/qsufsort.h", "types_elf.h", "types_win_pe.h", ] @@ -120,8 +120,8 @@ "memory_allocator_unittest.cc", "rel32_finder_win32_x86_unittest.cc", "streams_unittest.cc", - "third_party/paged_array_unittest.cc", - "third_party/qsufsort_unittest.cc", + "third_party/bsdiff/paged_array_unittest.cc", + "third_party/bsdiff/qsufsort_unittest.cc", "typedrva_unittest.cc", "versioning_unittest.cc", ]
diff --git a/courgette/bsdiff_memory_unittest.cc b/courgette/bsdiff_memory_unittest.cc index 5274565..a9423d4 100644 --- a/courgette/bsdiff_memory_unittest.cc +++ b/courgette/bsdiff_memory_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include <stddef.h>
diff --git a/courgette/courgette.gyp b/courgette/courgette.gyp index f5e4031..486254c 100644 --- a/courgette/courgette.gyp +++ b/courgette/courgette.gyp
@@ -49,11 +49,11 @@ 'simple_delta.h', 'streams.cc', 'streams.h', - 'third_party/bsdiff.h', - 'third_party/bsdiff_apply.cc', - 'third_party/bsdiff_create.cc', - 'third_party/paged_array.h', - 'third_party/qsufsort.h', + 'third_party/bsdiff/bsdiff.h', + 'third_party/bsdiff/bsdiff_apply.cc', + 'third_party/bsdiff/bsdiff_create.cc', + 'third_party/bsdiff/paged_array.h', + 'third_party/bsdiff/qsufsort.h', 'types_elf.h', 'types_win_pe.h', 'patch_generator_x86_32.h', @@ -122,8 +122,8 @@ 'streams_unittest.cc', 'typedrva_unittest.cc', 'versioning_unittest.cc', - 'third_party/paged_array_unittest.cc', - 'third_party/qsufsort_unittest.cc', + 'third_party/bsdiff/paged_array_unittest.cc', + 'third_party/bsdiff/qsufsort_unittest.cc', ], 'dependencies': [ 'courgette_lib',
diff --git a/courgette/courgette_minimal_tool.cc b/courgette/courgette_minimal_tool.cc index 972eac47..45ac6317 100644 --- a/courgette/courgette_minimal_tool.cc +++ b/courgette/courgette_minimal_tool.cc
@@ -8,9 +8,9 @@ #include <string> -#include "courgette/third_party/bsdiff.h" #include "courgette/courgette.h" #include "courgette/streams.h" +#include "courgette/third_party/bsdiff/bsdiff.h" void PrintHelp() { fprintf(stderr,
diff --git a/courgette/courgette_tool.cc b/courgette/courgette_tool.cc index 826c33f..83a6834 100644 --- a/courgette/courgette_tool.cc +++ b/courgette/courgette_tool.cc
@@ -22,8 +22,7 @@ #include "courgette/encoded_program.h" #include "courgette/program_detector.h" #include "courgette/streams.h" -#include "courgette/third_party/bsdiff.h" - +#include "courgette/third_party/bsdiff/bsdiff.h" void PrintHelp() { fprintf(stderr,
diff --git a/courgette/ensemble_create.cc b/courgette/ensemble_create.cc index 3bc1846..0237111 100644 --- a/courgette/ensemble_create.cc +++ b/courgette/ensemble_create.cc
@@ -24,13 +24,12 @@ #include "courgette/crc.h" #include "courgette/difference_estimator.h" +#include "courgette/patch_generator_x86_32.h" +#include "courgette/patcher_x86_32.h" #include "courgette/region.h" #include "courgette/simple_delta.h" #include "courgette/streams.h" -#include "courgette/third_party/bsdiff.h" - -#include "courgette/patcher_x86_32.h" -#include "courgette/patch_generator_x86_32.h" +#include "courgette/third_party/bsdiff/bsdiff.h" namespace courgette {
diff --git a/courgette/patch_generator_x86_32.h b/courgette/patch_generator_x86_32.h index af9c286..cc7c146b 100644 --- a/courgette/patch_generator_x86_32.h +++ b/courgette/patch_generator_x86_32.h
@@ -14,6 +14,7 @@ #include "base/macros.h" #include "courgette/assembly_program.h" #include "courgette/ensemble.h" +#include "courgette/patcher_x86_32.h" #include "courgette/program_detector.h" namespace courgette {
diff --git a/courgette/simple_delta.cc b/courgette/simple_delta.cc index 23f8430..ed7eaa0 100644 --- a/courgette/simple_delta.cc +++ b/courgette/simple_delta.cc
@@ -9,7 +9,7 @@ #include "base/logging.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" namespace courgette {
diff --git a/courgette/third_party/LICENCE b/courgette/third_party/bsdiff/LICENCE similarity index 100% rename from courgette/third_party/LICENCE rename to courgette/third_party/bsdiff/LICENCE
diff --git a/courgette/third_party/README.chromium b/courgette/third_party/bsdiff/README.chromium similarity index 87% rename from courgette/third_party/README.chromium rename to courgette/third_party/bsdiff/README.chromium index 3f7f3084..8e66a947 100644 --- a/courgette/third_party/README.chromium +++ b/courgette/third_party/bsdiff/README.chromium
@@ -1,3 +1,9 @@ +Name: bsdiff +URL: http://www.daemonology.net/bsdiff/ +License: BSD +License File: LICENCE + +Description: This directory contains an extensively modified version of Colin Percival's bsdiff, available in its original form from: @@ -6,7 +12,7 @@ The basic principles of operation are best understood by reading Colin's unpublised paper: -Colin Percival, Naive differences of executable code, http://www.daemonology.net/bsdiff/, 200 +Colin Percival, Naive differences of executable code, http://www.daemonology.net/bsdiff/, 2003. The copy on this directory so extensively modified that the binary format is incompatible with the original and it cannot be compiled outside the Chromium
diff --git a/courgette/third_party/bsdiff.h b/courgette/third_party/bsdiff/bsdiff.h similarity index 89% rename from courgette/third_party/bsdiff.h rename to courgette/third_party/bsdiff/bsdiff.h index 1a7e025d..707d0814 100644 --- a/courgette/third_party/bsdiff.h +++ b/courgette/third_party/bsdiff/bsdiff.h
@@ -34,8 +34,8 @@ * --Joshua Pawlicki <waffles@chromium.org> */ -#ifndef COURGETTE_BSDIFF_H_ -#define COURGETTE_BSDIFF_H_ +#ifndef COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ +#define COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ #include <stdint.h> @@ -79,10 +79,10 @@ // The patch stream starts with a MBSPatchHeader. typedef struct MBSPatchHeader_ { - char tag[8]; // Contains MBS_PATCH_HEADER_TAG - uint32_t slen; // Length of the file to be patched. - uint32_t scrc32; // CRC32 of the file to be patched. - uint32_t dlen; // Length of the result file. + char tag[8]; // Contains MBS_PATCH_HEADER_TAG. + uint32_t slen; // Length of the file to be patched. + uint32_t scrc32; // CRC32 of the file to be patched. + uint32_t dlen; // Length of the result file. } MBSPatchHeader; // This is the value for the tag field. Must match length exactly, not counting @@ -90,4 +90,4 @@ #define MBS_PATCH_HEADER_TAG "GBSDIF42" } // namespace -#endif // COURGETTE_BSDIFF_H_ +#endif // COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_
diff --git a/courgette/third_party/bsdiff_apply.cc b/courgette/third_party/bsdiff/bsdiff_apply.cc similarity index 87% rename from courgette/third_party/bsdiff_apply.cc rename to courgette/third_party/bsdiff/bsdiff_apply.cc index 537f194..0abec61 100644 --- a/courgette/third_party/bsdiff_apply.cc +++ b/courgette/third_party/bsdiff/bsdiff_apply.cc
@@ -34,7 +34,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include <stddef.h> #include <stdint.h> @@ -46,10 +46,14 @@ namespace courgette { BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) { - if (!stream->Read(header->tag, sizeof(header->tag))) return READ_ERROR; - if (!stream->ReadVarint32(&header->slen)) return READ_ERROR; - if (!stream->ReadVarint32(&header->scrc32)) return READ_ERROR; - if (!stream->ReadVarint32(&header->dlen)) return READ_ERROR; + if (!stream->Read(header->tag, sizeof(header->tag))) + return READ_ERROR; + if (!stream->ReadVarint32(&header->slen)) + return READ_ERROR; + if (!stream->ReadVarint32(&header->scrc32)) + return READ_ERROR; + if (!stream->ReadVarint32(&header->dlen)) + return READ_ERROR; // The string will have a NUL terminator that we don't use, hence '-1'. static_assert(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header->tag), @@ -102,8 +106,8 @@ return UNEXPECTED_ERROR; #ifdef DEBUG_bsmedberg - printf("Applying block: copy: %-8u extra: %-8u seek: %+i\n", - copy_count, extra_count, seek_adjustment); + printf("Applying block: copy: %-8u extra: %-8u seek: %+i\n", copy_count, + extra_count, seek_adjustment); #endif // Byte-wise arithmetically add bytes from old file to bytes from the diff // block. @@ -111,7 +115,7 @@ return UNEXPECTED_ERROR; // Add together bytes from the 'old' file and the 'diff' stream. - for (size_t i = 0; i < copy_count; ++i) { + for (size_t i = 0; i < copy_count; ++i) { uint8_t diff_byte = 0; if (pending_diff_zeros) { --pending_diff_zeros; @@ -145,11 +149,8 @@ } if (!control_stream_copy_counts->Empty() || - !control_stream_extra_counts->Empty() || - !control_stream_seeks->Empty() || - !diff_skips->Empty() || - !diff_bytes->Empty() || - !extra_bytes->Empty()) + !control_stream_extra_counts->Empty() || !control_stream_seeks->Empty() || + !diff_skips->Empty() || !diff_bytes->Empty() || !extra_bytes->Empty()) return UNEXPECTED_ERROR; return OK; @@ -160,12 +161,14 @@ SinkStream* new_stream) { MBSPatchHeader header; BSDiffStatus ret = MBS_ReadHeader(patch_stream, &header); - if (ret != OK) return ret; + if (ret != OK) + return ret; const uint8_t* old_start = old_stream->Buffer(); size_t old_size = old_stream->Remaining(); - if (old_size != header.slen) return UNEXPECTED_ERROR; + if (old_size != header.slen) + return UNEXPECTED_ERROR; if (CalculateCrc(old_start, old_size) != header.scrc32) return CRC_ERROR; @@ -196,17 +199,15 @@ // Set up the new stream and apply the patch. SinkStream new_sink_stream; - BSDiffStatus status = ApplyBinaryPatch(&old_file_stream, - &patch_file_stream, - &new_sink_stream); + BSDiffStatus status = + ApplyBinaryPatch(&old_file_stream, &patch_file_stream, &new_sink_stream); if (status != OK) { return status; } // Write the stream to disk. int written = base::WriteFile( - new_file_path, - reinterpret_cast<const char*>(new_sink_stream.Buffer()), + new_file_path, reinterpret_cast<const char*>(new_sink_stream.Buffer()), static_cast<int>(new_sink_stream.Length())); if (written != static_cast<int>(new_sink_stream.Length())) return WRITE_ERROR;
diff --git a/courgette/third_party/bsdiff_create.cc b/courgette/third_party/bsdiff/bsdiff_create.cc similarity index 86% rename from courgette/third_party/bsdiff_create.cc rename to courgette/third_party/bsdiff/bsdiff_create.cc index 87b8ab4e..46a32b8 100644 --- a/courgette/third_party/bsdiff_create.cc +++ b/courgette/third_party/bsdiff/bsdiff_create.cc
@@ -26,7 +26,7 @@ --Samuel Huang <huangs@chromium.org> */ -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" #include <stddef.h> #include <stdint.h> @@ -39,8 +39,8 @@ #include "courgette/crc.h" #include "courgette/streams.h" -#include "courgette/third_party/paged_array.h" -#include "courgette/third_party/qsufsort.h" +#include "courgette/third_party/bsdiff/paged_array.h" +#include "courgette/third_party/bsdiff/qsufsort.h" namespace courgette { @@ -54,8 +54,7 @@ BSDiffStatus CreateBinaryPatch(SourceStream* old_stream, SourceStream* new_stream, - SinkStream* patch_stream) -{ + SinkStream* patch_stream) { base::Time start_bsdiff_time = base::Time::Now(); VLOG(1) << "Start bsdiff"; size_t initial_patch_stream_length = patch_stream->Length(); @@ -140,7 +139,6 @@ // ssssssssssss |lastscan = scan - lenb| is new seed. // x Cases (1) and (3) .... - int lastscan = 0, lastpos = 0, lastoffset = 0; int scan = 0; @@ -152,11 +150,11 @@ // extend the match at |lastscan|. scan += match_length; - for (int scsc = scan; scan < newsize; ++scan) { + for (int scsc = scan; scan < newsize; ++scan) { match_length = qsuf::search<PagedArray<int>&>( I, old, oldsize, newbuf + scan, newsize - scan, &pos); - for ( ; scsc < scan + match_length ; scsc++) + for (; scsc < scan + match_length; scsc++) if ((scsc + lastoffset < oldsize) && (old[scsc + lastoffset] == newbuf[scsc])) oldscore++; @@ -185,9 +183,13 @@ int lenb = 0; if (scan < newsize) { // i.e. not case (4); there is a match to extend. int score = 0, Sb = 0; - for (int i = 1; (scan >= lastscan + i) && (pos >= i); i++) { - if (old[pos - i] == newbuf[scan - i]) score++; - if (score*2 - i > Sb*2 - lenb) { Sb = score; lenb = i; } + for (int i = 1; (scan >= lastscan + i) && (pos >= i); i++) { + if (old[pos - i] == newbuf[scan - i]) + score++; + if (score * 2 - i > Sb * 2 - lenb) { + Sb = score; + lenb = i; + } } } @@ -200,10 +202,14 @@ int lenf = 0; { int score = 0, Sf = 0; - for (int i = 0; (lastscan + i < scan) && (lastpos + i < oldsize); ) { - if (old[lastpos + i] == newbuf[lastscan + i]) score++; + for (int i = 0; (lastscan + i < scan) && (lastpos + i < oldsize);) { + if (old[lastpos + i] == newbuf[lastscan + i]) + score++; i++; - if (score*2 - i > Sf*2 - lenf) { Sf = score; lenf = i; } + if (score * 2 - i > Sf * 2 - lenf) { + Sf = score; + lenf = i; + } } } @@ -213,18 +219,25 @@ int overlap = (lastscan + lenf) - (scan - lenb); int score = 0; int Ss = 0, lens = 0; - for (int i = 0; i < overlap; i++) { + for (int i = 0; i < overlap; i++) { if (newbuf[lastscan + lenf - overlap + i] == - old[lastpos + lenf - overlap + i]) score++; - if (newbuf[scan - lenb + i] == old[pos - lenb + i]) score--; - if (score > Ss) { Ss = score; lens = i + 1; } + old[lastpos + lenf - overlap + i]) { + score++; + } + if (newbuf[scan - lenb + i] == old[pos - lenb + i]) { + score--; + } + if (score > Ss) { + Ss = score; + lens = i + 1; + } } lenf += lens - overlap; lenb -= lens; }; - for (int i = 0; i < lenf; i++) { + for (int i = 0; i < lenf; i++) { uint8_t diff_byte = newbuf[lastscan + i] - old[lastpos + i]; if (diff_byte) { ++diff_bytes_nonzero; @@ -238,7 +251,7 @@ } } int gap = (scan - lenb) - (lastscan + lenf); - for (int i = 0; i < gap; i++) { + for (int i = 0; i < gap; i++) { if (!extra_bytes->Write(&newbuf[lastscan + lenf + i], 1)) return MEM_ERROR; } @@ -258,13 +271,13 @@ ++control_length; #ifdef DEBUG_bsmedberg - VLOG(1) << StringPrintf("Writing a block: copy: %-8u extra: %-8u seek: " - "%+-9d", copy_count, extra_count, - seek_adjustment); + VLOG(1) << StringPrintf( + "Writing a block: copy: %-8u extra: %-8u seek: %+-9d", copy_count, + extra_count, seek_adjustment); #endif - lastscan = scan - lenb; // Include the backward extension in seed. - lastpos = pos - lenb; // ditto. + lastscan = scan - lenb; // Include the backward extension in seed. + lastpos = pos - lenb; // ditto. lastoffset = lastpos - lastscan; } } @@ -279,9 +292,9 @@ static_assert(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header.tag), "MBS_PATCH_HEADER_TAG must match header field size"); memcpy(header.tag, MBS_PATCH_HEADER_TAG, sizeof(header.tag)); - header.slen = oldsize; - header.scrc32 = CalculateCrc(old, oldsize); - header.dlen = newsize; + header.slen = oldsize; + header.scrc32 = CalculateCrc(old, oldsize); + header.dlen = newsize; if (!WriteHeader(patch_stream, &header)) return MEM_ERROR;
diff --git a/courgette/third_party/paged_array.h b/courgette/third_party/bsdiff/paged_array.h similarity index 90% rename from courgette/third_party/paged_array.h rename to courgette/third_party/bsdiff/paged_array.h index 48a92f1..27c3c0b 100644 --- a/courgette/third_party/paged_array.h +++ b/courgette/third_party/bsdiff/paged_array.h
@@ -6,10 +6,10 @@ // // PagedArray is a work-around to allow large arrays to be allocated when there // is too much address space fragmentation for allocating the large arrays as -// contigous arrays. +// contiguous arrays. -#ifndef COURGETTE_BSDIFF_PAGED_ARRAY_H_ -#define COURGETTE_BSDIFF_PAGED_ARRAY_H_ +#ifndef COURGETTE_THIRD_PARTY_BSDIFF_PAGED_ARRAY_H_ +#define COURGETTE_THIRD_PARTY_BSDIFF_PAGED_ARRAY_H_ #include <stddef.h> @@ -19,7 +19,7 @@ namespace courgette { // PagedArray implements an array stored using many fixed-size pages. -template<typename T> +template <typename T> class PagedArray { enum { // Page size in elements. Page size of 2^18 * sizeof(T) is 1MB for T = int. @@ -80,5 +80,6 @@ DISALLOW_COPY_AND_ASSIGN(PagedArray); }; -} // namespace -#endif // COURGETTE_BSDIFF_PAGED_ARRAY_H_ + +} // namespace courgette +#endif // COURGETTE_THIRD_PARTY_BSDIFF_PAGED_ARRAY_H_
diff --git a/courgette/third_party/paged_array_unittest.cc b/courgette/third_party/bsdiff/paged_array_unittest.cc similarity index 95% rename from courgette/third_party/paged_array_unittest.cc rename to courgette/third_party/bsdiff/paged_array_unittest.cc index faa5548..7ae4f1c 100644 --- a/courgette/third_party/paged_array_unittest.cc +++ b/courgette/third_party/bsdiff/paged_array_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "courgette/third_party/paged_array.h" +#include "courgette/third_party/bsdiff/paged_array.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/courgette/third_party/qsufsort.h b/courgette/third_party/bsdiff/qsufsort.h similarity index 70% rename from courgette/third_party/qsufsort.h rename to courgette/third_party/bsdiff/qsufsort.h index 7bb46df..ce4d7e57 100644 --- a/courgette/third_party/qsufsort.h +++ b/courgette/third_party/bsdiff/qsufsort.h
@@ -23,6 +23,9 @@ --Samuel Huang <huangs@chromium.org> */ +#ifndef COURGETTE_THIRD_PARTY_BSDIFF_QSUFSORT_H_ +#define COURGETTE_THIRD_PARTY_BSDIFF_QSUFSORT_H_ + #include <algorithm> #include <cstring> @@ -34,7 +37,7 @@ // The following code is taken verbatim from 'bsdiff.c'. Please keep all the // code formatting and variable names. The changes from the original are: // (1) replacing tabs with spaces, -// (2) indentation, +// (2) indentation and spacing, // (3) using 'const', // (4) changing the V and I parameters from int* to template <typename T>. // (5) optimizing split() and search(); fix styles. @@ -45,7 +48,8 @@ namespace { -template <typename T> T median3(const T& a, const T& b, const T& c) { +template <typename T> +T median3(const T& a, const T& b, const T& c) { if (a < b) return b < c ? b : (a < c ? c : a); return b > c ? b : (a > c ? c : a); @@ -53,10 +57,11 @@ } // namespace -template <typename T> void split(T I, T V, int start, int end, int h) { +template <typename T> +void split(T I, T V, int start, int end, int h) { // For small interval, apply selection sort. if (end - start < 16) { - for (int i = start; i < end; ) { + for (int i = start; i < end;) { int skip = 1; int best = V[I[i] + h]; for (int j = i + 1; j < end; j++) { @@ -106,7 +111,7 @@ // [k, end) with secondary keys > pivot. int j = start; int k = end; - for (int i = start; i < k; ) { + for (int i = start; i < k;) { int cur = V[I[i] + h]; if (cur < pivot) { if (i != j) { @@ -145,64 +150,79 @@ } template <class T> -static void -qsufsort(T I, T V,const unsigned char *old,int oldsize) -{ +static void qsufsort(T I, T V, const unsigned char* old, int oldsize) { int buckets[256]; - int i,h,len; + int i, h, len; - for(i=0;i<256;i++) buckets[i]=0; - for(i=0;i<oldsize;i++) buckets[old[i]]++; - for(i=1;i<256;i++) buckets[i]+=buckets[i-1]; - for(i=255;i>0;i--) buckets[i]=buckets[i-1]; - buckets[0]=0; + for (i = 0; i < 256; i++) + buckets[i] = 0; + for (i = 0; i < oldsize; i++) + buckets[old[i]]++; + for (i = 1; i < 256; i++) + buckets[i] += buckets[i - 1]; + for (i = 255; i > 0; i--) + buckets[i] = buckets[i - 1]; + buckets[0] = 0; - for(i=0;i<oldsize;i++) I[++buckets[old[i]]]=i; - I[0]=oldsize; - for(i=0;i<oldsize;i++) V[i]=buckets[old[i]]; - V[oldsize]=0; - for(i=1;i<256;i++) if(buckets[i]==buckets[i-1]+1) I[buckets[i]]=-1; - I[0]=-1; + for (i = 0; i < oldsize; i++) + I[++buckets[old[i]]] = i; + I[0] = oldsize; + for (i = 0; i < oldsize; i++) + V[i] = buckets[old[i]]; + V[oldsize] = 0; + for (i = 1; i < 256; i++) + if (buckets[i] == buckets[i - 1] + 1) + I[buckets[i]] = -1; + I[0] = -1; - for(h=1;I[0]!=-(oldsize+1);h+=h) { - len=0; - for(i=0;i<oldsize+1;) { - if(I[i]<0) { - len-=I[i]; - i-=I[i]; + for (h = 1; I[0] != -(oldsize + 1); h += h) { + len = 0; + for (i = 0; i < oldsize + 1;) { + if (I[i] < 0) { + len -= I[i]; + i -= I[i]; } else { - if(len) I[i-len]=-len; - len=V[I[i]]+1-i; - split<T>(I,V,i,i+len,h); - i+=len; - len=0; + if (len) + I[i - len] = -len; + len = V[I[i]] + 1 - i; + split<T>(I, V, i, i + len, h); + i += len; + len = 0; }; }; - if(len) I[i-len]=-len; + if (len) + I[i - len] = -len; }; - for(i=0;i<oldsize+1;i++) I[V[i]]=i; + for (i = 0; i < oldsize + 1; i++) + I[V[i]] = i; } -static int -matchlen(const unsigned char *old,int oldsize,const unsigned char *newbuf,int newsize) -{ +static int matchlen(const unsigned char* old, + int oldsize, + const unsigned char* newbuf, + int newsize) { int i; - for(i=0;(i<oldsize)&&(i<newsize);i++) - if(old[i]!=newbuf[i]) break; + for (i = 0; (i < oldsize) && (i < newsize); i++) + if (old[i] != newbuf[i]) + break; return i; } template <class T> -static int search(T I, const unsigned char *old, int oldsize, - const unsigned char *newbuf, int newsize, int *pos) { +static int search(T I, + const unsigned char* old, + int oldsize, + const unsigned char* newbuf, + int newsize, + int* pos) { int lo = 0; int hi = oldsize; while (hi - lo >= 2) { int mid = (lo + hi) / 2; - if(memcmp(old+I[mid],newbuf,std::min(oldsize-I[mid],newsize))<0) { + if (memcmp(old + I[mid], newbuf, std::min(oldsize - I[mid], newsize)) < 0) { lo = mid; } else { hi = mid; @@ -211,7 +231,7 @@ int x = matchlen(old + I[lo], oldsize - I[lo], newbuf, newsize); int y = matchlen(old + I[hi], oldsize - I[hi], newbuf, newsize); - if(x > y) { + if (x > y) { *pos = I[lo]; return x; } @@ -224,3 +244,4 @@ } // namespace qsuf } // namespace courgette +#endif // COURGETTE_THIRD_PARTY_BSDIFF_QSUFSORT_H_
diff --git a/courgette/third_party/bsdiff/qsufsort_unittest.cc b/courgette/third_party/bsdiff/qsufsort_unittest.cc new file mode 100644 index 0000000..4e49fe2 --- /dev/null +++ b/courgette/third_party/bsdiff/qsufsort_unittest.cc
@@ -0,0 +1,137 @@ +// 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 "courgette/third_party/bsdiff/qsufsort.h" + +#include <stddef.h> + +#include <algorithm> +#include <cstring> +#include <string> +#include <vector> + +#include "base/macros.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(QSufSortTest, Sort) { + const char* test_cases[] = { + "", + "a", + "za", + "CACAO", + "banana", + "tobeornottobe", + "The quick brown fox jumps over the lazy dog.", + "elephantelephantelephantelephantelephant", + "-------------------------", + "011010011001011010010110011010010", + "3141592653589793238462643383279502884197169399375105", + "\xFF\xFE\xFF\xFE\xFD\x80\x30\x31\x32\x80\x30\xFF\x01\xAB\xCD", + }; + + for (size_t idx = 0; idx < arraysize(test_cases); ++idx) { + int len = static_cast<int>(::strlen(test_cases[idx])); + const unsigned char* s = + reinterpret_cast<const unsigned char*>(test_cases[idx]); + + // Generate the suffix array as I. + std::vector<int> I(len + 1); + std::vector<int> V(len + 1); + courgette::qsuf::qsufsort<int*>(&I[0], &V[0], s, len); + + // Expect that I[] is a permutation of [0, len]. + std::vector<int> I_sorted(I); + std::sort(I_sorted.begin(), I_sorted.end()); + for (int i = 0; i < len + 1; ++i) { + EXPECT_EQ(i, I_sorted[i]) << "test_case[" << idx << "]"; + } + + // First string must be empty string. + EXPECT_EQ(len, I[0]) << "test_case[" << idx << "]"; + + // Expect that the |len + 1| suffixes are strictly ordered. + const unsigned char* end = s + len; + for (int i = 0; i < len; ++i) { + const unsigned char* suf1 = s + I[i]; + const unsigned char* suf2 = s + I[i + 1]; + bool is_less = std::lexicographical_compare(suf1, end, suf2, end); + EXPECT_TRUE(is_less) << "test_case[" << idx << "]"; + } + } +} + +TEST(QSufSortTest, Search) { + // Initialize main string and the suffix array. + // Positions: 00000000001111111111122222222233333333334444 + // 01234567890123456789012345678901234567890123 + const char* old_str = "the quick brown fox jumps over the lazy dog."; + int old_size = static_cast<int>(::strlen(old_str)); + const unsigned char* old_buf = + reinterpret_cast<const unsigned char*>(old_str); + std::vector<int> I(old_size + 1); + std::vector<int> V(old_size + 1); + courgette::qsuf::qsufsort<int*>(&I[0], &V[0], old_buf, old_size); + + // Test queries. + const struct { + int exp_pos; // -1 means "don't care". + int exp_match_len; + const char* query_str; + } test_cases[] = { + // Entire string. + {0, 44, "the quick brown fox jumps over the lazy dog."}, + // Empty string. + {-1, 0, ""}, // Current algorithm does not enforce |pos| == 0. + // Exact and unique suffix match. + {43, 1, "."}, + {31, 13, "the lazy dog."}, + // Exact and unique non-suffix match. + {4, 5, "quick"}, + {0, 9, "the quick"}, // Unique prefix. + // Entire word match with mutiple results: take lexicographical first. + {31, 3, "the"}, // Non-unique prefix: "the l"... < "the q"... + {9, 1, " "}, // " brown"... wins. + // Partial and unique match of query prefix. + {16, 10, "fox jumps with the hosps"}, + // Partial and multiple match of query prefix: no guarantees on |pos|. + // Take lexicographical first for matching portion *only*, so same + // results: + {-1, 4, "the apple"}, // query < "the l"... < "the q"... + {-1, 4, "the opera"}, // "the l"... < query < "the q"... + {-1, 4, "the zebra"}, // "the l"... < "the q"... < query + // Prefix match dominates suffix match. + {26, 5, "over quick brown fox"}, + // No match. + {-1, 0, ","}, + {-1, 0, "1234"}, + {-1, 0, "THE QUICK BROWN FOX"}, + {-1, 0, "(the"}, + }; + + for (size_t idx = 0; idx < arraysize(test_cases); ++idx) { + const auto& test_case = test_cases[idx]; + int new_size = static_cast<int>(::strlen(test_case.query_str)); + const unsigned char* new_buf = + reinterpret_cast<const unsigned char*>(test_case.query_str); + + // Perform the search. + int pos = 0; + int match_len = courgette::qsuf::search(&I[0], old_buf, old_size, new_buf, + new_size, &pos); + + // Check basic properties and match with expected values. + EXPECT_GE(match_len, 0) << "test_case[" << idx << "]"; + EXPECT_LE(match_len, new_size) << "test_case[" << idx << "]"; + if (match_len > 0) { + EXPECT_GE(pos, 0) << "test_case[" << idx << "]"; + EXPECT_LE(pos, old_size - match_len) << "test_case[" << idx << "]"; + EXPECT_EQ(0, ::memcmp(old_buf + pos, new_buf, match_len)) << "test_case[" + << idx << "]"; + } + if (test_case.exp_pos >= 0) { + EXPECT_EQ(test_case.exp_pos, pos) << "test_case[" << idx << "]"; + } + EXPECT_EQ(test_case.exp_match_len, match_len) << "test_case[" << idx << "]"; + } +}
diff --git a/courgette/third_party/qsufsort_unittest.cc b/courgette/third_party/qsufsort_unittest.cc deleted file mode 100644 index 204a09cd..0000000 --- a/courgette/third_party/qsufsort_unittest.cc +++ /dev/null
@@ -1,136 +0,0 @@ -// 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 "courgette/third_party/qsufsort.h" - -#include <stddef.h> - -#include <algorithm> -#include <cstring> -#include <string> -#include <vector> - -#include "base/macros.h" -#include "testing/gtest/include/gtest/gtest.h" - -TEST(QSufSortTest, Sort) { - const char* test_cases[] = { - "", - "a", - "za", - "CACAO", - "banana", - "tobeornottobe", - "The quick brown fox jumps over the lazy dog.", - "elephantelephantelephantelephantelephant", - "-------------------------", - "011010011001011010010110011010010", - "3141592653589793238462643383279502884197169399375105", - "\xFF\xFE\xFF\xFE\xFD\x80\x30\x31\x32\x80\x30\xFF\x01\xAB\xCD", - }; - - for (size_t idx = 0; idx < arraysize(test_cases); ++idx) { - int len = static_cast<int>(::strlen(test_cases[idx])); - const unsigned char* s = - reinterpret_cast<const unsigned char*>(test_cases[idx]); - - // Generate the suffix array as I. - std::vector<int> I(len + 1); - std::vector<int> V(len + 1); - courgette::qsuf::qsufsort<int*>(&I[0], &V[0], s, len); - - // Expect that I[] is a permutation of [0, len]. - std::vector<int> I_sorted(I); - std::sort(I_sorted.begin(), I_sorted.end()); - for (int i = 0; i < len + 1; ++i) { - EXPECT_EQ(i, I_sorted[i]) << "test_case[" << idx << "]"; - } - - // First string must be empty string. - EXPECT_EQ(len, I[0]) << "test_case[" << idx << "]"; - - // Expect that the |len + 1| suffixes are strictly ordered. - const unsigned char* end = s + len; - for (int i = 0; i < len; ++i) { - const unsigned char* suf1 = s + I[i]; - const unsigned char* suf2 = s + I[i + 1]; - bool is_less = std::lexicographical_compare(suf1, end, suf2, end); - EXPECT_TRUE(is_less) << "test_case[" << idx << "]"; - } - } -} - -TEST(QSufSortTest, Search) { - // Initialize main string and the suffix array. - // Positions: 00000000001111111111122222222233333333334444 - // 01234567890123456789012345678901234567890123 - const char* old_str = "the quick brown fox jumps over the lazy dog."; - int old_size = static_cast<int>(::strlen(old_str)); - const unsigned char* old_buf = - reinterpret_cast<const unsigned char*>(old_str); - std::vector<int> I(old_size + 1); - std::vector<int> V(old_size + 1); - courgette::qsuf::qsufsort<int*>(&I[0], &V[0], old_buf, old_size); - - // Test queries. - const struct { - int exp_pos; // -1 means "don't care". - int exp_match_len; - const char* query_str; - } test_cases[] = { - // Entire string. - {0, 44, "the quick brown fox jumps over the lazy dog."}, - // Empty string. - {-1, 0, ""}, // Current algorithm does not enforce |pos| == 0. - // Exact and unique suffix match. - {43, 1, "."}, - {31, 13, "the lazy dog."}, - // Exact and unique non-suffix match. - {4, 5, "quick"}, - {0, 9, "the quick"}, // Unique prefix. - // Entire word match with mutiple results: take lexicographical first. - {31, 3, "the"}, // Non-unique prefix: "the l"... < "the q"... - {9, 1, " "}, // " brown"... wins. - // Partial and unique match of query prefix. - {16, 10, "fox jumps with the hosps"}, - // Partial and multiple match of query prefix: no guarantees on |pos|. - // Take lexicographical first for matching portion *only*, so same results: - {-1, 4, "the apple"}, // query < "the l"... < "the q"... - {-1, 4, "the opera"}, // "the l"... < query < "the q"... - {-1, 4, "the zebra"}, // "the l"... < "the q"... < query - // Prefix match dominates suffix match. - {26, 5, "over quick brown fox"}, - // No match. - {-1, 0, ","}, - {-1, 0, "1234"}, - {-1, 0, "THE QUICK BROWN FOX"}, - {-1, 0, "(the"}, - }; - - for (size_t idx = 0; idx < arraysize(test_cases); ++idx) { - const auto& test_case = test_cases[idx]; - int new_size = static_cast<int>(::strlen(test_case.query_str)); - const unsigned char* new_buf = - reinterpret_cast<const unsigned char*>(test_case.query_str); - - // Perform the search. - int pos = 0; - int match_len = courgette::qsuf::search( - &I[0], old_buf, old_size, new_buf, new_size, &pos); - - // Check basic properties and match with expected values. - EXPECT_GE(match_len, 0) << "test_case[" << idx << "]"; - EXPECT_LE(match_len, new_size) << "test_case[" << idx << "]"; - if (match_len > 0) { - EXPECT_GE(pos, 0) << "test_case[" << idx << "]"; - EXPECT_LE(pos, old_size - match_len) << "test_case[" << idx << "]"; - EXPECT_EQ(0, ::memcmp(old_buf + pos, new_buf, match_len)) - << "test_case[" << idx << "]"; - } - if (test_case.exp_pos >= 0) { - EXPECT_EQ(test_case.exp_pos, pos) << "test_case[" << idx << "]"; - } - EXPECT_EQ(test_case.exp_match_len, match_len) << "test_case[" << idx << "]"; - } -}
diff --git a/courgette/versioning_unittest.cc b/courgette/versioning_unittest.cc index 655aa93..3a3a4cb 100644 --- a/courgette/versioning_unittest.cc +++ b/courgette/versioning_unittest.cc
@@ -10,7 +10,7 @@ #include "courgette/courgette.h" #include "courgette/streams.h" -#include "courgette/third_party/bsdiff.h" +#include "courgette/third_party/bsdiff/bsdiff.h" class VersioningTest : public BaseTest { public:
diff --git a/gpu/gles2_conform_support/gles2_conform_test_expectations.txt b/gpu/gles2_conform_support/gles2_conform_test_expectations.txt index 1e78fe8..5a604e6 100644 --- a/gpu/gles2_conform_support/gles2_conform_test_expectations.txt +++ b/gpu/gles2_conform_support/gles2_conform_test_expectations.txt
@@ -24,6 +24,8 @@ // 91531 MAC WIN LINUX : conformance_more_* = SKIP // 91532 MAC NVIDIA 0x0640 : tex_image_and_sub_image_2d_with_video = PASS FAIL +612551 WIN LINUX MAC CHROMEOS : GL2ExtensionTests_egl_image_input_run = SKIP + 517966 WIN OPENGL : GL2FixedTests_blend_input_run = FAIL 517966 WIN OPENGL : GL2FixedTests_buffer_clear_input_run = FAIL 517966 WIN OPENGL : GL2FixedTests_buffer_color_input_run = FAIL
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn index 749eff6a..4cfffa3 100644 --- a/ios/web/BUILD.gn +++ b/ios/web/BUILD.gn
@@ -281,6 +281,22 @@ ] } +source_set("earl_grey_test_support") { + testonly = true + + deps = [ + ":test_support", + "//ios/third_party/earl_grey", + ] + + sources = [ + "public/test/earl_grey/web_view_matchers.h", + "public/test/earl_grey/web_view_matchers.mm", + "public/test/web_view_interaction_test_util.h", + "public/test/web_view_interaction_test_util.mm", + ] +} + source_set("test_support") { testonly = true
diff --git a/ios/web/ios_web.gyp b/ios/web/ios_web.gyp index a0e12728..5b5963b 100644 --- a/ios/web/ios_web.gyp +++ b/ios/web/ios_web.gyp
@@ -430,6 +430,21 @@ ], }, { + # GN version: //ios/web:earl_grey_test_support + 'target_name': 'ios_web_earl_grey_test_support', + 'type': 'static_library', + 'dependencies': [ + 'ios_web_test_support', + '<(DEPTH)/ios/third_party/earl_grey/earl_grey.gyp:EarlGrey', + ], + 'sources': [ + 'public/test/earl_grey/web_view_matchers.h', + 'public/test/earl_grey/web_view_matchers.mm', + 'public/test/web_view_interaction_test_util.h', + 'public/test/web_view_interaction_test_util.mm', + ], + }, + { # GN version: //ios/web:test_support 'target_name': 'ios_web_test_support', 'type': 'static_library',
diff --git a/ios/web/ios_web_shell_tests.gyp b/ios/web/ios_web_shell_tests.gyp index 14297352..8505ae4 100644 --- a/ios/web/ios_web_shell_tests.gyp +++ b/ios/web/ios_web_shell_tests.gyp
@@ -58,6 +58,7 @@ }, 'dependencies': [ 'ios_web_shell_earl_grey_test_support', + '<(DEPTH)/ios/third_party/earl_grey/earl_grey.gyp:EarlGrey', ], 'sources': [ 'shell/test/web_shell_navigation_egtest.mm', @@ -104,19 +105,16 @@ 'type': 'static_library', 'dependencies': [ '<(DEPTH)/ios/third_party/earl_grey/earl_grey.gyp:EarlGrey', - 'ios_web.gyp:ios_web_test_support', + 'ios_web.gyp:ios_web_earl_grey_test_support', '../testing/earl_grey/earl_grey_support.gyp:earl_grey_support', ], - 'export_dependent_settings': [ - '<(DEPTH)/ios/third_party/earl_grey/earl_grey.gyp:EarlGrey', - ], 'sources': [ - 'public/test/earl_grey/web_view_matchers.h', - 'public/test/earl_grey/web_view_matchers.mm', - 'public/test/web_view_interaction_test_util.h', - 'public/test/web_view_interaction_test_util.mm', + 'shell/test/app/navigation_test_util.h', + 'shell/test/app/navigation_test_util.mm', 'shell/test/app/web_shell_test_util.h', 'shell/test/app/web_shell_test_util.mm', + 'shell/test/app/web_view_interaction_test_util.h', + 'shell/test/app/web_view_interaction_test_util.mm', 'shell/test/earl_grey/shell_matchers.h', 'shell/test/earl_grey/shell_matchers.mm', ],
diff --git a/ios/web/public/test/navigation_test_util.h b/ios/web/public/test/navigation_test_util.h index 7b4886d..3fe85f5f5 100644 --- a/ios/web/public/test/navigation_test_util.h +++ b/ios/web/public/test/navigation_test_util.h
@@ -9,12 +9,12 @@ #include "url/gurl.h" namespace web { -namespace navigation_test_util { +namespace test { // Loads |url| in |web_state| with transition of type ui::PAGE_TRANSITION_TYPED. void LoadUrl(web::WebState* web_state, const GURL& url); -} // namespace navigation_test_util +} // namespace test } // namespace web #endif // IOS_WEB_SHELL_PUBLIC_TEST_NAVIGATION_TEST_UTIL_H_ \ No newline at end of file
diff --git a/ios/web/public/test/navigation_test_util.mm b/ios/web/public/test/navigation_test_util.mm index bf9299081..497d9b2 100644 --- a/ios/web/public/test/navigation_test_util.mm +++ b/ios/web/public/test/navigation_test_util.mm
@@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ios/web/public/test/navigation_test_util.h" +#import "ios/web/public/test/navigation_test_util.h" #import "ios/web/public/navigation_manager.h" using web::NavigationManager; namespace web { -namespace navigation_test_util { +namespace test { void LoadUrl(web::WebState* web_state, const GURL& url) { NavigationManager* navigation_manager = web_state->GetNavigationManager(); @@ -18,5 +18,5 @@ navigation_manager->LoadURLWithParams(params); } -} // namespace navigation_test_util +} // namespace test } // namespace web \ No newline at end of file
diff --git a/ios/web/shell/test/app/navigation_test_util.h b/ios/web/shell/test/app/navigation_test_util.h new file mode 100644 index 0000000..fc94394ff --- /dev/null +++ b/ios/web/shell/test/app/navigation_test_util.h
@@ -0,0 +1,20 @@ +// 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 IOS_WEB_SHELL_TEST_APP_NAVIGATION_TEST_UTIL_H_ +#define IOS_WEB_SHELL_TEST_APP_NAVIGATION_TEST_UTIL_H_ + +#include "url/gurl.h" + +namespace web { +namespace shell_test_util { + +// Loads |url| in the current WebState with transition of type +// ui::PAGE_TRANSITION_TYPED. +void LoadUrl(const GURL& url); + +} // namespace shell_test_util +} // namespace web + +#endif // IOS_WEB_SHELL_TEST_APP_NAVIGATION_TEST_UTIL_H_ \ No newline at end of file
diff --git a/ios/web/shell/test/app/navigation_test_util.mm b/ios/web/shell/test/app/navigation_test_util.mm new file mode 100644 index 0000000..908dab6 --- /dev/null +++ b/ios/web/shell/test/app/navigation_test_util.mm
@@ -0,0 +1,18 @@ +// 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 "ios/web/shell/test/app/navigation_test_util.h" + +#import "ios/web/public/test/navigation_test_util.h" +#import "ios/web/shell/test/app/web_shell_test_util.h" + +namespace web { +namespace shell_test_util { + +void LoadUrl(const GURL& url) { + web::test::LoadUrl(GetCurrentWebState(), url); +} + +} // namespace shell_test_util +} // namespace web
diff --git a/ios/web/shell/test/app/web_shell_test_util.h b/ios/web/shell/test/app/web_shell_test_util.h index 2a88d2a..a6ab360 100644 --- a/ios/web/shell/test/app/web_shell_test_util.h +++ b/ios/web/shell/test/app/web_shell_test_util.h
@@ -8,12 +8,12 @@ #import "ios/web/public/web_state/web_state.h" namespace web { -namespace web_shell_test_util { +namespace shell_test_util { // Gets the current WebState for the web shell. web::WebState* GetCurrentWebState(); -} // namespace web_shell_test_util +} // namespace shell_test_util } // namespace web #endif // IOS_WEB_SHELL_TEST_APP_WEB_SHELL_TEST_UTIL_H_ \ No newline at end of file
diff --git a/ios/web/shell/test/app/web_shell_test_util.mm b/ios/web/shell/test/app/web_shell_test_util.mm index 04128ef..23fbde6 100644 --- a/ios/web/shell/test/app/web_shell_test_util.mm +++ b/ios/web/shell/test/app/web_shell_test_util.mm
@@ -9,7 +9,7 @@ #import "ios/web/shell/view_controller.h" namespace web { -namespace web_shell_test_util { +namespace shell_test_util { web::WebState* GetCurrentWebState() { ViewController* view_controller = static_cast<ViewController*>([[ @@ -17,5 +17,5 @@ return view_controller.webState; } -} // namespace web_shell_test_util +} // namespace shell_test_util } // namespace web
diff --git a/ios/web/shell/test/app/web_view_interaction_test_util.h b/ios/web/shell/test/app/web_view_interaction_test_util.h new file mode 100644 index 0000000..54f003a9 --- /dev/null +++ b/ios/web/shell/test/app/web_view_interaction_test_util.h
@@ -0,0 +1,20 @@ +// 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 IOS_WEB_SHELL_TEST_APP_WEB_VIEW_INTERACTION_TEST_UTIL_H_ +#define IOS_WEB_SHELL_TEST_APP_WEB_VIEW_INTERACTION_TEST_UTIL_H_ + +#include <string> + +namespace web { +namespace shell_test_util { + +// Attempts to tap the element with |element_id| in the current WebState +// using a JavaScript click() event. +void TapWebViewElementWithId(const std::string& element_id); + +} // namespace shell_test_util +} // namespace web + +#endif // IOS_WEB_SHELL_TEST_APP_WEB_VIEW_INTERACTION_TEST_UTIL_H_ \ No newline at end of file
diff --git a/ios/web/shell/test/app/web_view_interaction_test_util.mm b/ios/web/shell/test/app/web_view_interaction_test_util.mm new file mode 100644 index 0000000..f7f72c3b --- /dev/null +++ b/ios/web/shell/test/app/web_view_interaction_test_util.mm
@@ -0,0 +1,18 @@ +// 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 "ios/web/shell/test/app/web_view_interaction_test_util.h" + +#import "ios/web/public/test/web_view_interaction_test_util.h" +#import "ios/web/shell/test/app/web_shell_test_util.h" + +namespace web { +namespace shell_test_util { + +void TapWebViewElementWithId(const std::string& element_id) { + web::test::TapWebViewElementWithId(GetCurrentWebState(), element_id); +} + +} // namespace shell_test_util +} // namespace web
diff --git a/ios/web/shell/test/earl_grey/shell_matchers.mm b/ios/web/shell/test/earl_grey/shell_matchers.mm index 8da81b6..ce7762dd3 100644 --- a/ios/web/shell/test/earl_grey/shell_matchers.mm +++ b/ios/web/shell/test/earl_grey/shell_matchers.mm
@@ -39,7 +39,7 @@ @implementation GREYMatchers (WebShellAdditions) + (id<GREYMatcher>)matcherForWebViewContainingText:(NSString*)text { - web::WebState* webState = web::web_shell_test_util::GetCurrentWebState(); + web::WebState* webState = web::shell_test_util::GetCurrentWebState(); return web::webViewContainingText(text, webState); }
diff --git a/ios/web/shell/test/web_shell_navigation_egtest.mm b/ios/web/shell/test/web_shell_navigation_egtest.mm index fad4316..9dc55a2 100644 --- a/ios/web/shell/test/web_shell_navigation_egtest.mm +++ b/ios/web/shell/test/web_shell_navigation_egtest.mm
@@ -11,9 +11,8 @@ #include "base/strings/sys_string_conversions.h" #import "ios/web/public/test/http_server.h" #include "ios/web/public/test/http_server_util.h" -#include "ios/web/public/test/navigation_test_util.h" -#import "ios/web/public/test/web_view_interaction_test_util.h" -#include "ios/web/shell/test/app/web_shell_test_util.h" +#include "ios/web/shell/test/app/navigation_test_util.h" +#include "ios/web/shell/test/app/web_view_interaction_test_util.h" #import "ios/web/shell/test/earl_grey/shell_matchers.h" // Navigation test cases for the web shell. These are Earl Grey integration @@ -55,16 +54,15 @@ "http://ios/web/shell/test/http_server_files/basic_navigation_test.html"); NSString* URLSpec = base::SysUTF8ToNSString(URL.spec()); web::test::SetUpFileBasedHttpServer(); - web::WebState* webState = web::web_shell_test_util::GetCurrentWebState(); // TODO(crbug.com/611515): Create web shell utility that only requires URL, // and gets the web state and passes it in to the web view utility. - web::navigation_test_util::LoadUrl(webState, URL); + web::shell_test_util::LoadUrl(URL); [[EarlGrey selectElementWithMatcher:web::addressFieldText(URLSpec)] assertWithMatcher:grey_notNil()]; - web::test::TapWebViewElementWithId(webState, - "basic-link-navigation-to-about-blank"); + web::shell_test_util::TapWebViewElementWithId( + "basic-link-navigation-to-about-blank"); [[EarlGrey selectElementWithMatcher:web::addressFieldText(@"about:blank")] assertWithMatcher:grey_notNil()]; @@ -86,15 +84,13 @@ web::test::SetUpSimpleHttpServer(responses); - web::WebState* webState = web::web_shell_test_util::GetCurrentWebState(); - - web::navigation_test_util::LoadUrl(webState, URL1); + web::shell_test_util::LoadUrl(URL1); [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1Text)] assertWithMatcher:grey_notNil()]; [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] assertWithMatcher:grey_notNil()]; - web::navigation_test_util::LoadUrl(webState, URL2); + web::shell_test_util::LoadUrl(URL2); [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] assertWithMatcher:grey_notNil()]; [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)]
diff --git a/net/cert/signed_tree_head.cc b/net/cert/signed_tree_head.cc index 8bf2b9f..1816446 100644 --- a/net/cert/signed_tree_head.cc +++ b/net/cert/signed_tree_head.cc
@@ -45,5 +45,19 @@ << "}"; } +bool operator==(const SignedTreeHead& lhs, const SignedTreeHead& rhs) { + return std::tie(lhs.version, lhs.timestamp, lhs.tree_size, lhs.log_id) == + std::tie(rhs.version, rhs.timestamp, rhs.tree_size, rhs.log_id) && + memcmp(lhs.sha256_root_hash, rhs.sha256_root_hash, + kSthRootHashLength) == 0 && + lhs.signature.SignatureParametersMatch( + rhs.signature.hash_algorithm, rhs.signature.signature_algorithm) && + lhs.signature.signature_data == rhs.signature.signature_data; +} + +bool operator!=(const SignedTreeHead& lhs, const SignedTreeHead& rhs) { + return !(lhs == rhs); +} + } // namespace ct } // namespace net
diff --git a/net/cert/signed_tree_head.h b/net/cert/signed_tree_head.h index 154c7a9..2d65192 100644 --- a/net/cert/signed_tree_head.h +++ b/net/cert/signed_tree_head.h
@@ -52,6 +52,11 @@ NET_EXPORT void PrintTo(const SignedTreeHead& sth, std::ostream* os); +NET_EXPORT bool operator==(const SignedTreeHead& lhs, + const SignedTreeHead& rhs); +NET_EXPORT bool operator!=(const SignedTreeHead& lhs, + const SignedTreeHead& rhs); + } // namespace ct } // namespace net
diff --git a/net/cert/sth_distributor.cc b/net/cert/sth_distributor.cc index 9d56c03..c511e27 100644 --- a/net/cert/sth_distributor.cc +++ b/net/cert/sth_distributor.cc
@@ -25,6 +25,16 @@ STHDistributor::~STHDistributor() {} void STHDistributor::NewSTHObserved(const SignedTreeHead& sth) { + auto it = std::find_if(observed_sths_.begin(), observed_sths_.end(), + [&sth](const SignedTreeHead& other) { + return sth.log_id == other.log_id; + }); + + if (it == observed_sths_.end()) + observed_sths_.push_back(sth); + else + *it = sth; + FOR_EACH_OBSERVER(STHObserver, observer_list_, NewSTHObserved(sth)); if (sth.log_id.compare(0, sth.log_id.size(), @@ -40,6 +50,13 @@ void STHDistributor::RegisterObserver(STHObserver* observer) { observer_list_.AddObserver(observer); + // Make a local copy, because notifying the |observer| of a + // new STH may result in this class being notified of a + // (different) new STH, thus invalidating the iterator. + std::vector<SignedTreeHead> local_sths(observed_sths_); + + for (const auto& sth : local_sths) + observer->NewSTHObserved(sth); } void STHDistributor::UnregisterObserver(STHObserver* observer) {
diff --git a/net/cert/sth_distributor.h b/net/cert/sth_distributor.h index 3d9691c..fee3a62d 100644 --- a/net/cert/sth_distributor.h +++ b/net/cert/sth_distributor.h
@@ -5,6 +5,8 @@ #ifndef NET_CERT_STH_DISTRIBUTOR_H_ #define NET_CERT_STH_DISTRIBUTOR_H_ +#include <vector> + #include "base/observer_list.h" #include "net/base/net_export.h" #include "net/cert/sth_observer.h" @@ -14,6 +16,8 @@ namespace ct { +struct SignedTreeHead; + // A proxy for delegating new STH notifications to all registered // observers. // For each |observer| registered with RegisterObserver, the @@ -28,10 +32,20 @@ void NewSTHObserved(const SignedTreeHead& sth) override; // STHReporter implementation + // Registers |observer| for new STH notifications. On registration, + // the |observer| will be notified of the latest STH for each log tha the + // STHDistributor has observed. void RegisterObserver(STHObserver* observer) override; + + // Unregisters |observer|, which must have been previously + // registered via RegisterObserver() void UnregisterObserver(STHObserver* observer) override; private: + // STHs from logs, one for each log. + std::vector<SignedTreeHead> observed_sths_; + + // The observers for new STH notifications. base::ObserverList<STHObserver> observer_list_; };
diff --git a/net/cert/sth_distributor_unittest.cc b/net/cert/sth_distributor_unittest.cc new file mode 100644 index 0000000..1dcecf6 --- /dev/null +++ b/net/cert/sth_distributor_unittest.cc
@@ -0,0 +1,133 @@ +// 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/cert/sth_distributor.h" + +#include <map> +#include <string> + +#include "base/test/histogram_tester.h" +#include "crypto/sha2.h" +#include "net/cert/signed_tree_head.h" +#include "net/cert/sth_observer.h" +#include "net/test/ct_test_util.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace net { + +namespace ct { + +namespace { + +// An STHObserver implementation that simply stores all +// observed STHs, keyed by log ID. +class StoringSTHObserver : public STHObserver { + public: + void NewSTHObserved(const SignedTreeHead& sth) override { + sths[sth.log_id] = sth; + } + + std::map<std::string, SignedTreeHead> sths; +}; + +class STHDistributorTest : public ::testing::Test { + public: + STHDistributorTest() {} + + void SetUp() override { + ASSERT_TRUE(GetSampleSignedTreeHead(&sample_sth_)); + sample_sth_.log_id = GetTestPublicKeyId(); + } + + protected: + STHDistributor distributor_; + SignedTreeHead sample_sth_; +}; + +// Test that when a new observer is registered, the STHDistributor notifies it +// of all the observed STHs it received so far. +// This test makes sure that all observed STHs are reported to the observer. +TEST_F(STHDistributorTest, NotifiesOfExistingSTHs) { + // Create an STH that differs from the |sample_sth_| by belonging to a + // different log. + const std::string other_log = "another log"; + SignedTreeHead second_sth(sample_sth_); + second_sth.log_id = other_log; + + // Notify |distributor_| of both STHs. + distributor_.NewSTHObserved(sample_sth_); + distributor_.NewSTHObserved(second_sth); + + StoringSTHObserver observer; + distributor_.RegisterObserver(&observer); + + // Check that two STHs from different logs received prior to observer + // registration were reported to the observer once registered. + EXPECT_EQ(2u, observer.sths.size()); + EXPECT_EQ(1u, observer.sths.count(other_log)); +} + +// Test that histograms are properly recorded for the STH age when an STH +// from Google's Pilot log is observed. +TEST_F(STHDistributorTest, LogsUMAForPilotSTH) { + const char kPilotSTHAgeHistogram[] = + "Net.CertificateTransparency.PilotSTHAge"; + base::HistogramTester histograms; + histograms.ExpectTotalCount(kPilotSTHAgeHistogram, 0); + + const uint8_t kPilotLogID[] = { + 0xa4, 0xb9, 0x09, 0x90, 0xb4, 0x18, 0x58, 0x14, 0x87, 0xbb, 0x13, + 0xa2, 0xcc, 0x67, 0x70, 0x0a, 0x3c, 0x35, 0x98, 0x04, 0xf9, 0x1b, + 0xdf, 0xb8, 0xe3, 0x77, 0xcd, 0x0e, 0xc8, 0x0d, 0xdc, 0x10}; + sample_sth_.log_id = std::string(reinterpret_cast<const char*>(kPilotLogID), + crypto::kSHA256Length); + + distributor_.NewSTHObserved(sample_sth_); + histograms.ExpectTotalCount(kPilotSTHAgeHistogram, 1); +} + +// Test that the STHDistributor updates, rather than accumulates, STHs +// coming from the same log. +// This is tested by notifying the STHDistributor of an STH, modifying that +// STH, notifying the STHDistributor of the modified STH, then registering +// an observer which should get notified only once, with the modified STH. +TEST_F(STHDistributorTest, UpdatesObservedSTHData) { + // Observe an initial STH + StoringSTHObserver observer; + distributor_.RegisterObserver(&observer); + + distributor_.NewSTHObserved(sample_sth_); + + EXPECT_EQ(1u, observer.sths.size()); + EXPECT_EQ(sample_sth_, observer.sths[GetTestPublicKeyId()]); + + // Observe a new STH. "new" simply means that it is a more recently observed + // SignedTreeHead for the given log ID, not necessarily that it's newer + // chronologically (the timestamp) or the log state (the tree size). + // To make sure the more recently observed SignedTreeHead is returned, just + // modify some fields. + SignedTreeHead new_sth = sample_sth_; + new_sth.tree_size++; + new_sth.timestamp -= base::TimeDelta::FromSeconds(3); + + distributor_.NewSTHObserved(new_sth); + // The STH should have been broadcast to existing observers. + EXPECT_EQ(1u, observer.sths.size()); + EXPECT_NE(sample_sth_, observer.sths[GetTestPublicKeyId()]); + EXPECT_EQ(new_sth, observer.sths[GetTestPublicKeyId()]); + + // Registering a new observer should only receive the most recently observed + // STH. + StoringSTHObserver new_observer; + distributor_.RegisterObserver(&new_observer); + EXPECT_EQ(1u, new_observer.sths.size()); + EXPECT_NE(sample_sth_, new_observer.sths[GetTestPublicKeyId()]); + EXPECT_EQ(new_sth, new_observer.sths[GetTestPublicKeyId()]); +} + +} // namespace + +} // namespace ct + +} // namespace net
diff --git a/net/net.gypi b/net/net.gypi index 4f34731..2b5540d 100644 --- a/net/net.gypi +++ b/net/net.gypi
@@ -1090,6 +1090,8 @@ 'spdy/buffered_spdy_framer.h', 'spdy/fuzzing/hpack_fuzz_util.cc', 'spdy/fuzzing/hpack_fuzz_util.h', + 'spdy/header_coalescer.cc', + 'spdy/header_coalescer.h', 'spdy/hpack/hpack_constants.cc', 'spdy/hpack/hpack_constants.h', 'spdy/hpack/hpack_decoder.cc', @@ -1383,6 +1385,7 @@ 'cert/nss_profile_filter_chromeos_unittest.cc', 'cert/pem_tokenizer_unittest.cc', 'cert/signed_certificate_timestamp_unittest.cc', + 'cert/sth_distributor_unittest.cc', 'cert/test_root_certs_unittest.cc', 'cert/x509_cert_types_unittest.cc', 'cert/x509_certificate_unittest.cc',
diff --git a/net/quic/quic_chromium_client_stream.cc b/net/quic/quic_chromium_client_stream.cc index 0f21d51..2b72c95 100644 --- a/net/quic/quic_chromium_client_stream.cc +++ b/net/quic/quic_chromium_client_stream.cc
@@ -60,6 +60,36 @@ } } +void QuicChromiumClientStream::OnInitialHeadersComplete( + bool fin, + size_t frame_len, + const QuicHeaderList& header_list) { + QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list); + + SpdyHeaderBlock header_block; + int64_t length = -1; + if (!SpdyUtils::CopyAndValidateHeaders(header_list, &length, &header_block)) { + DLOG(ERROR) << "Failed to parse header list: " << header_list.DebugString(); + ConsumeHeaderList(); + Reset(QUIC_BAD_APPLICATION_PAYLOAD); + return; + } + + ConsumeHeaderList(); + session_->OnInitialHeadersComplete(id(), header_block); + + // The delegate will read the headers via a posted task. + NotifyDelegateOfHeadersCompleteLater(header_block, frame_len); +} + +void QuicChromiumClientStream::OnTrailingHeadersComplete( + bool fin, + size_t frame_len, + const QuicHeaderList& header_list) { + QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len, header_list); + NotifyDelegateOfHeadersCompleteLater(received_trailers(), frame_len); +} + void QuicChromiumClientStream::OnPromiseHeadersComplete( QuicStreamId promised_id, size_t frame_len) { @@ -222,6 +252,7 @@ // Only mark trailers consumed when we are about to notify delegate. if (headers_delivered_) { MarkTrailersConsumed(decompressed_trailers().length()); + MarkTrailersDelivered(); net_log_.AddEvent( NetLog::TYPE_QUIC_CHROMIUM_CLIENT_STREAM_READ_RESPONSE_TRAILERS, base::Bind(&SpdyHeaderBlockNetLogCallback, &headers));
diff --git a/net/quic/quic_chromium_client_stream.h b/net/quic/quic_chromium_client_stream.h index 1a66865..ae70853 100644 --- a/net/quic/quic_chromium_client_stream.h +++ b/net/quic/quic_chromium_client_stream.h
@@ -63,6 +63,12 @@ // QuicSpdyStream void OnStreamHeadersComplete(bool fin, size_t frame_len) override; + void OnInitialHeadersComplete(bool fin, + size_t frame_len, + const QuicHeaderList& header_list) override; + void OnTrailingHeadersComplete(bool fin, + size_t frame_len, + const QuicHeaderList& header_list) override; void OnPromiseHeadersComplete(QuicStreamId promised_stream_id, size_t frame_len) override; void OnDataAvailable() override;
diff --git a/net/quic/quic_headers_stream.cc b/net/quic/quic_headers_stream.cc index 0e2da5e..7cc85983 100644 --- a/net/quic/quic_headers_stream.cc +++ b/net/quic/quic_headers_stream.cc
@@ -10,7 +10,6 @@ #include "net/quic/quic_bug_tracker.h" #include "net/quic/quic_flags.h" #include "net/quic/quic_header_list.h" -#include "net/quic/quic_headers_stream.h" #include "net/quic/quic_spdy_session.h" #include "net/quic/quic_time.h" @@ -375,6 +374,8 @@ } void QuicHeadersStream::OnHeaderList(const QuicHeaderList& header_list) { + DVLOG(1) << "Received header list for stream " << stream_id_ << ": " + << header_list.DebugString(); if (measure_headers_hol_blocking_time_) { if (prev_max_timestamp_ > cur_max_timestamp_) { // prev_max_timestamp_ > cur_max_timestamp_ implies that
diff --git a/net/quic/quic_headers_stream_test.cc b/net/quic/quic_headers_stream_test.cc index 469d70e..99b4948f 100644 --- a/net/quic/quic_headers_stream_test.cc +++ b/net/quic/quic_headers_stream_test.cc
@@ -23,6 +23,7 @@ using testing::ElementsAre; using testing::InSequence; using testing::Invoke; +using testing::Return; using testing::StrictMock; using testing::WithArgs; using testing::_; @@ -162,6 +163,29 @@ saved_header_data_.append(data.data(), data.length()); } + void SavePromiseHeaderList(QuicStreamId /* stream_id */, + QuicStreamId /* promised_stream_id */, + size_t size, + const QuicHeaderList& header_list) { + SaveToHandler(size, header_list); + } + + void SaveHeaderList(QuicStreamId /* stream_id */, + bool /* fin */, + size_t size, + const QuicHeaderList& header_list) { + SaveToHandler(size, header_list); + } + + void SaveToHandler(size_t size, const QuicHeaderList& header_list) { + headers_handler_.reset(new TestHeadersHandler); + headers_handler_->OnHeaderBlockStart(); + for (const auto& p : header_list) { + headers_handler_->OnHeader(p.first, p.second); + } + headers_handler_->OnHeaderBlockEnd(size); + } + void WriteHeadersAndExpectSynStream(QuicStreamId stream_id, bool fin, SpdyPriority priority) { @@ -194,9 +218,10 @@ /*parent_stream_id=*/0, /*exclusive=*/false, fin, kFrameComplete)); } - EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) - .WillRepeatedly(WithArgs<1, 2>( - Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); + headers_handler_.reset(new TestHeadersHandler); + EXPECT_CALL(visitor_, OnHeaderFrameStart(stream_id)) + .WillOnce(Return(headers_handler_.get())); + EXPECT_CALL(visitor_, OnHeaderFrameEnd(stream_id, true)).Times(1); if (fin) { EXPECT_CALL(visitor_, OnStreamEnd(stream_id)); } @@ -209,11 +234,8 @@ } void CheckHeaders() { - SpdyHeaderBlock headers; - EXPECT_TRUE(framer_->ParseHeaderBlockInBuffer( - saved_header_data_.data(), saved_header_data_.length(), &headers)); - EXPECT_EQ(headers_, headers); - saved_header_data_.clear(); + EXPECT_EQ(headers_, headers_handler_->decoded_block()); + headers_handler_.reset(); } Perspective perspective() { return GetParam().perspective; } @@ -241,6 +263,7 @@ StrictMock<MockQuicSpdySession> session_; QuicHeadersStream* headers_stream_; SpdyHeaderBlock headers_; + std::unique_ptr<TestHeadersHandler> headers_handler_; string body_; string saved_data_; string saved_header_data_; @@ -288,9 +311,10 @@ // Parse the outgoing data and check that it matches was was written. EXPECT_CALL(visitor_, OnPushPromise(stream_id, promised_stream_id, kFrameComplete)); - EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) - .WillRepeatedly(WithArgs<1, 2>( - Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); + headers_handler_.reset(new TestHeadersHandler); + EXPECT_CALL(visitor_, OnHeaderFrameStart(stream_id)) + .WillOnce(Return(headers_handler_.get())); + EXPECT_CALL(visitor_, OnHeaderFrameEnd(stream_id, true)).Times(1); framer_->ProcessInput(saved_data_.data(), saved_data_.length()); EXPECT_FALSE(framer_->HasError()) << SpdyFramer::ErrorCodeToString(framer_->error_code()); @@ -324,11 +348,9 @@ headers_frame.set_fin(fin); frame = framer_->SerializeFrame(headers_frame); } - EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)) - .WillRepeatedly(WithArgs<1>(Invoke( - this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece))); EXPECT_CALL(session_, - OnStreamHeadersComplete(stream_id, fin, frame.size())); + OnStreamHeaderList(stream_id, fin, frame.size(), _)) + .WillOnce(Invoke(this, &QuicHeadersStreamTest::SaveHeaderList)); stream_frame_.data_buffer = frame.data(); stream_frame_.data_length = frame.size(); headers_stream_->OnStreamFrame(stream_frame_); @@ -355,11 +377,10 @@ .WillRepeatedly(InvokeWithoutArgs( this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); } else { - EXPECT_CALL(session_, OnPromiseHeaders(stream_id, _)) - .WillRepeatedly(WithArgs<1>( - Invoke(this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece))); - EXPECT_CALL(session_, OnPromiseHeadersComplete( - stream_id, promised_stream_id, frame.size())); + EXPECT_CALL(session_, OnPromiseHeaderList(stream_id, promised_stream_id, + frame.size(), _)) + .WillOnce( + Invoke(this, &QuicHeadersStreamTest::SavePromiseHeaderList)); } stream_frame_.data_buffer = frame.data(); stream_frame_.data_length = frame.size(); @@ -395,9 +416,8 @@ headers_frame.set_fin(fin); frame = framer_->SerializeFrame(headers_frame); } - EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)); - EXPECT_CALL(session_, - OnStreamHeadersComplete(stream_id, fin, frame.size())); + EXPECT_CALL(session_, OnStreamHeaderList(stream_id, fin, frame.size(), _)) + .Times(1); stream_frame_.data_buffer = frame.data(); stream_frame_.data_length = frame.size(); headers_stream_->OnStreamFrame(stream_frame_); @@ -439,9 +459,7 @@ DVLOG(1) << "make frame for stream " << stream_num << " offset " << stream_frames[stream_num].offset; stream_frame_.offset += frames[stream_num].size(); - EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)).Times(1); - EXPECT_CALL(session_, OnStreamHeadersComplete(stream_id, fin, _)) - .Times(1); + EXPECT_CALL(session_, OnStreamHeaderList(stream_id, fin, _, _)).Times(1); } } @@ -482,11 +500,9 @@ headers_frame.set_fin(fin); frame = framer_->SerializeFrame(headers_frame); } - EXPECT_CALL(session_, OnStreamHeaders(stream_id, _)) - .WillRepeatedly(WithArgs<1>(Invoke( - this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece))); EXPECT_CALL(session_, - OnStreamHeadersComplete(stream_id, fin, frame.size())); + OnStreamHeaderList(stream_id, fin, frame.size(), _)) + .WillOnce(Invoke(this, &QuicHeadersStreamTest::SaveHeaderList)); stream_frame_.data_buffer = frame.data(); stream_frame_.data_length = frame.size(); headers_stream_->OnStreamFrame(stream_frame_);
diff --git a/net/quic/quic_spdy_stream.cc b/net/quic/quic_spdy_stream.cc index b6adeec..fcd206e 100644 --- a/net/quic/quic_spdy_stream.cc +++ b/net/quic/quic_spdy_stream.cc
@@ -30,6 +30,7 @@ headers_decompressed_(false), priority_(kDefaultPriority), trailers_decompressed_(false), + trailers_delivered_(false), avoid_empty_nonfin_writes_(FLAGS_quic_avoid_empty_nonfin_writes) { DCHECK_NE(kCryptoStreamId, id); // Don't receive any callbacks from the sequencer until headers @@ -161,6 +162,10 @@ decompressed_trailers_.erase(0, bytes_consumed); } +void QuicSpdyStream::MarkTrailersDelivered() { + trailers_delivered_ = true; +} + void QuicSpdyStream::ConsumeHeaderList() { header_list_.Clear(); if (FinishedReadingHeaders()) { @@ -377,8 +382,13 @@ bool QuicSpdyStream::FinishedReadingTrailers() const { // If no further trailing headers are expected, and the decompressed trailers // (if any) have been consumed, then reading of trailers is finished. - bool no_more_trailers = fin_received() || trailers_decompressed_; - return no_more_trailers && decompressed_trailers_.empty(); + if (!fin_received()) { + return false; + } else if (!trailers_decompressed_) { + return true; + } else { + return trailers_delivered_ && decompressed_trailers_.empty(); + } } SpdyPriority QuicSpdyStream::priority() const {
diff --git a/net/quic/quic_spdy_stream.h b/net/quic/quic_spdy_stream.h index d8cf396..3945130 100644 --- a/net/quic/quic_spdy_stream.h +++ b/net/quic/quic_spdy_stream.h
@@ -140,6 +140,9 @@ // Marks |bytes_consumed| of the trailers data as consumed. void MarkTrailersConsumed(size_t bytes_consumed); + // Marks the trailers as consumed. + void MarkTrailersDelivered(); + // Clears |header_list_|. void ConsumeHeaderList(); @@ -233,6 +236,8 @@ // True if the trailers have been completely decompressed. bool trailers_decompressed_; + // True if the trailers have been consumed. + bool trailers_delivered_; // Contains a copy of the decompressed trailers until they are consumed // via ProcessData or Readv. std::string decompressed_trailers_;
diff --git a/net/quic/quic_spdy_stream_test.cc b/net/quic/quic_spdy_stream_test.cc index 8bd1e62b..34454da 100644 --- a/net/quic/quic_spdy_stream_test.cc +++ b/net/quic/quic_spdy_stream_test.cc
@@ -847,6 +847,7 @@ EXPECT_EQ(trailers, decompressed_trailers); // Consuming the trailers erases them from the stream. stream_->MarkTrailersConsumed(decompressed_trailers.size()); + stream_->MarkTrailersDelivered(); EXPECT_EQ("", stream_->decompressed_trailers()); EXPECT_FALSE(stream_->IsDoneReading());
diff --git a/net/quic/spdy_utils.cc b/net/quic/spdy_utils.cc index 90e6537..bf50d7d 100644 --- a/net/quic/spdy_utils.cc +++ b/net/quic/spdy_utils.cc
@@ -120,12 +120,6 @@ return false; } - if (std::any_of(name.begin(), name.end(), base::IsAsciiUpper<char>)) { - DLOG(ERROR) << "Malformed header: Header name " << name - << " contains upper-case characters."; - return false; - } - auto iter = headers->find(name); if (iter == headers->end()) { (*headers)[name] = p.second;
diff --git a/net/quic/spdy_utils_test.cc b/net/quic/spdy_utils_test.cc index c4f0943..dbcc1ed7 100644 --- a/net/quic/spdy_utils_test.cc +++ b/net/quic/spdy_utils_test.cc
@@ -144,15 +144,6 @@ SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); } -TEST(SpdyUtilsTest, CopyAndValidateHeadersUpperCaseName) { - auto headers = - FromList({{"foo", "foovalue"}, {"bar", "barvalue"}, {"bAz", ""}}); - int64_t content_length = -1; - SpdyHeaderBlock block; - ASSERT_FALSE( - SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); -} - TEST(SpdyUtilsTest, CopyAndValidateHeadersMultipleContentLengths) { auto headers = FromList({{"content-length", "9"}, {"foo", "foovalue"},
diff --git a/net/quic/test_tools/mock_quic_spdy_client_stream.h b/net/quic/test_tools/mock_quic_spdy_client_stream.h index d5bd14f1..7164679 100644 --- a/net/quic/test_tools/mock_quic_spdy_client_stream.h +++ b/net/quic/test_tools/mock_quic_spdy_client_stream.h
@@ -21,7 +21,10 @@ MOCK_METHOD1(OnStreamFrame, void(const QuicStreamFrame& frame)); MOCK_METHOD2(OnInitialHeadersComplete, void(bool fin, size_t frame_len)); - MOCK_METHOD2(OnTrailingHeadersComplete, void(bool fin, size_t frame_len)); + MOCK_METHOD3(OnTrailingHeadersComplete, + void(bool fin, + size_t frame_len, + const QuicHeaderList& header_list)); MOCK_METHOD1(OnPromiseHeaders, void(base::StringPiece headers_data)); MOCK_METHOD2(OnPromiseHeadersComplete, void(QuicStreamId promised_stream_id, size_t frame_len));
diff --git a/net/spdy/buffered_spdy_framer.cc b/net/spdy/buffered_spdy_framer.cc index 4dd34ce..1d346e5 100644 --- a/net/spdy/buffered_spdy_framer.cc +++ b/net/spdy/buffered_spdy_framer.cc
@@ -5,6 +5,7 @@ #include "net/spdy/buffered_spdy_framer.h" #include "base/logging.h" +#include "base/strings/string_util.h" namespace net { @@ -210,12 +211,50 @@ SpdyHeadersHandlerInterface* BufferedSpdyFramer::OnHeaderFrameStart( SpdyStreamId stream_id) { - return visitor_->OnHeaderFrameStart(stream_id); + coalescer_.reset(new HeaderCoalescer()); + return coalescer_.get(); } void BufferedSpdyFramer::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { - visitor_->OnHeaderFrameEnd(stream_id, end_headers); + if (coalescer_->error_seen()) { + visitor_->OnStreamError(stream_id, + "Could not parse Spdy Control Frame Header."); + return; + } + DCHECK(control_frame_fields_.get()); + switch (control_frame_fields_->type) { + case SYN_STREAM: + visitor_->OnSynStream( + control_frame_fields_->stream_id, + control_frame_fields_->associated_stream_id, + control_frame_fields_->priority, control_frame_fields_->fin, + control_frame_fields_->unidirectional, coalescer_->headers()); + break; + case SYN_REPLY: + visitor_->OnSynReply(control_frame_fields_->stream_id, + control_frame_fields_->fin, coalescer_->headers()); + break; + case HEADERS: + visitor_->OnHeaders(control_frame_fields_->stream_id, + control_frame_fields_->has_priority, + control_frame_fields_->priority, + control_frame_fields_->parent_stream_id, + control_frame_fields_->exclusive, + control_frame_fields_->fin, coalescer_->headers()); + break; + case PUSH_PROMISE: + DCHECK_LT(SPDY3, protocol_version()); + visitor_->OnPushPromise(control_frame_fields_->stream_id, + control_frame_fields_->promised_stream_id, + coalescer_->headers()); + break; + default: + DCHECK(false) << "Unexpect control frame type: " + << control_frame_fields_->type; + break; + } + control_frame_fields_.reset(NULL); } void BufferedSpdyFramer::OnSettings(bool clear_persisted) {
diff --git a/net/spdy/buffered_spdy_framer.h b/net/spdy/buffered_spdy_framer.h index 87283b0..8cc7bce0 100644 --- a/net/spdy/buffered_spdy_framer.h +++ b/net/spdy/buffered_spdy_framer.h
@@ -14,6 +14,7 @@ #include "base/macros.h" #include "net/base/net_export.h" #include "net/socket/next_proto.h" +#include "net/spdy/header_coalescer.h" #include "net/spdy/spdy_framer.h" #include "net/spdy/spdy_header_block.h" #include "net/spdy/spdy_protocol.h" @@ -81,20 +82,6 @@ // |len| The number of padding octets. virtual void OnStreamPadding(SpdyStreamId stream_id, size_t len) = 0; - // Called just before processing the payload of a frame containing header - // data. Should return an implementation of SpdyHeadersHandlerInterface that - // will receive headers for stream |stream_id|. The caller will not take - // ownership of the headers handler. The same instance should be returned - // for all header frames comprising a logical header block (i.e. until - // OnHeaderFrameEnd() is called with end_headers == true). - virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart( - SpdyStreamId stream_id) = 0; - - // Called after processing the payload of a frame containing header data. - // |end_headers| is true if there will not be any subsequent CONTINUATION - // frames. - virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0; - // Called when a SETTINGS frame is received. // |clear_persisted| True if the respective flag is set on the SETTINGS frame. virtual void OnSettings(bool clear_persisted) = 0; @@ -311,6 +298,8 @@ }; std::unique_ptr<GoAwayFields> goaway_fields_; + std::unique_ptr<HeaderCoalescer> coalescer_; + DISALLOW_COPY_AND_ASSIGN(BufferedSpdyFramer); };
diff --git a/net/spdy/buffered_spdy_framer_unittest.cc b/net/spdy/buffered_spdy_framer_unittest.cc index 90f456037..700045d 100644 --- a/net/spdy/buffered_spdy_framer_unittest.cc +++ b/net/spdy/buffered_spdy_framer_unittest.cc
@@ -92,16 +92,6 @@ LOG(FATAL) << "Unexpected OnStreamPadding call."; } - SpdyHeadersHandlerInterface* OnHeaderFrameStart( - SpdyStreamId stream_id) override { - LOG(FATAL) << "Unexpected OnHeaderFrameStart call."; - return nullptr; - } - - void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override { - LOG(FATAL) << "Unexpected OnHeaderFrameEnd call."; - } - void OnSettings(bool clear_persisted) override {} void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override {
diff --git a/net/spdy/header_coalescer.cc b/net/spdy/header_coalescer.cc new file mode 100644 index 0000000..03357c9 --- /dev/null +++ b/net/spdy/header_coalescer.cc
@@ -0,0 +1,36 @@ +// 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/spdy/header_coalescer.h" + +#include "base/strings/string_util.h" + +namespace net { + +void HeaderCoalescer::OnHeader(base::StringPiece key, base::StringPiece value) { + if (key.empty()) { + DVLOG(1) << "Header name must not be empty."; + error_seen_ = true; + return; + } + + auto iter = headers_.find(key); + if (iter == headers_.end()) { + headers_[key] = value; + } else { + // This header had multiple values, so it must be reconstructed. + base::StringPiece v = iter->second; + std::string s(v.data(), v.length()); + if (key == "cookie") { + // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. + s.append("; "); + } else { + base::StringPiece("\0", 1).AppendToString(&s); + } + value.AppendToString(&s); + headers_.ReplaceOrAppendHeader(key, s); + } +} + +} // namespace net
diff --git a/net/spdy/header_coalescer.h b/net/spdy/header_coalescer.h new file mode 100644 index 0000000..e699622 --- /dev/null +++ b/net/spdy/header_coalescer.h
@@ -0,0 +1,34 @@ +// 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_SPDY_HEADER_COALESCER_H_ +#define NET_SPDY_HEADER_COALESCER_H_ + +#include "net/base/net_export.h" +#include "net/spdy/spdy_header_block.h" +#include "net/spdy/spdy_headers_handler_interface.h" + +namespace net { + +class NET_EXPORT_PRIVATE HeaderCoalescer : public SpdyHeadersHandlerInterface { + public: + HeaderCoalescer() {} + + void OnHeaderBlockStart() override {} + + void OnHeader(base::StringPiece key, base::StringPiece value) override; + + void OnHeaderBlockEnd(size_t uncompressed_header_bytes) override {} + + const SpdyHeaderBlock& headers() const { return headers_; } + bool error_seen() const { return error_seen_; } + + private: + SpdyHeaderBlock headers_; + bool error_seen_ = false; +}; + +} // namespace net + +#endif // NET_SPDY_HEADER_COALESCER_H_
diff --git a/net/spdy/mock_spdy_framer_visitor.cc b/net/spdy/mock_spdy_framer_visitor.cc index c4a210f..c13d4a3 100644 --- a/net/spdy/mock_spdy_framer_visitor.cc +++ b/net/spdy/mock_spdy_framer_visitor.cc
@@ -8,7 +8,9 @@ namespace test { -MockSpdyFramerVisitor::MockSpdyFramerVisitor() {} +MockSpdyFramerVisitor::MockSpdyFramerVisitor() { + DelegateNewHeaderHandling(); +} MockSpdyFramerVisitor::~MockSpdyFramerVisitor() {}
diff --git a/net/spdy/mock_spdy_framer_visitor.h b/net/spdy/mock_spdy_framer_visitor.h index ac97a3d..dcf7356 100644 --- a/net/spdy/mock_spdy_framer_visitor.h +++ b/net/spdy/mock_spdy_framer_visitor.h
@@ -10,6 +10,7 @@ #include "base/strings/string_piece.h" #include "net/spdy/spdy_framer.h" +#include "net/spdy/spdy_test_utils.h" #include "testing/gmock/include/gmock/gmock.h" namespace net { @@ -75,6 +76,31 @@ uint8_t weight, bool exclusive)); MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); + + void DelegateNewHeaderHandling() { + ON_CALL(*this, OnHeaderFrameStart(testing::_)) + .WillByDefault(testing::Invoke( + this, &MockSpdyFramerVisitor::ReturnTestHeadersHandler)); + ON_CALL(*this, OnHeaderFrameEnd(testing::_, testing::_)) + .WillByDefault(testing::Invoke( + this, &MockSpdyFramerVisitor::ResetTestHeadersHandler)); + } + + SpdyHeadersHandlerInterface* ReturnTestHeadersHandler( + SpdyStreamId /* stream_id */) { + if (headers_handler_ == nullptr) { + headers_handler_.reset(new TestHeadersHandler); + } + return headers_handler_.get(); + } + + void ResetTestHeadersHandler(SpdyStreamId /* stream_id */, bool end) { + if (end) { + headers_handler_.reset(); + } + } + + std::unique_ptr<SpdyHeadersHandlerInterface> headers_handler_; }; } // namespace test
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 7ead3317..b951301 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc
@@ -21,6 +21,7 @@ #include "net/spdy/spdy_bug_tracker.h" #include "net/spdy/spdy_frame_builder.h" #include "net/spdy/spdy_frame_reader.h" +#include "net/spdy/spdy_headers_block_parser.h" #include "third_party/zlib/zlib.h" using base::StringPiece; @@ -170,6 +171,7 @@ expect_continuation_(0), visitor_(NULL), debug_visitor_(NULL), + header_handler_(nullptr), display_protocol_("SPDY"), protocol_version_(version), enable_compression_(true), @@ -448,6 +450,8 @@ return "SPDY_INVALID_CONTROL_FRAME_FLAGS"; case SPDY_UNEXPECTED_FRAME: return "UNEXPECTED_FRAME"; + case SPDY_INTERNAL_FRAMER_ERROR: + return "SPDY_INTERNAL_FRAMER_ERROR"; } return "UNKNOWN_ERROR"; } @@ -1609,6 +1613,21 @@ return original_len - len; #endif } + + if (current_frame_type_ != CONTINUATION) { + header_handler_ = visitor_->OnHeaderFrameStart(current_frame_stream_id_); + if (header_handler_ == nullptr) { + SPDY_BUG << "visitor_->OnHeaderFrameStart returned nullptr"; + set_error(SPDY_INTERNAL_FRAMER_ERROR); + return original_len - len; + } + if (protocol_version() == SPDY3) { + header_parser_.reset( + new SpdyHeadersBlockParser(protocol_version(), header_handler_)); + } else { + GetHpackDecoder()->HandleControlFrameHeadersStart(header_handler_); + } + } CHANGE_STATE(SPDY_CONTROL_FRAME_HEADER_BLOCK); } return original_len - len; @@ -1665,19 +1684,19 @@ size_t compressed_len = 0; if (GetHpackDecoder()->HandleControlFrameHeadersComplete( &compressed_len)) { - // TODO(jgraettinger): To be removed with migration to - // SpdyHeadersHandlerInterface. Serializes the HPACK block as a SPDY3 - // block, delivered via reentrant call to - // ProcessControlFrameHeaderBlock(). - DeliverHpackBlockAsSpdy3Block(compressed_len); - return process_bytes; + visitor_->OnHeaderFrameEnd(current_frame_stream_id_, true); + if (state_ == SPDY_ERROR) { + return data_len; + } + } else { + set_error(SPDY_DECOMPRESS_FAILURE); + processed_successfully = false; } - set_error(SPDY_DECOMPRESS_FAILURE); - processed_successfully = false; } else { - // The complete header block has been delivered. We send a zero-length - // OnControlFrameHeaderData() to indicate this. - visitor_->OnControlFrameHeaderData(current_frame_stream_id_, NULL, 0); + visitor_->OnHeaderFrameEnd(current_frame_stream_id_, true); + if (state_ == SPDY_ERROR) { + return data_len; + } } } if (processed_successfully) { @@ -3088,8 +3107,12 @@ if ((rv == Z_OK) || input_exhausted) { size_t decompressed_len = arraysize(buffer) - decomp->avail_out; if (decompressed_len > 0) { - processed_successfully = visitor_->OnControlFrameHeaderData( + processed_successfully = header_parser_->HandleControlFrameHeadersData( stream_id, buffer, decompressed_len); + if (header_parser_->get_error() == + SpdyHeadersBlockParser::NEED_MORE_DATA) { + processed_successfully = true; + } } if (!processed_successfully) { // Assume that the problem was the header block was too large for the @@ -3110,8 +3133,11 @@ bool read_successfully = true; while (read_successfully && len > 0) { size_t bytes_to_deliver = std::min(len, kHeaderDataChunkMaxSize); - read_successfully = visitor_->OnControlFrameHeaderData(stream_id, data, - bytes_to_deliver); + read_successfully = header_parser_->HandleControlFrameHeadersData( + stream_id, data, bytes_to_deliver); + if (header_parser_->get_error() == SpdyHeadersBlockParser::NEED_MORE_DATA) { + read_successfully = true; + } data += bytes_to_deliver; len -= bytes_to_deliver; if (!read_successfully) {
diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h index 6d0b78b..b33b2693 100644 --- a/net/spdy/spdy_framer.h +++ b/net/spdy/spdy_framer.h
@@ -20,6 +20,7 @@ #include "net/spdy/hpack/hpack_encoder.h" #include "net/spdy/spdy_alt_svc_wire_format.h" #include "net/spdy/spdy_header_block.h" +#include "net/spdy/spdy_headers_block_parser.h" #include "net/spdy/spdy_protocol.h" typedef struct z_stream_s z_stream; // Forward declaration for zlib. @@ -127,9 +128,9 @@ // Called just before processing the payload of a frame containing header // data. Should return an implementation of SpdyHeadersHandlerInterface that // will receive headers for stream |stream_id|. The caller will not take - // ownership of the headers handler. The same instance should be returned - // for all header frames comprising a logical header block (i.e. until - // OnHeaderFrameEnd() is called with end_headers == true). + // ownership of the headers handler. The same instance should remain live + // and be returned for all header frames comprising a logical header block + // (i.e. until OnHeaderFrameEnd() is called with end_headers == true). virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart( SpdyStreamId stream_id) = 0; @@ -338,6 +339,7 @@ SPDY_INVALID_DATA_FRAME_FLAGS, // Data frame has invalid flags. SPDY_INVALID_CONTROL_FRAME_FLAGS, // Control frame has invalid flags. SPDY_UNEXPECTED_FRAME, // Frame received out of order. + SPDY_INTERNAL_FRAMER_ERROR, // SpdyFramer was used incorrectly. SPDY_INVALID_CONTROL_FRAME_SIZE, // Control frame not sized to spec LAST_ERROR, // Must be the last entry in the enum. @@ -542,9 +544,9 @@ bool probable_http_response() const { return probable_http_response_; } - SpdyPriority GetLowestPriority() const { return 7; } + SpdyPriority GetLowestPriority() const { return kV3LowestPriority; } - SpdyPriority GetHighestPriority() const { return 0; } + SpdyPriority GetHighestPriority() const { return kV3HighestPriority; } // Interpolates SpdyPriority values into SPDY4/HTTP2 priority weights, and // vice versa. Note that these methods accept/return weight values in their @@ -568,6 +570,7 @@ size_t header_encoder_table_size() const; protected: + friend class BufferedSpdyFramer; friend class HttpNetworkLayer; // This is temporary for the server. friend class HttpNetworkTransactionTest; friend class HttpProxyClientSocketPoolTest; @@ -767,6 +770,9 @@ SpdyFramerVisitorInterface* visitor_; SpdyFramerDebugVisitorInterface* debug_visitor_; + std::unique_ptr<SpdyHeadersBlockParser> header_parser_; + SpdyHeadersHandlerInterface* header_handler_; + std::string display_protocol_; // The protocol version to be spoken/understood by this framer.
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index 1ce33951..b4429a2 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc
@@ -60,21 +60,155 @@ template <class SpdyFrameType> static SpdySerializedFrame DecompressFrame(SpdyFramer* framer, const SpdyFrameType& frame) { - DecompressionVisitor visitor(framer->protocol_version()); + NewDecompressionVisitor visitor; framer->set_visitor(&visitor); CHECK_EQ(frame.size(), framer->ProcessInput(frame.data(), frame.size())); CHECK_EQ(SpdyFramer::SPDY_READY_FOR_FRAME, framer->state()); - framer->set_visitor(NULL); - - char* buffer = visitor.ReleaseBuffer(); - CHECK(buffer != NULL); - SpdySerializedFrame decompressed_frame(buffer, visitor.size(), true); - SetFrameLength(&decompressed_frame, - visitor.size() - framer->GetControlFrameHeaderSize(), - framer->protocol_version()); - return decompressed_frame; + framer->set_visitor(nullptr); + SpdyFramer serializer(framer->protocol_version()); + serializer.set_enable_compression(false); + return serializer.SerializeFrame(visitor.GetFrame()); } + class NewDecompressionVisitor : public SpdyFramerVisitorInterface { + public: + NewDecompressionVisitor() : finished_(false) {} + + const SpdyFrameIR& GetFrame() const { + CHECK(finished_); + return *frame_; + } + + SpdyHeadersHandlerInterface* OnHeaderFrameStart( + SpdyStreamId stream_id) override { + if (headers_handler_ == nullptr) { + headers_handler_.reset(new TestHeadersHandler); + } + return headers_handler_.get(); + } + + void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override { + CHECK(!finished_); + frame_->set_header_block(headers_handler_->decoded_block()); + finished_ = true; + if (end_headers) { + headers_handler_.reset(); + } + } + + void OnSynStream(SpdyStreamId stream_id, + SpdyStreamId associated_stream_id, + SpdyPriority priority, + bool fin, + bool unidirectional) override { + SpdySynStreamIR* syn_stream = new SpdySynStreamIR(stream_id); + syn_stream->set_associated_to_stream_id(associated_stream_id); + syn_stream->set_priority(priority); + syn_stream->set_fin(fin); + syn_stream->set_unidirectional(unidirectional); + frame_.reset(syn_stream); + } + + void OnSynReply(SpdyStreamId stream_id, bool fin) override { + SpdyHeadersIR* headers = new SpdyHeadersIR(stream_id); + headers->set_fin(fin); + frame_.reset(headers); + } + + void OnHeaders(SpdyStreamId stream_id, + bool has_priority, + SpdyPriority priority, + SpdyStreamId parent_stream_id, + bool exclusive, + bool fin, + bool end) override { + SpdyHeadersIR* headers = new SpdyHeadersIR(stream_id); + headers->set_has_priority(has_priority); + headers->set_priority(priority); + headers->set_parent_stream_id(parent_stream_id); + headers->set_exclusive(exclusive); + headers->set_fin(fin); + frame_.reset(headers); + } + + void OnPushPromise(SpdyStreamId stream_id, + SpdyStreamId promised_stream_id, + bool end) override { + SpdyPushPromiseIR* push_promise = + new SpdyPushPromiseIR(stream_id, promised_stream_id); + frame_.reset(push_promise); + } + + // TODO(birenroy): Add support for CONTINUATION. + void OnContinuation(SpdyStreamId stream_id, bool end) override { + LOG(FATAL); + } + + // All other methods just LOG(FATAL). + void OnError(SpdyFramer* framer) override { LOG(FATAL); } + void OnDataFrameHeader(SpdyStreamId stream_id, + size_t length, + bool fin) override { + LOG(FATAL) << "Unexpected data frame header"; + } + void OnStreamFrameData(SpdyStreamId stream_id, + const char* data, + size_t len) override { + LOG(FATAL); + } + + void OnStreamEnd(SpdyStreamId stream_id) override { LOG(FATAL); } + + void OnStreamPadding(SpdyStreamId stream_id, size_t len) override { + LOG(FATAL); + } + + bool OnControlFrameHeaderData(SpdyStreamId stream_id, + const char* header_data, + size_t len) override { + LOG(FATAL); + return true; + } + + void OnRstStream(SpdyStreamId stream_id, + SpdyRstStreamStatus status) override { + LOG(FATAL); + } + void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override { + LOG(FATAL); + } + void OnPing(SpdyPingId unique_id, bool is_ack) override { LOG(FATAL); } + void OnSettingsEnd() override { LOG(FATAL); } + void OnGoAway(SpdyStreamId last_accepted_stream_id, + SpdyGoAwayStatus status) override { + LOG(FATAL); + } + + void OnWindowUpdate(SpdyStreamId stream_id, + int delta_window_size) override { + LOG(FATAL); + } + + void OnPriority(SpdyStreamId stream_id, + SpdyStreamId parent_stream_id, + uint8_t weight, + bool exclusive) override { + // Do nothing. + } + + bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override { + LOG(FATAL); + return false; + } + + private: + std::unique_ptr<TestHeadersHandler> headers_handler_; + std::unique_ptr<SpdyFrameWithHeaderBlockIR> frame_; + bool finished_; + + DISALLOW_COPY_AND_ASSIGN(NewDecompressionVisitor); + }; + class DecompressionVisitor : public SpdyFramerVisitorInterface { public: explicit DecompressionVisitor(SpdyMajorVersion version) @@ -107,12 +241,12 @@ SpdyHeadersHandlerInterface* OnHeaderFrameStart( SpdyStreamId stream_id) override { - LOG(FATAL); + LOG(FATAL) << "Not implemented."; return nullptr; } void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override { - LOG(FATAL); + LOG(FATAL) << "Not implemented."; } bool OnControlFrameHeaderData(SpdyStreamId stream_id, @@ -240,6 +374,7 @@ private: SpdyMajorVersion version_; + TestHeadersHandler* headers_handler_; std::unique_ptr<char[]> buffer_; size_t size_; bool finished_; @@ -251,6 +386,20 @@ DISALLOW_COPY_AND_ASSIGN(SpdyFramerTestUtil); }; +class SpdyFramerPeer { + public: + static size_t ControlFrameBufferSize() { + return SpdyFramer::kControlFrameBufferSize; + } + static size_t GetNumberRequiredContinuationFrames(SpdyFramer* framer, + size_t size) { + return framer->GetNumberRequiredContinuationFrames(size); + } + static void SetError(SpdyFramer* framer, SpdyFramer::SpdyError error) { + framer->set_error(error); + } +}; + class TestSpdyVisitor : public SpdyFramerVisitorInterface, public SpdyFramerDebugVisitorInterface { public: @@ -335,13 +484,19 @@ SpdyHeadersHandlerInterface* OnHeaderFrameStart( SpdyStreamId stream_id) override { - LOG(FATAL) << "OnHeaderFrameStart(" << stream_id << ")"; - return nullptr; + if (headers_handler_ == nullptr) { + headers_handler_.reset(new TestHeadersHandler); + } + return headers_handler_.get(); } void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override { - LOG(FATAL) << "OnHeaderFrameEnd(" << stream_id << ", " << end_headers - << ")"; + CHECK(headers_handler_ != nullptr); + headers_ = headers_handler_->decoded_block(); + header_bytes_received_ = headers_handler_->header_bytes_parsed(); + if (end_headers) { + headers_handler_.reset(); + } } bool OnControlFrameHeaderData(SpdyStreamId stream_id, @@ -631,26 +786,17 @@ std::unique_ptr<char[]> header_buffer_; size_t header_buffer_length_; size_t header_buffer_size_; + size_t header_bytes_received_; SpdyStreamId header_stream_id_; SpdyFrameType header_control_type_; bool header_buffer_valid_; + std::unique_ptr<TestHeadersHandler> headers_handler_; SpdyHeaderBlock headers_; bool header_has_priority_; SpdyStreamId header_parent_stream_id_; bool header_exclusive_; }; -class SpdyFramerPeer { - public: - static size_t ControlFrameBufferSize() { - return SpdyFramer::kControlFrameBufferSize; - } - static size_t GetNumberRequiredContinuationFrames(SpdyFramer* framer, - size_t size) { - return framer->GetNumberRequiredContinuationFrames(size); - } -}; - // Retrieves serialized headers from a HEADERS or SYN_STREAM frame. StringPiece GetSerializedHeaders(const SpdySerializedFrame& frame, const SpdyFramer& framer) { @@ -748,7 +894,7 @@ visitor.SimulateInFramer(reinterpret_cast<unsigned char*>(frame.data()), frame.size()); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_NE(headers.header_block(), visitor.headers_); EXPECT_EQ(1u, visitor.headers_.size()); EXPECT_EQ("key=value; foo; bar=; k2=v2 ", visitor.headers_["cookie"]); @@ -772,7 +918,7 @@ visitor.SimulateInFramer(reinterpret_cast<unsigned char*>(frame.data()), frame.size()); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_EQ(headers.header_block(), visitor.headers_); } @@ -935,6 +1081,7 @@ sizeof(kH2FrameData), false); EXPECT_CALL(visitor, OnHeaders(1, false, 0, 0, false, false, false)); + EXPECT_CALL(visitor, OnHeaderFrameStart(1)).Times(1); EXPECT_CALL(visitor, OnError(testing::Eq(&framer))); EXPECT_EQ(frame.size(), framer.ProcessInput(frame.data(), frame.size())); EXPECT_TRUE(framer.HasError()); @@ -966,7 +1113,7 @@ SpdySerializedFrame frame(kH2FrameData, sizeof(kH2FrameData), false); EXPECT_CALL(visitor, OnHeaders(1, false, 0, 0, false, false, false)); - + EXPECT_CALL(visitor, OnHeaderFrameStart(1)).Times(1); EXPECT_EQ(frame.size(), framer.ProcessInput(frame.data(), frame.size())); EXPECT_FALSE(framer.HasError()); EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) @@ -3511,12 +3658,8 @@ reinterpret_cast<unsigned char*>(control_frame.data()), control_frame.size()); EXPECT_EQ(1, visitor.headers_frame_count_); - // control_frame_header_data_count_ depends on the random sequence - // produced by rand(), so adding, removing or running single tests - // alters this value. The best we can do is assert that it happens - // at least twice. - EXPECT_LE(2, visitor.control_frame_header_data_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_EQ(0, visitor.end_of_stream_count_); EXPECT_EQ(headers, visitor.headers_); } @@ -3535,12 +3678,8 @@ reinterpret_cast<unsigned char*>(control_frame.data()), control_frame.size()); EXPECT_EQ(1, visitor.headers_frame_count_); - // control_frame_header_data_count_ depends on the random sequence - // produced by rand(), so adding, removing or running single tests - // alters this value. The best we can do is assert that it happens - // at least twice. - EXPECT_LE(2, visitor.control_frame_header_data_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_EQ(1, visitor.end_of_stream_count_); EXPECT_EQ(headers, visitor.headers_); } @@ -3576,9 +3715,8 @@ EXPECT_TRUE(visitor.header_buffer_valid_); EXPECT_EQ(0, visitor.error_count_); EXPECT_EQ(1, visitor.syn_frame_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_EQ(0, visitor.end_of_stream_count_); - EXPECT_LT(kBigValueSize, visitor.header_buffer_length_); } TEST_P(SpdyFramerTest, ControlFrameTooLarge) { @@ -3653,7 +3791,7 @@ EXPECT_EQ(0, visitor.error_count_); EXPECT_EQ(1, visitor.headers_frame_count_); EXPECT_EQ(1, visitor.continuation_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); } TEST_P(SpdyFramerTest, TooLargePushPromiseFrameUsesContinuation) { @@ -3683,7 +3821,7 @@ EXPECT_EQ(0, visitor.error_count_); EXPECT_EQ(1, visitor.push_promise_frame_count_); EXPECT_EQ(1, visitor.continuation_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); } // Check that the framer stops delivering header data chunks once the visitor @@ -3707,25 +3845,10 @@ visitor.SimulateInFramer( reinterpret_cast<unsigned char*>(control_frame.data()), control_frame.size()); - EXPECT_FALSE(visitor.header_buffer_valid_); - EXPECT_EQ(1, visitor.error_count_); - EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, - visitor.framer_.error_code()) - << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); - - // The framer should have stoped delivering chunks after the visitor - // signaled "stop" by returning false from OnControlFrameHeaderData(). - // - // control_frame_header_data_count_ depends on the random sequence - // produced by rand(), so adding, removing or running single tests - // alters this value. The best we can do is assert that it happens - // at least kHeaderBufferChunks + 1. - EXPECT_LE(kHeaderBufferChunks + 1, - static_cast<unsigned>(visitor.control_frame_header_data_count_)); - EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); - - // The framer should not have sent half-close to the visitor. - EXPECT_EQ(0, visitor.end_of_stream_count_); + // It's up to the visitor to ignore extraneous header data; the framer + // won't throw an error. + EXPECT_GT(visitor.header_bytes_received_, visitor.header_buffer_size_); + EXPECT_EQ(1, visitor.end_of_stream_count_); } TEST_P(SpdyFramerTest, DecompressCorruptHeaderBlock) { @@ -4179,7 +4302,7 @@ EXPECT_EQ(1, visitor.headers_frame_count_); EXPECT_EQ(2, visitor.continuation_count_); EXPECT_EQ(1, visitor.fin_flag_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_EQ(1, visitor.end_of_stream_count_); EXPECT_THAT(visitor.headers_, @@ -4229,7 +4352,7 @@ EXPECT_EQ(1u, visitor.last_push_promise_stream_); EXPECT_EQ(42u, visitor.last_push_promise_promised_stream_); EXPECT_EQ(2, visitor.continuation_count_); - EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); + EXPECT_EQ(0, visitor.zero_length_control_frame_header_data_count_); EXPECT_EQ(0, visitor.end_of_stream_count_); EXPECT_THAT(visitor.headers_, @@ -4836,8 +4959,8 @@ EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(8, SYN_STREAM, _)); EXPECT_CALL(visitor, OnSynStream(8, 3, 1, flags & CONTROL_FLAG_FIN, flags & CONTROL_FLAG_UNIDIRECTIONAL)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(8, _, _)) - .WillRepeatedly(testing::Return(true)); + EXPECT_CALL(visitor, OnHeaderFrameStart(8)).Times(1); + EXPECT_CALL(visitor, OnHeaderFrameEnd(8, _)).Times(1); if (flags & DATA_FLAG_FIN) { EXPECT_CALL(visitor, OnStreamEnd(_)); } else { @@ -4883,8 +5006,8 @@ EXPECT_CALL(visitor, OnError(_)); } else { EXPECT_CALL(visitor, OnSynReply(37, flags & CONTROL_FLAG_FIN)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(37, _, _)) - .WillRepeatedly(testing::Return(true)); + EXPECT_CALL(visitor, OnHeaderFrameStart(37)).Times(1); + EXPECT_CALL(visitor, OnHeaderFrameEnd(37, _)).Times(1); if (flags & DATA_FLAG_FIN) { EXPECT_CALL(visitor, OnStreamEnd(_)); } @@ -5082,8 +5205,10 @@ } EXPECT_CALL(visitor, OnHeaders(stream_id, has_priority, priority, parent_stream_id, exclusive, fin, end)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(57, _, _)) - .WillRepeatedly(testing::Return(true)); + EXPECT_CALL(visitor, OnHeaderFrameStart(57)).Times(1); + if (end) { + EXPECT_CALL(visitor, OnHeaderFrameEnd(57, _)).Times(1); + } if (flags & DATA_FLAG_FIN && (IsSpdy3() || flags & HEADERS_FLAG_END_HEADERS)) { EXPECT_CALL(visitor, OnStreamEnd(_)); @@ -5179,9 +5304,13 @@ bool end = flags & PUSH_PROMISE_FLAG_END_PUSH_PROMISE; EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(client_id, PUSH_PROMISE, _)); - EXPECT_CALL(visitor, OnPushPromise(client_id, promised_id, end)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(client_id, _, _)) - .WillRepeatedly(testing::Return(true)); + EXPECT_CALL(visitor, + OnPushPromise(client_id, promised_id, + flags & PUSH_PROMISE_FLAG_END_PUSH_PROMISE)); + EXPECT_CALL(visitor, OnHeaderFrameStart(client_id)).Times(1); + if (end) { + EXPECT_CALL(visitor, OnHeaderFrameEnd(client_id, _)).Times(1); + } framer.ProcessInput(frame.data(), frame.size()); EXPECT_EQ(SpdyFramer::SPDY_READY_FOR_FRAME, framer.state()); @@ -5209,8 +5338,7 @@ EXPECT_CALL(debug_visitor, OnSendCompressedFrame(42, HEADERS, _, _)); EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(42, HEADERS, _)); EXPECT_CALL(visitor, OnHeaders(42, false, 0, 0, false, false, false)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(42, _, _)) - .WillRepeatedly(testing::Return(true)); + EXPECT_CALL(visitor, OnHeaderFrameStart(42)).Times(1); SpdyHeadersIR headers_ir(42); headers_ir.SetHeader("foo", "bar"); @@ -5224,8 +5352,10 @@ EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(42, CONTINUATION, _)); EXPECT_CALL(visitor, OnContinuation(42, flags & HEADERS_FLAG_END_HEADERS)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(42, _, _)) - .WillRepeatedly(testing::Return(true)); + bool end = flags & HEADERS_FLAG_END_HEADERS; + if (end) { + EXPECT_CALL(visitor, OnHeaderFrameEnd(42, _)).Times(1); + } framer.ProcessInput(frame0.data(), frame0.size()); framer.ProcessInput(frame.data(), frame.size()); @@ -5262,7 +5392,8 @@ EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(1, SYN_STREAM, _)); EXPECT_CALL(visitor, OnSynStream(1, 0, 1, false, false)); - EXPECT_CALL(visitor, OnControlFrameHeaderData(1, NULL, 0)); + EXPECT_CALL(visitor, OnHeaderFrameStart(1)).Times(1); + EXPECT_CALL(visitor, OnHeaderFrameEnd(1, _)).Times(1); framer.ProcessInput(frame.data(), framer.GetSynStreamMinimumSize()); EXPECT_EQ(SpdyFramer::SPDY_READY_FOR_FRAME, framer.state());
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index d1ed0689..9ba99e1c 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -3611,7 +3611,7 @@ spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( 0, GOAWAY_FRAME_SIZE_ERROR, - "Framer error: 14 (INVALID_CONTROL_FRAME_SIZE).")); + "Framer error: 15 (INVALID_CONTROL_FRAME_SIZE).")); MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)}; // Read WINDOW_UPDATE with incorrectly-sized payload.
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 76b74a5..344b20c 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc
@@ -362,6 +362,8 @@ return SPDY_ERROR_INVALID_CONTROL_FRAME_FLAGS; case SpdyFramer::SPDY_UNEXPECTED_FRAME: return SPDY_ERROR_UNEXPECTED_FRAME; + case SpdyFramer::SPDY_INTERNAL_FRAMER_ERROR: + return SPDY_ERROR_INTERNAL_FRAMER_ERROR; case SpdyFramer::SPDY_INVALID_CONTROL_FRAME_SIZE: return SPDY_ERROR_INVALID_CONTROL_FRAME_SIZE; case SpdyFramer::SPDY_INVALID_STREAM_ID: @@ -400,6 +402,8 @@ return ERR_SPDY_PROTOCOL_ERROR; case SpdyFramer::SPDY_UNEXPECTED_FRAME: return ERR_SPDY_PROTOCOL_ERROR; + case SpdyFramer::SPDY_INTERNAL_FRAMER_ERROR: + return ERR_SPDY_PROTOCOL_ERROR; case SpdyFramer::SPDY_INVALID_CONTROL_FRAME_SIZE: return ERR_SPDY_FRAME_SIZE_ERROR; case SpdyFramer::SPDY_INVALID_STREAM_ID: @@ -2208,16 +2212,6 @@ it->second.stream->OnPaddingConsumed(len); } -SpdyHeadersHandlerInterface* SpdySession::OnHeaderFrameStart( - SpdyStreamId stream_id) { - LOG(FATAL); - return nullptr; -} - -void SpdySession::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { - LOG(FATAL); -} - void SpdySession::OnSettings(bool clear_persisted) { CHECK(in_io_loop_);
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 328420b..84e3bd9 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h
@@ -99,6 +99,7 @@ SPDY_ERROR_INVALID_DATA_FRAME_FLAGS = 8, SPDY_ERROR_INVALID_CONTROL_FRAME_FLAGS = 9, SPDY_ERROR_UNEXPECTED_FRAME = 31, + SPDY_ERROR_INTERNAL_FRAMER_ERROR = 41, SPDY_ERROR_INVALID_CONTROL_FRAME_SIZE = 37, SPDY_ERROR_INVALID_STREAM_ID = 38, // SpdyRstStreamStatus mappings. @@ -140,7 +141,7 @@ // If these compile asserts fail then SpdyProtocolErrorDetails needs // to be updated with new values, as do the mapping functions above. -static_assert(15 == SpdyFramer::LAST_ERROR, +static_assert(16 == SpdyFramer::LAST_ERROR, "SpdyProtocolErrorDetails / Spdy Errors mismatch"); static_assert(17 == RST_STREAM_NUM_STATUS_CODES, "SpdyProtocolErrorDetails / RstStreamStatus mismatch"); @@ -885,9 +886,6 @@ size_t len) override; void OnStreamEnd(SpdyStreamId stream_id) override; void OnStreamPadding(SpdyStreamId stream_id, size_t len) override; - SpdyHeadersHandlerInterface* OnHeaderFrameStart( - SpdyStreamId stream_id) override; - void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override; void OnSettings(bool clear_persisted) override; void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override; void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) override;
diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc index 92c9c586..53434d6 100644 --- a/net/spdy/spdy_test_util_common.cc +++ b/net/spdy/spdy_test_util_common.cc
@@ -216,11 +216,6 @@ size_t len) override {} void OnStreamEnd(SpdyStreamId stream_id) override {} void OnStreamPadding(SpdyStreamId stream_id, size_t len) override {} - SpdyHeadersHandlerInterface* OnHeaderFrameStart( - SpdyStreamId stream_id) override { - return nullptr; - } - void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override {} void OnSettings(bool clear_persisted) override {} void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override {} void OnPing(SpdyPingId unique_id, bool is_ack) override {}
diff --git a/net/tools/flip_server/spdy_interface.cc b/net/tools/flip_server/spdy_interface.cc index c479f24..ddd3f5e 100644 --- a/net/tools/flip_server/spdy_interface.cc +++ b/net/tools/flip_server/spdy_interface.cc
@@ -239,18 +239,6 @@ << ", [" << len << "])"; } -SpdyHeadersHandlerInterface* SpdySM::OnHeaderFrameStart( - SpdyStreamId stream_id) { - LOG(FATAL) << ACCEPTOR_CLIENT_IDENT - << "SpdySM::OnHeaderFrameStart() not implemented."; - return nullptr; -} - -void SpdySM::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { - LOG(FATAL) << ACCEPTOR_CLIENT_IDENT - << "SpdySM::OnHeaderFrameEnd() not implemented."; -} - void SpdySM::OnSynStream(SpdyStreamId stream_id, SpdyStreamId associated_stream_id, SpdyPriority priority,
diff --git a/net/tools/flip_server/spdy_interface.h b/net/tools/flip_server/spdy_interface.h index cafad909..09d20fa 100644 --- a/net/tools/flip_server/spdy_interface.h +++ b/net/tools/flip_server/spdy_interface.h
@@ -113,20 +113,6 @@ // |len| The number of padding octets. void OnStreamPadding(SpdyStreamId stream_id, size_t len) override; - // Called just before processing the payload of a frame containing header - // data. Should return an implementation of SpdyHeadersHandlerInterface that - // will receive headers for stream |stream_id|. The caller will not take - // ownership of the headers handler. The same instance should be returned - // for all header frames comprising a logical header block (i.e. until - // OnHeaderFrameEnd() is called with end_headers == true). - SpdyHeadersHandlerInterface* OnHeaderFrameStart( - SpdyStreamId stream_id) override; - - // Called after processing the payload of a frame containing header data. - // |end_headers| is true if there will not be any subsequent CONTINUATION - // frames. - void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override; - // Called when a SETTINGS frame is received. // |clear_persisted| True if the respective flag is set on the SETTINGS frame. void OnSettings(bool clear_persisted) override {}
diff --git a/net/tools/quic/quic_spdy_client_stream.cc b/net/tools/quic/quic_spdy_client_stream.cc index ca3bd78..633963a 100644 --- a/net/tools/quic/quic_spdy_client_stream.cc +++ b/net/tools/quic/quic_spdy_client_stream.cc
@@ -96,9 +96,11 @@ session_->OnInitialHeadersComplete(id(), response_headers_); } -void QuicSpdyClientStream::OnTrailingHeadersComplete(bool fin, - size_t frame_len) { - QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len); +void QuicSpdyClientStream::OnTrailingHeadersComplete( + bool fin, + size_t frame_len, + const QuicHeaderList& header_list) { + QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len, header_list); MarkTrailersConsumed(decompressed_trailers().length()); } @@ -139,6 +141,9 @@ } session_->HandlePromised(id(), promised_id, promise_headers); + if (visitor() != nullptr) { + visitor()->OnPromiseHeadersComplete(promised_id, frame_len); + } } void QuicSpdyClientStream::OnDataAvailable() {
diff --git a/net/tools/quic/quic_spdy_client_stream.h b/net/tools/quic/quic_spdy_client_stream.h index 3bbe1349..9dac6c0 100644 --- a/net/tools/quic/quic_spdy_client_stream.h +++ b/net/tools/quic/quic_spdy_client_stream.h
@@ -40,7 +40,9 @@ const QuicHeaderList& header_list) override; // Override the base class to parse and store trailers. - void OnTrailingHeadersComplete(bool fin, size_t frame_len) override; + void OnTrailingHeadersComplete(bool fin, + size_t frame_len, + const QuicHeaderList& header_list) override; // Override the base class to handle creation of the push stream. void OnPromiseHeadersComplete(QuicStreamId promised_stream_id,
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java index d9ca3afc..42281ea 100644 --- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java +++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -40,6 +40,7 @@ import org.chromium.chromoting.help.HelpSingleton; import org.chromium.chromoting.jni.Client; import org.chromium.chromoting.jni.ConnectionListener; +import org.chromium.chromoting.jni.JniInterface; import java.util.ArrayList; import java.util.Arrays; @@ -575,6 +576,7 @@ @Override public void onAccountSelected(String accountName) { mAccount = accountName; + JniInterface.setAccountForLogging(accountName); // The current host list is no longer valid for the new account, so clear the list. mHosts = new HostInfo[0];
diff --git a/remoting/android/java/src/org/chromium/chromoting/OAuthTokenConsumer.java b/remoting/android/java/src/org/chromium/chromoting/OAuthTokenConsumer.java index 1e3771e..b3f65f5 100644 --- a/remoting/android/java/src/org/chromium/chromoting/OAuthTokenConsumer.java +++ b/remoting/android/java/src/org/chromium/chromoting/OAuthTokenConsumer.java
@@ -4,7 +4,7 @@ package org.chromium.chromoting; -import android.app.Activity; +import android.content.Context; import org.chromium.chromoting.base.OAuthTokenFetcher; @@ -13,17 +13,18 @@ * time. */ public class OAuthTokenConsumer { - private Activity mActivity; + private Context mContext; private String mTokenScope; private boolean mWaitingForAuthToken; private String mLatestToken; /** - * @param activity The Chromoting activity. + * @param context The context used to fetch token. |context| must be an activity if user + * interaction is required to get back the token. * @param tokenScope Scope to use when fetching the OAuth token. */ - public OAuthTokenConsumer(Activity activity, String tokenScope) { - mActivity = activity; + public OAuthTokenConsumer(Context context, String tokenScope) { + mContext = context; mTokenScope = tokenScope; mWaitingForAuthToken = false; } @@ -47,7 +48,7 @@ } mWaitingForAuthToken = true; - new OAuthTokenFetcher(mActivity, account, mTokenScope, new OAuthTokenFetcher.Callback() { + new OAuthTokenFetcher(mContext, account, mTokenScope, new OAuthTokenFetcher.Callback() { @Override public void onTokenFetched(String token) { mWaitingForAuthToken = false;
diff --git a/remoting/android/java/src/org/chromium/chromoting/base/OAuthTokenFetcher.java b/remoting/android/java/src/org/chromium/chromoting/base/OAuthTokenFetcher.java index 78bb27ea..96756e4 100644 --- a/remoting/android/java/src/org/chromium/chromoting/base/OAuthTokenFetcher.java +++ b/remoting/android/java/src/org/chromium/chromoting/base/OAuthTokenFetcher.java
@@ -5,7 +5,10 @@ package org.chromium.chromoting.base; import android.app.Activity; +import android.content.Context; import android.os.AsyncTask; +import android.os.Handler; +import android.os.Looper; import com.google.android.gms.auth.GoogleAuthException; import com.google.android.gms.auth.GoogleAuthUtil; @@ -20,11 +23,12 @@ public class OAuthTokenFetcher { /** * Callback interface to receive the token, or an error notification. These will be called - * on the application's main thread. Note that if a user-recoverable error occurs, neither of - * these callback will be triggered. Instead, a new Activity will be launched, and the calling - * Activity must override + * on the application's main thread. Note that if a user-recoverable error occurs and the + * passed-in context is an activity, neither of these callback will be triggered. Instead, a new + * Activity will be launched, and the calling Activity must override * {@link android.app.Activity#onActivityResult} and handle the result code * {@link REQUEST_CODE_RECOVER_FROM_OAUTH_ERROR} to re-attempt or cancel fetching the token. + * If the context is not an activity, onError will be called with Error.UI. */ public interface Callback { /** Called when a token is obtained. */ @@ -37,16 +41,17 @@ } /** Error types that can be returned as non-recoverable errors from the token-fetcher. */ - public enum Error { NETWORK, UNEXPECTED } + public enum Error { NETWORK, UI, UNEXPECTED } /** Request code used for starting the OAuth recovery activity. */ public static final int REQUEST_CODE_RECOVER_FROM_OAUTH_ERROR = 100; /** - * Reference to the main activity. Used for running tasks on the main thread, and for - * starting other activities to handle user-recoverable errors. + * Reference to the context to fetch token. It will be used for starting other activities to + * handle user-recoverable errors if it is an activity, otherwise user-recoverable errors will + * not be handled. */ - private Activity mActivity; + private Context mContext; /** Account name (e-mail) for which the token will be fetched. */ private String mAccountName; @@ -56,9 +61,9 @@ private Callback mCallback; - public OAuthTokenFetcher(Activity activity, String accountName, String tokenScope, + public OAuthTokenFetcher(Context context, String accountName, String tokenScope, Callback callback) { - mActivity = activity; + mContext = context; mAccountName = accountName; mTokenScope = tokenScope; mCallback = callback; @@ -84,13 +89,13 @@ protected Void doInBackground(Void... params) { try { if (expiredToken != null) { - GoogleAuthUtil.clearToken(mActivity, expiredToken); + GoogleAuthUtil.clearToken(mContext, expiredToken); } // This method is deprecated but its replacement is not yet available. // TODO(lambroslambrou): Fix this by replacing |mAccountName| with an instance // of android.accounts.Account. - String token = GoogleAuthUtil.getToken(mActivity, mAccountName, mTokenScope); + String token = GoogleAuthUtil.getToken(mContext, mAccountName, mTokenScope); handleTokenReceived(token); } catch (IOException ioException) { handleError(Error.NETWORK); @@ -105,7 +110,7 @@ } private void handleTokenReceived(final String token) { - mActivity.runOnUiThread(new Runnable() { + new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { mCallback.onTokenFetched(token); @@ -114,7 +119,7 @@ } private void handleError(final Error error) { - mActivity.runOnUiThread(new Runnable() { + new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { mCallback.onError(error); @@ -123,10 +128,15 @@ } private void handleRecoverableException(final UserRecoverableAuthException exception) { - mActivity.runOnUiThread(new Runnable() { + if (!(mContext instanceof Activity)) { + handleError(Error.UI); + return; + } + final Activity activity = (Activity) mContext; + activity.runOnUiThread(new Runnable() { @Override public void run() { - mActivity.startActivityForResult(exception.getIntent(), + activity.startActivityForResult(exception.getIntent(), REQUEST_CODE_RECOVER_FROM_OAUTH_ERROR); } });
diff --git a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java index 47a8d2b..4d37bb8 100644 --- a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java +++ b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
@@ -8,8 +8,11 @@ import android.graphics.Bitmap; import org.chromium.base.ContextUtils; +import org.chromium.base.Log; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; +import org.chromium.chromoting.OAuthTokenConsumer; +import org.chromium.chromoting.base.OAuthTokenFetcher; import java.nio.ByteBuffer; @@ -19,6 +22,15 @@ */ @JNINamespace("remoting") public class JniInterface { + private static final String TAG = "Chromoting"; + + private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com/auth/chromoting"; + + // Used to fetch auth token for native client. + private static OAuthTokenConsumer sLoggerTokenConsumer; + + private static String sAccount; + /** * To be called once from the Application context singleton. Loads and initializes the native * code. Called on the UI thread. @@ -26,6 +38,7 @@ */ public static void loadLibrary(Context context) { ContextUtils.initApplicationContext(context.getApplicationContext()); + sLoggerTokenConsumer = new OAuthTokenConsumer(context.getApplicationContext(), TOKEN_SCOPE); System.loadLibrary("remoting_client_jni"); ContextUtils.initApplicationContextForNative(); nativeLoadNative(); @@ -180,4 +193,28 @@ /** Passes extension message to the native code. */ static native void nativeSendExtensionMessage(String type, String data); + + public static void setAccountForLogging(String account) { + sAccount = account; + } + + @CalledByNative + private static void fetchAuthToken() { + if (sAccount == null) { + throw new IllegalStateException("Account is not set before fetching the auth token."); + } + sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback() { + @Override + public void onTokenFetched(String token) { + nativeOnAuthTokenFetched(token); + } + + @Override + public void onError(OAuthTokenFetcher.Error error) { + Log.e(TAG, "Failed to fetch auth token for native client."); + } + }); + } + + static native void nativeOnAuthTokenFetched(String token); }
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc index 5ca09b9..e67f9c3 100644 --- a/remoting/client/jni/chromoting_jni_instance.cc +++ b/remoting/client/jni/chromoting_jni_instance.cc
@@ -18,7 +18,7 @@ #include "net/socket/client_socket_factory.h" #include "remoting/base/chromium_url_request.h" #include "remoting/client/audio_player_android.h" -#include "remoting/client/client_status_logger.h" +#include "remoting/client/client_telemetry_logger.h" #include "remoting/client/jni/android_keymap.h" #include "remoting/client/jni/chromoting_jni_runtime.h" #include "remoting/client/jni/jni_frame_consumer.h" @@ -42,8 +42,6 @@ const int kXmppPort = 5222; const bool kXmppUseTls = true; -const char kDirectoryBotJid[] = "remoting@bot.talk.google.com"; - // Interval at which to log performance statistics, if enabled. const int kPerfStatsIntervalMs = 60000; @@ -97,7 +95,6 @@ DCHECK(!video_renderer_); DCHECK(!client_); DCHECK(!signaling_); - DCHECK(!client_status_logger_); } void ChromotingJniInstance::Disconnect() { @@ -110,9 +107,18 @@ stats_logging_enabled_ = false; + // User disconnection will not trigger OnConnectionState(Closed, OK). + // Remote disconnection will trigger OnConnectionState(...) and later trigger + // Disconnect(). + if (connected_) { + jni_runtime_->logger()->LogSessionStateChange( + ChromotingEvent::SessionState::CLOSED, + ChromotingEvent::ConnectionError::NONE); + connected_ = false; + } + // |client_| must be torn down before |signaling_|. client_.reset(); - client_status_logger_.reset(); video_renderer_.reset(); view_.reset(); signaling_.reset(); @@ -297,9 +303,14 @@ protocol::ErrorCode error) { DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); - EnableStatsLogging(state == protocol::ConnectionToHost::CONNECTED); + // This code assumes no intermediate connection state between CONNECTED and + // CLOSED/FAILED. + connected_ = state == protocol::ConnectionToHost::CONNECTED; + EnableStatsLogging(connected_); - client_status_logger_->LogSessionStateChange(state, error); + jni_runtime_->logger()->LogSessionStateChange( + ClientTelemetryLogger::TranslateState(state), + ClientTelemetryLogger::TranslateError(error)); if (create_pairing_ && state == protocol::ConnectionToHost::CONNECTED) { protocol::PairingRequest request; @@ -404,9 +415,6 @@ new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), jni_runtime_->url_requester(), xmpp_config_)); - client_status_logger_.reset(new ClientStatusLogger( - ServerLogEntry::ME2ME, signaling_.get(), kDirectoryBotJid)); - scoped_refptr<protocol::TransportContext> transport_context = new protocol::TransportContext( signaling_.get(), @@ -508,7 +516,7 @@ perf_tracker_->round_trip_ms().Average(), perf_tracker_->round_trip_ms().Max()); - client_status_logger_->LogStatistics(perf_tracker_.get()); + jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); jni_runtime_->network_task_runner()->PostDelayedTask( FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this),
diff --git a/remoting/client/jni/chromoting_jni_instance.h b/remoting/client/jni/chromoting_jni_instance.h index da02627..e832771 100644 --- a/remoting/client/jni/chromoting_jni_instance.h +++ b/remoting/client/jni/chromoting_jni_instance.h
@@ -31,7 +31,6 @@ } // namespace protocol class ChromotingJniRuntime; -class ClientStatusLogger; class JniFrameConsumer; // ClientUserInterface that indirectly makes and receives JNI calls. @@ -163,7 +162,6 @@ std::unique_ptr<ChromotingClient> client_; XmppSignalStrategy::XmppServerConfig xmpp_config_; std::unique_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ - std::unique_ptr<ClientStatusLogger> client_status_logger_; protocol::ThirdPartyTokenFetchedCallback third_party_token_fetched_callback_; // Pass this the user's PIN once we have it. To be assigned and accessed on @@ -189,6 +187,10 @@ // set of capabilities for this remoting session. std::string capabilities_; + // Indicates whether the client is connected to the host. Used on network + // thread. + bool connected_ = false; + friend class base::RefCountedThreadSafe<ChromotingJniInstance>; base::WeakPtrFactory<ChromotingJniInstance> weak_factory_;
diff --git a/remoting/client/jni/chromoting_jni_runtime.cc b/remoting/client/jni/chromoting_jni_runtime.cc index 443e0b6..d4d0cf16 100644 --- a/remoting/client/jni/chromoting_jni_runtime.cc +++ b/remoting/client/jni/chromoting_jni_runtime.cc
@@ -10,10 +10,12 @@ #include "base/android/library_loader/library_loader_hooks.h" #include "base/android/scoped_java_ref.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "base/memory/singleton.h" #include "base/stl_util.h" #include "base/synchronization/waitable_event.h" #include "jni/JniInterface_jni.h" +#include "remoting/base/chromium_url_request.h" #include "remoting/base/url_request_context_getter.h" #include "remoting/client/jni/jni_touch_event_data.h" @@ -25,6 +27,8 @@ const int kBytesPerPixel = 4; +const char kTelemetryBaseUrl[] = "https://remoting-pa.googleapis.com/v1/events"; + } // namespace namespace remoting { @@ -178,6 +182,21 @@ ConvertJavaStringToUTF8(env, data)); } +static void HandleAuthTokenOnNetworkThread(const std::string& token) { + ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); + DCHECK(runtime->network_task_runner()->BelongsToCurrentThread()); + runtime->logger()->SetAuthToken(token); +} + +static void OnAuthTokenFetched(JNIEnv* env, + const JavaParamRef<jclass>& clazz, + const JavaParamRef<jstring>& token) { + ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); + runtime->network_task_runner()->PostTask( + FROM_HERE, base::Bind(&HandleAuthTokenOnNetworkThread, + ConvertJavaStringToUTF8(env, token))); +} + // ChromotingJniRuntime implementation. // static @@ -203,6 +222,9 @@ // Pass the main ui loop already attached to be used for creating threads. runtime_ = ChromotingClientRuntime::Create(ui_loop_.get()); + network_task_runner()->PostTask( + FROM_HERE, base::Bind(&ChromotingJniRuntime::StartLoggerOnNetworkThread, + base::Unretained(this))); } ChromotingJniRuntime::~ChromotingJniRuntime() { @@ -280,6 +302,18 @@ env, j_host.obj(), j_id.obj(), j_secret.obj()); } +void ChromotingJniRuntime::FetchAuthToken() { + if (!ui_task_runner()->BelongsToCurrentThread()) { + ui_task_runner()->PostTask( + FROM_HERE, base::Bind(&ChromotingJniRuntime::FetchAuthToken, + base::Unretained(this))); + return; + } + JNIEnv* env = base::android::AttachCurrentThread(); + + Java_JniInterface_fetchAuthToken(env); +} + void ChromotingJniRuntime::FetchThirdPartyToken(const std::string& token_url, const std::string& client_id, const std::string& scope) { @@ -363,4 +397,17 @@ base::android::DetachFromVM(); waiter->Signal(); } + +void ChromotingJniRuntime::StartLoggerOnNetworkThread() { + DCHECK(network_task_runner()->BelongsToCurrentThread()); + logger_.reset(new ClientTelemetryLogger(ChromotingEvent::Mode::ME2ME)); + logger_->Start( + base::WrapUnique( + new ChromiumUrlRequestFactory(runtime_->url_requester())), + kTelemetryBaseUrl); + logger_->SetAuthClosure( + base::Bind(&ChromotingJniRuntime::FetchAuthToken, + base::Unretained(this))); +} + } // namespace remoting
diff --git a/remoting/client/jni/chromoting_jni_runtime.h b/remoting/client/jni/chromoting_jni_runtime.h index bb5a216..18b0dec 100644 --- a/remoting/client/jni/chromoting_jni_runtime.h +++ b/remoting/client/jni/chromoting_jni_runtime.h
@@ -13,6 +13,7 @@ #include "net/url_request/url_request_context_getter.h" #include "remoting/base/auto_thread.h" #include "remoting/client/chromoting_client_runtime.h" +#include "remoting/client/client_telemetry_logger.h" #include "remoting/client/jni/chromoting_jni_instance.h" #include "remoting/protocol/connection_to_host.h" @@ -50,6 +51,14 @@ return runtime_->url_requester(); } + // The runtime handles authentication and the caller should not call SetAuth*. + // The runtime itself will not send out any logs. Used on the network thread. + ClientTelemetryLogger* logger() { + DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread()); + DCHECK(logger_); + return logger_.get(); + } + // Initiates a connection with the specified host. Only call when a host // connection is active (i.e. between a call to Connect() and the // corresponding call to Disconnect()). To skip the attempt at pair-based @@ -87,6 +96,9 @@ const std::string& id, const std::string& secret); + // Fetch OAuth token for the telemetry logger. Call on UI thread. + void FetchAuthToken(); + // Pops up a third party login page to fetch token required for // authentication. Call on UI thread. void FetchThirdPartyToken(const std::string& token_url, @@ -127,6 +139,9 @@ // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. void DetachFromVmAndSignal(base::WaitableEvent* waiter); + // Starts the logger on the network thread. + void StartLoggerOnNetworkThread(); + // Chromium code's connection to the app message loop. Once created the // MessageLoop will live for the life of the program. std::unique_ptr<base::MessageLoopForUI> ui_loop_; @@ -138,6 +153,9 @@ // Contains all connection-specific state. scoped_refptr<ChromotingJniInstance> session_; + // For logging session stage changes and stats. + std::unique_ptr<ClientTelemetryLogger> logger_; + friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>; DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime);
diff --git a/sync/android/java/src/org/chromium/sync/notifier/InvalidationPreferences.java b/sync/android/java/src/org/chromium/sync/notifier/InvalidationPreferences.java index 1d3c4ec..58a5acb 100644 --- a/sync/android/java/src/org/chromium/sync/notifier/InvalidationPreferences.java +++ b/sync/android/java/src/org/chromium/sync/notifier/InvalidationPreferences.java
@@ -5,14 +5,13 @@ package org.chromium.sync.notifier; import android.accounts.Account; -import android.content.Context; import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.util.Base64; import android.util.Log; import com.google.ipc.invalidation.external.client.types.ObjectId; +import org.chromium.base.ContextUtils; import org.chromium.base.VisibleForTesting; import java.util.Collection; @@ -40,11 +39,11 @@ * Wrapper around a {@link android.content.SharedPreferences.Editor} for the preferences. * Used to avoid exposing raw preference objects to users of this class. */ - public class EditContext { + public static class EditContext { private final SharedPreferences.Editor mEditor; EditContext() { - mEditor = PreferenceManager.getDefaultSharedPreferences(mContext).edit(); + mEditor = ContextUtils.getAppSharedPreferences().edit(); } } @@ -80,14 +79,6 @@ // Only one commit call can be in progress at a time. private static final Object sCommitLock = new Object(); - private final Context mContext; - - public InvalidationPreferences(Context context) { - Context appContext = context.getApplicationContext(); - if (appContext == null) throw new NullPointerException("Unable to get application context"); - mContext = appContext; - } - /** Returns a new {@link EditContext} to modify the preferences managed by this class. */ public EditContext edit() { return new EditContext(); @@ -111,7 +102,7 @@ /** Returns the saved sync types, or {@code null} if none exist. */ @Nullable public Set<String> getSavedSyncedTypes() { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); Set<String> syncedTypes = preferences.getStringSet(PrefKeys.SYNC_TANGO_TYPES, null); // Wrap with unmodifiableSet to ensure it's never modified. See crbug.com/568369. return syncedTypes == null ? null : Collections.unmodifiableSet(syncedTypes); @@ -127,7 +118,7 @@ /** Returns the saved non-sync object ids, or {@code null} if none exist. */ @Nullable public Set<ObjectId> getSavedObjectIds() { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); Set<String> objectIdStrings = preferences.getStringSet(PrefKeys.TANGO_OBJECT_IDS, null); if (objectIdStrings == null) { return null; @@ -154,7 +145,7 @@ /** Returns the saved account, or {@code null} if none exists. */ @Nullable public Account getSavedSyncedAccount() { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); String accountName = preferences.getString(PrefKeys.SYNC_ACCT_NAME, null); String accountType = preferences.getString(PrefKeys.SYNC_ACCT_TYPE, null); if (accountName == null || accountType == null) { @@ -171,7 +162,7 @@ /** Returns the notification client internal state. */ @Nullable public byte[] getInternalNotificationClientState() { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext); + SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); String base64State = preferences.getString(PrefKeys.SYNC_TANGO_INTERNAL_STATE, null); if (base64State == null) { return null;
diff --git a/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java b/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java index 26a5067..e37cf1e 100644 --- a/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java +++ b/sync/android/java/src/org/chromium/sync/signin/ChromeSigninController.java
@@ -6,8 +6,8 @@ import android.accounts.Account; import android.content.Context; -import android.preference.PreferenceManager; +import org.chromium.base.ContextUtils; import org.chromium.sync.AndroidSyncSettings; /** @@ -59,7 +59,7 @@ } public void setSignedInAccountName(String accountName) { - PreferenceManager.getDefaultSharedPreferences(mApplicationContext).edit() + ContextUtils.getAppSharedPreferences().edit() .putString(SIGNED_IN_ACCOUNT_KEY, accountName) .apply(); // TODO(maxbogue): Move this to SigninManager. @@ -67,7 +67,6 @@ } public String getSignedInAccountName() { - return PreferenceManager.getDefaultSharedPreferences(mApplicationContext) - .getString(SIGNED_IN_ACCOUNT_KEY, null); + return ContextUtils.getAppSharedPreferences().getString(SIGNED_IN_ACCOUNT_KEY, null); } }
diff --git a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationPreferencesTest.java b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationPreferencesTest.java index 4bcfd20f..c88ba72 100644 --- a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationPreferencesTest.java +++ b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationPreferencesTest.java
@@ -5,14 +5,12 @@ package org.chromium.sync.notifier; import android.accounts.Account; -import android.content.Context; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; import com.google.ipc.invalidation.external.client.types.ObjectId; import org.chromium.base.CollectionUtil; -import org.chromium.base.test.util.AdvancedMockContext; import org.chromium.base.test.util.Feature; import java.util.Arrays; @@ -24,21 +22,13 @@ * @author dsmyers@google.com (Daniel Myers) */ public class InvalidationPreferencesTest extends InstrumentationTestCase { - private Context mContext; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mContext = new AdvancedMockContext(getInstrumentation().getContext()); - } - @SmallTest @Feature({"Sync"}) public void testReadMissingData() { /* * Test plan: read saved state from empty preferences. Verify that null is returned. */ - InvalidationPreferences invPreferences = new InvalidationPreferences(mContext); + InvalidationPreferences invPreferences = new InvalidationPreferences(); assertNull(invPreferences.getSavedSyncedAccount()); assertNull(invPreferences.getSavedSyncedTypes()); assertNull(invPreferences.getSavedObjectIds()); @@ -52,7 +42,7 @@ * Test plan: write and read back saved state. Verify that the returned state is what * was written. */ - InvalidationPreferences invPreferences = new InvalidationPreferences(mContext); + InvalidationPreferences invPreferences = new InvalidationPreferences(); InvalidationPreferences.EditContext editContext = invPreferences.edit(); // Write mix of valid and invalid types to disk to test that preferences are not
diff --git a/sync/engine/net/server_connection_manager.cc b/sync/engine/net/server_connection_manager.cc index a5be7a5..b496f5b 100644 --- a/sync/engine/net/server_connection_manager.cc +++ b/sync/engine/net/server_connection_manager.cc
@@ -299,33 +299,6 @@ return false; } -// Returns the current server parameters in server_url and port. -void ServerConnectionManager::GetServerParameters(string* server_url, - int* port, - bool* use_ssl) const { - if (server_url != NULL) - *server_url = sync_server_; - if (port != NULL) - *port = sync_server_port_; - if (use_ssl != NULL) - *use_ssl = use_ssl_; -} - -std::string ServerConnectionManager::GetServerHost() const { - string server_url; - int port; - bool use_ssl; - GetServerParameters(&server_url, &port, &use_ssl); - // For unit tests. - if (server_url.empty()) - return std::string(); - // We just want the hostname, so we don't need to switch on use_ssl. - server_url = "http://" + server_url; - GURL gurl(server_url); - DCHECK(gurl.is_valid()) << gurl; - return gurl.host(); -} - void ServerConnectionManager::AddListener( ServerConnectionEventListener* listener) { DCHECK(thread_checker_.CalledOnValidThread());
diff --git a/sync/engine/net/server_connection_manager.h b/sync/engine/net/server_connection_manager.h index 6003225..8d3028c 100644 --- a/sync/engine/net/server_connection_manager.h +++ b/sync/engine/net/server_connection_manager.h
@@ -158,7 +158,6 @@ ServerConnectionManager* scm_; private: - int ReadResponse(void* buffer, int length); int ReadResponse(std::string* buffer, int length); }; @@ -185,13 +184,6 @@ const std::string client_id() const { return client_id_; } - // Returns the current server parameters in server_url, port and use_ssl. - void GetServerParameters(std::string* server_url, - int* port, - bool* use_ssl) const; - - std::string GetServerHost() const; - // Factory method to create an Connection object we can use for // communication with the server. virtual Connection* MakeConnection(); @@ -288,8 +280,6 @@ Connection* active_connection_; private: - friend class Connection; - // A class to help deal with cleaning up active Connection objects when (for // ex) multiple early-exits are present in some scope. ScopedConnectionHelper // informs the ServerConnectionManager before the Connection object it takes
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation b/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation index da5af548..f1d8a9a5 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation
@@ -96,7 +96,7 @@ http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_redirect_with_timing_allow_origin.html [ Timeout ] http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_cross_origin_redirect.html [ Timeout ] http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_same_origin_redirect.html [ Timeout ] - imported/web-platform-tests/web-animations/animation-timeline/document-timeline.html [ Failure ] + imported/wpt/web-animations/animation-timeline/document-timeline.html [ Failure ] # https://crbug.com/555418: Move `X-Frame-Options` and CSP's `frame-ancestor` # checks up out of the renderer.
diff --git a/third_party/WebKit/LayoutTests/MSANExpectations b/third_party/WebKit/LayoutTests/MSANExpectations index eef8802..3cada19d 100644 --- a/third_party/WebKit/LayoutTests/MSANExpectations +++ b/third_party/WebKit/LayoutTests/MSANExpectations
@@ -31,7 +31,7 @@ crbug.com/454267 [ Linux ] virtual/gpu/fast/canvas/canvas-ellipse-360-winding.html [ Crash ] crbug.com/522315 [ Linux ] virtual/gpu/fast/canvas/quadraticCurveTo.xml [ Crash ] -crbug.com/517704 [ Linux ] imported/web-platform-tests/encoding/api-invalid-label.html [ Timeout Pass ] +crbug.com/517704 [ Linux ] imported/wpt/encoding/api-invalid-label.html [ Timeout Pass ] # Times out on MSAN crbug.com/462190 [ Linux ] inspector-protocol/heap-profiler/heap-samples-in-snapshot.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/SlowTests b/third_party/WebKit/LayoutTests/SlowTests index b90d1f9..caf7823b5 100644 --- a/third_party/WebKit/LayoutTests/SlowTests +++ b/third_party/WebKit/LayoutTests/SlowTests
@@ -172,7 +172,7 @@ crbug.com/453312 html5lib/generated/run-webkit01-data.html [ Slow ] crbug.com/453312 html5lib/webkit-resumer.html [ Slow ] -crbug.com/577381 [ Linux Debug ] imported/web-platform-tests/encoding/api-invalid-label.html [ Slow ] +crbug.com/577381 [ Linux Debug ] imported/wpt/encoding/api-invalid-label.html [ Slow ] crbug.com/577381 [ Linux Debug ] imported/web-platform-tests/html/syntax/parsing/html5lib_tests10.html [ Slow ] crbug.com/577381 [ Linux Debug ] imported/web-platform-tests/html/syntax/parsing/html5lib_tests21.html [ Slow ] crbug.com/577381 [ Linux Debug ] imported/web-platform-tests/html/syntax/parsing/html5lib_webkit01.html [ Slow ]
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index ff2d88c..7d4b71d 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -115,7 +115,7 @@ crbug.com/521091 http/tests/inspector/elements/styles/selector-line-sourcemap-header.html [ Crash Failure Timeout Pass ] crbug.com/521093 http/tests/loading/pdf-commit-load-callbacks.html [ Failure Pass ] crbug.com/521094 [ Mac ] http/tests/navigation/beacon-cross-origin.https.html [ Crash Failure Pass ] -crbug.com/521096 imported/web-platform-tests/webstorage/event_case_sensitive.html [ Failure Pass ] +crbug.com/521096 imported/wpt/webstorage/event_case_sensitive.html [ Failure Pass ] crbug.com/521107 [ Debug ] fast/html/imports/import-custom-element-abort.html [ Crash Pass ] crbug.com/520166 compositing/overflow/do-not-repaint-if-scrolling-composited-layers.html [ Failure Pass ] crbug.com/520169 [ Win ] fast/dom/Geolocation/timestamp.html [ Failure Pass ] @@ -161,10 +161,10 @@ # These performance-sensitive user-timing tests are flaky in debug on all platforms, and flaky on all configurations of windows. # See: crbug.com/567965, crbug.com/518992, and crbug.com/518993 -crbug.com/567965 [ Debug ] imported/web-platform-tests/user-timing/test_user_timing_measure.html [ Skip ] -crbug.com/518992 [ Win Release ] imported/web-platform-tests/user-timing/test_user_timing_measure.html [ Skip ] -crbug.com/567965 [ Debug ] imported/web-platform-tests/user-timing/test_user_timing_mark.html [ Skip ] -crbug.com/518993 imported/web-platform-tests/user-timing/test_user_timing_measure_navigation_timing.html [ Skip ] +crbug.com/567965 [ Debug ] imported/wpt/user-timing/test_user_timing_measure.html [ Skip ] +crbug.com/518992 [ Win Release ] imported/wpt/user-timing/test_user_timing_measure.html [ Skip ] +crbug.com/567965 [ Debug ] imported/wpt/user-timing/test_user_timing_mark.html [ Skip ] +crbug.com/518993 imported/wpt/user-timing/test_user_timing_measure_navigation_timing.html [ Skip ] crbug.com/526594 [ Win ] plugins/webview-plugin-lifecycle.html [ Failure ] @@ -530,7 +530,7 @@ crbug.com/505364 imported/web-platform-tests/custom-elements/v0/instantiating/extensions-to-document-interface/create-element-interface-type-is-a-type-extension.html [ Failure ] crbug.com/505364 imported/csswg-test/css-scoping-1/css-scoping-shadow-slot-display-override.html [ Failure ] -crbug.com/517840 imported/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html [ Failure Timeout ] +crbug.com/517840 imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html [ Failure Timeout ] crbug.com/603997 compositing/overflow/clear-scroll-parent.html [ NeedsManualRebaseline ] crbug.com/603997 virtual/prefer_compositing_to_lcd_text/compositing/overflow/clear-scroll-parent.html [ NeedsManualRebaseline ] @@ -541,6 +541,8 @@ crbug.com/380217 [ Linux Win ] fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius.html [ Skip ] crbug.com/380217 [ Win ] fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-bottom-left.html [ Skip ] +crbug.com/605840 [ Linux Win ] fast/text/hyphens/hyphens-auto.html [ Skip ] + crbug.com/405389 imported/csswg-test/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-017.html [ Failure ] crbug.com/424365 imported/csswg-test/css-shapes-1/shape-outside/shape-image/shape-image-010.html [ Failure ] crbug.com/424365 imported/csswg-test/css-shapes-1/shape-outside/shape-image/shape-image-024.html [ Failure ] @@ -735,7 +737,7 @@ crbug.com/498845 [ Win ] fast/multicol/vertical-rl/float-content-break.html [ Failure ] crbug.com/443615 [ Linux Win ] imported/csswg-test/css-shapes-1/shape-outside/supported-shapes/circle/shape-outside-circle-027.html [ Failure ] -crbug.com/443379 imported/web-platform-tests/gamepad/idlharness.html [ Failure Timeout ] +crbug.com/443379 imported/wpt/gamepad/idlharness.html [ Failure Timeout ] crbug.com/396775 compositing/overflow/reflected-overlay-scrollbars-should-appear-without-compositing.html [ Failure ] crbug.com/396775 virtual/prefer_compositing_to_lcd_text/compositing/overflow/reflected-overlay-scrollbars-should-appear-without-compositing.html [ Failure ] @@ -1188,8 +1190,6 @@ crbug.com/564109 [ Win7 ] http/tests/webfont/font-display.html [ Pass Timeout Failure ] -crbug.com/568867 [ Win Debug ] transforms/3d/point-mapping/3d-point-mapping-deep.html [ Failure ] - crbug.com/571376 http/tests/webfont/font-display-intervention.html [ Pass Failure ] crbug.com/320139 fast/repaint/block-layout-inline-children-replaced.html [ Pass Failure ] @@ -1297,13 +1297,13 @@ crbug.com/605525 [ Win ] http/tests/xmlhttprequest/redirect-cross-origin-post.html [ Failure Pass ] -crbug.com/603703 [ Linux Mac ] imported/web-platform-tests/web-animations/animation-timeline/document-timeline.html [ Failure Pass ] +crbug.com/603703 [ Linux Mac ] imported/wpt/web-animations/animation-timeline/document-timeline.html [ Failure Pass ] -crbug.com/600248 imported/web-platform-tests/web-animations/animation-effect-timing/endDelay.html [ Failure ] -crbug.com/600248 imported/web-platform-tests/web-animations/animation/constructor.html [ Failure Timeout ] -crbug.com/600248 imported/web-platform-tests/web-animations/animation/finished.html [ Pass Failure ] -crbug.com/600248 imported/web-platform-tests/web-animations/animation/oncancel.html [ Pass Failure ] -crbug.com/600248 imported/web-platform-tests/web-animations/animation/onfinish.html [ Pass Failure ] +crbug.com/600248 imported/wpt/web-animations/animation-effect-timing/endDelay.html [ Failure ] +crbug.com/600248 imported/wpt/web-animations/animation/constructor.html [ Failure Timeout ] +crbug.com/600248 imported/wpt/web-animations/animation/finished.html [ Pass Failure ] +crbug.com/600248 imported/wpt/web-animations/animation/oncancel.html [ Pass Failure ] +crbug.com/600248 imported/wpt/web-animations/animation/onfinish.html [ Pass Failure ] crbug.com/604642 [ Mac ] fast/text/midword-break-after-breakable-char.html [ Failure ] @@ -1314,8 +1314,6 @@ crbug.com/605059 [ Retina ] fast/text/international/rtl-negative-letter-spacing.html [ Failure ] -crbug.com/606302 [ Win7 ] transforms/3d/point-mapping/3d-point-mapping-preserve-3d.html [ Failure Pass ] - crbug.com/610464 [ Win7 Debug ] inspector/components/throttler.html [ Failure Pass ] crbug.com/606649 fast/dom/gc-dom-tree-lifetime.html [ Pass Timeout ]
diff --git a/third_party/WebKit/LayoutTests/W3CImportExpectations b/third_party/WebKit/LayoutTests/W3CImportExpectations index 969d5bf..e547cfa 100644 --- a/third_party/WebKit/LayoutTests/W3CImportExpectations +++ b/third_party/WebKit/LayoutTests/W3CImportExpectations
@@ -187,11 +187,11 @@ # imported/web-platform-tests/IndexedDB [ Pass ] imported/web-platform-tests/WebCryptoAPI [ Skip ] ## Owners: jsbell@chromium.org -# imported/web-platform-tests/WebIDL [ Pass ] -imported/web-platform-tests/WebIDL/invalid [ Skip ] -imported/web-platform-tests/WebIDL/readme.txt [ Skip ] -imported/web-platform-tests/WebIDL/testable_assertions.txt [ Skip ] -imported/web-platform-tests/WebIDL/valid [ Skip ] +# imported/wpt/WebIDL [ Pass ] +imported/wpt/WebIDL/invalid [ Skip ] +imported/wpt/WebIDL/readme.txt [ Skip ] +imported/wpt/WebIDL/testable_assertions.txt [ Skip ] +imported/wpt/WebIDL/valid [ Skip ] imported/web-platform-tests/XMLHttpRequest [ Skip ] imported/web-platform-tests/ambient-light [ Skip ] imported/web-platform-tests/animation-timing [ Skip ] @@ -211,18 +211,18 @@ imported/web-platform-tests/custom-elements/v0/registering/unresolved-element-pseudoclass [ Skip ] imported/web-platform-tests/docs [ Skip ] ## Owners: tkent@chromium.org -imported/web-platform-tests/dom [ Pass ] -imported/web-platform-tests/domparsing [ Skip ] -imported/web-platform-tests/domxpath [ Skip ] +imported/wpt/dom [ Pass ] +imported/wpt/domparsing [ Skip ] +imported/wpt/domxpath [ Skip ] imported/web-platform-tests/editing [ Skip ] ## Owners: jsbell@chromium.org -# imported/web-platform-tests/encoding [ Pass ] +# imported/wpt/encoding [ Pass ] imported/web-platform-tests/eventsource [ Skip ] imported/web-platform-tests/ext-xhtml-pubid [ Skip ] imported/web-platform-tests/fetch [ Skip ] imported/web-platform-tests/fonts [ Skip ] ## Owners: bajones@chromium.org -# imported/web-platform-tests/gamepad [ Pass ] +# imported/wpt/gamepad [ Pass ] imported/web-platform-tests/generic-sensor [ Skip ] imported/web-platform-tests/geolocation-API [ Skip ] ## Owners: jsbell@chromium.org @@ -285,47 +285,47 @@ imported/web-platform-tests/svg [ Skip ] imported/web-platform-tests/tools [ Skip ] ## Owners: chongz@chromium.org -# imported/web-platform-tests/touch-events [ Pass ] +# imported/wpt/touch-events [ Pass ] imported/web-platform-tests/typedarrays [ Skip ] ## Owners: dtapuska@chromium.org # imported/web-platform-tests/uievents [ Pass ] imported/web-platform-tests/url [ Skip ] ## Owners: jsbell@chromium.org -# imported/web-platform-tests/user-timing [ Pass ] +# imported/wpt/user-timing [ Pass ] imported/web-platform-tests/vibration [ Skip ] ## Owners: suzyh@chromium.org -# imported/web-platform-tests/web-animations [ Pass ] +# imported/wpt/web-animations [ Pass ] imported/web-platform-tests/webaudio [ Skip ] imported/web-platform-tests/webdriver [ Skip ] imported/web-platform-tests/webgl [ Skip ] imported/web-platform-tests/webmessaging [ Skip ] ## Owners: hta@chromium.org -# imported/web-platform-tests/webrtc [ Pass ] +# imported/wpt/webrtc [ Pass ] imported/web-platform-tests/websockets [ Skip ] ## Owners: michaeln@chromium.org,jsbell@chromium.org -# imported/web-platform-tests/webstorage [ Pass ] +# imported/wpt/webstorage [ Pass ] imported/web-platform-tests/webvtt [ Skip ] imported/web-platform-tests/workers [ Skip ] # Skip OWNERS files in web-platform-tests. crbug.com/584660 -imported/web-platform-tests/user-timing/OWNERS [ Skip ] +imported/wpt/user-timing/OWNERS [ Skip ] imported/web-platform-tests/custom-elements/OWNERS [ Skip ] -imported/web-platform-tests/gamepad/OWNERS [ Skip ] +imported/wpt/gamepad/OWNERS [ Skip ] imported/web-platform-tests/FileAPI/OWNERS [ Skip ] imported/web-platform-tests/html/OWNERS [ Skip ] -imported/web-platform-tests/webrtc/OWNERS [ Skip ] +imported/wpt/webrtc/OWNERS [ Skip ] imported/web-platform-tests/html-imports/OWNERS [ Skip ] imported/web-platform-tests/IndexedDB/OWNERS [ Skip ] -imported/web-platform-tests/dom/OWNERS [ Skip ] +imported/wpt/dom/OWNERS [ Skip ] imported/web-platform-tests/shadow-dom/OWNERS [ Skip ] -imported/web-platform-tests/encoding/OWNERS [ Skip ] +imported/wpt/encoding/OWNERS [ Skip ] imported/web-platform-tests/hr-time/OWNERS [ Skip ] imported/web-platform-tests/pointerevents/OWNERS [ Skip ] -imported/web-platform-tests/webstorage/OWNERS [ Skip ] +imported/wpt/webstorage/OWNERS [ Skip ] imported/web-platform-tests/mediacapture-streams/OWNERS [ Skip ] -imported/web-platform-tests/touch-events/OWNERS [ Skip ] +imported/wpt/touch-events/OWNERS [ Skip ] imported/web-platform-tests/uievents/OWNERS [ Skip ] -imported/web-platform-tests/web-animations/OWNERS [ Skip ] +imported/wpt/web-animations/OWNERS [ Skip ] # Exceptions for individual files that fail due to bugs in the # upstream tests that we shouldn't bother importing until they are @@ -347,11 +347,11 @@ imported/web-platform-tests/html/syntax/parsing-html-fragments/the-input-byte-stream-038.html [ Skip ] # crbug.com/490939: The following tests are too large. They cause time out frequently. -imported/web-platform-tests/dom/ranges/Range-compareBoundaryPoints.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-comparePoint.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-isPointInRange.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-mutations.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-set.html [ Skip ] +imported/wpt/dom/ranges/Range-compareBoundaryPoints.html [ Skip ] +imported/wpt/dom/ranges/Range-comparePoint.html [ Skip ] +imported/wpt/dom/ranges/Range-isPointInRange.html [ Skip ] +imported/wpt/dom/ranges/Range-mutations.html [ Skip ] +imported/wpt/dom/ranges/Range-set.html [ Skip ] imported/web-platform-tests/html/dom/interfaces.html [ Skip ] imported/web-platform-tests/html/dom/reflection-embedded.html [ Skip ] imported/web-platform-tests/html/dom/reflection-forms.html [ Skip ] @@ -367,7 +367,7 @@ imported/web-platform-tests/html/browsers/browsing-the-web/read-text/load-text-plain.html [ Skip ] # crbug.com/498120: Using absolute URL links. -imported/web-platform-tests/dom/events/EventTarget-dispatchEvent.html [ Skip ] +imported/wpt/dom/events/EventTarget-dispatchEvent.html [ Skip ] imported/web-platform-tests/html/browsers/history/the-location-interface/location-stringifier.html [ Skip ] imported/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-07.html [ Skip ] imported/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.currentScript.sub.html [ Skip ] @@ -453,19 +453,19 @@ imported/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.html [ Skip ] # crbug.com/490940: Needs to load extra HTML resources. -imported/web-platform-tests/dom/nodes/Document-createElement-namespace.html [ Skip ] -imported/web-platform-tests/dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html [ Skip ] -imported/web-platform-tests/dom/nodes/Node-isEqualNode-xhtml.xhtml [ Skip ] -imported/web-platform-tests/dom/nodes/Node-parentNode.html [ Skip ] -imported/web-platform-tests/dom/nodes/ParentNode-querySelector-All.html [ Skip ] -imported/web-platform-tests/dom/nodes/ParentNode-querySelector-All.js [ Skip ] -imported/web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht.xht [ Skip ] -imported/web-platform-tests/dom/nodes/getElementsByClassName-31.htm [ Skip ] -imported/web-platform-tests/dom/ranges/Range-cloneContents.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-deleteContents.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-extractContents.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-insertNode.html [ Skip ] -imported/web-platform-tests/dom/ranges/Range-surroundContents.html [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace.html [ Skip ] +imported/wpt/dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html [ Skip ] +imported/wpt/dom/nodes/Node-isEqualNode-xhtml.xhtml [ Skip ] +imported/wpt/dom/nodes/Node-parentNode.html [ Skip ] +imported/wpt/dom/nodes/ParentNode-querySelector-All.html [ Skip ] +imported/wpt/dom/nodes/ParentNode-querySelector-All.js [ Skip ] +imported/wpt/dom/nodes/ParentNode-querySelector-All-xht.xht [ Skip ] +imported/wpt/dom/nodes/getElementsByClassName-31.htm [ Skip ] +imported/wpt/dom/ranges/Range-cloneContents.html [ Skip ] +imported/wpt/dom/ranges/Range-deleteContents.html [ Skip ] +imported/wpt/dom/ranges/Range-extractContents.html [ Skip ] +imported/wpt/dom/ranges/Range-insertNode.html [ Skip ] +imported/wpt/dom/ranges/Range-surroundContents.html [ Skip ] imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/001.html [ Skip ] imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html [ Skip ] imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html [ Skip ] @@ -548,28 +548,28 @@ imported/web-platform-tests/html/webappapis/scripting/events/onerroreventhandler.html [ Skip ] # crbug.com/493537: Need to support SVG reference tests -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/bare_mathml.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/bare_svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/bare_xhtml.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/empty.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/mathml.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/minimal_html.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/xhtml.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/xhtml_ns_changed.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/xhtml_ns_removed.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-childElement-null-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-add-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-remove-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-childElementCount-nochild-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-childElementCount-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-firstElementChild-entity.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-firstElementChild-namespace-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-firstElementChild-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-lastElementChild-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-nextElementSibling-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-previousElementSibling-svg.svg [ Skip ] -imported/web-platform-tests/dom/nodes/Element-siblingElement-null-svg.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/bare_mathml.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/bare_svg.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/bare_xhtml.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/empty.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/mathml.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/minimal_html.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/svg.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/xhtml.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/xhtml_ns_changed.svg [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/xhtml_ns_removed.svg [ Skip ] +imported/wpt/dom/nodes/Element-childElement-null-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-childElementCount-dynamic-add-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-childElementCount-dynamic-remove-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-childElementCount-nochild-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-childElementCount-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-firstElementChild-entity.svg [ Skip ] +imported/wpt/dom/nodes/Element-firstElementChild-namespace-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-firstElementChild-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-lastElementChild-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-nextElementSibling-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-previousElementSibling-svg.svg [ Skip ] +imported/wpt/dom/nodes/Element-siblingElement-null-svg.svg [ Skip ] imported/web-platform-tests/html/editing/the-hidden-attribute/hidden-2.svg [ Skip ] # https://github.com/w3c/web-platform-tests/issues/1861: A function can be @@ -617,13 +617,13 @@ imported/web-platform-tests/mediacapture-streams/obtaining-local-multimedia-content/navigatorusermedia/deny.html [ Skip ] # Requires http server. -imported/web-platform-tests/dom/nodes/Document-URL.sub.html [ Skip ] -imported/web-platform-tests/dom/nodes/Document-characterSet-normalization.html [ Skip ] -imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_mimeheader_01.html [ Skip ] -imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_mimeheader_02.html [ Skip ] -imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_xml.html [ Skip ] -imported/web-platform-tests/dom/nodes/Document-contentType/contentType/xhr_responseType_document.html [ Skip ] -imported/web-platform-tests/dom/nodes/Element-matches.html [ Skip ] +imported/wpt/dom/nodes/Document-URL.sub.html [ Skip ] +imported/wpt/dom/nodes/Document-characterSet-normalization.html [ Skip ] +imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_mimeheader_01.html [ Skip ] +imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_mimeheader_02.html [ Skip ] +imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_xml.html [ Skip ] +imported/wpt/dom/nodes/Document-contentType/contentType/xhr_responseType_document.html [ Skip ] +imported/wpt/dom/nodes/Element-matches.html [ Skip ] imported/web-platform-tests/html/browsers/history/the-history-interface/008.html [ Skip ] imported/web-platform-tests/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html [ Skip ] imported/web-platform-tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html [ Skip ] @@ -644,9 +644,9 @@ imported/web-platform-tests/mediacapture-streams/obtaining-local-multimedia-content/navigatorusermedia/empty-option-param.html # Uses custom request handler -imported/web-platform-tests/encoding/single-byte-decoder.html [ Skip ] -imported/web-platform-tests/encoding/resources/single-byte-raw.py [ Skip ] -imported/web-platform-tests/encoding/resources/text-plain-charset.py [ Skip ] +imported/wpt/encoding/single-byte-decoder.html [ Skip ] +imported/wpt/encoding/resources/single-byte-raw.py [ Skip ] +imported/wpt/encoding/resources/text-plain-charset.py [ Skip ] imported/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-moved.html [ Skip ] imported/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-addEventListener.html [ Skip ] imported/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-candidate-remove-no-listener.html [ Skip ] @@ -664,7 +664,7 @@ imported/web-platform-tests/pointerevents/pointerevent_pointermove-on-chorded-mouse-button.html [ Skip ] # Uses TAB character for indentation -imported/web-platform-tests/touch-events/multi-touch-interactions.js [ Skip ] +imported/wpt/touch-events/multi-touch-interactions.js [ Skip ] # CSS Writing Modes Level 3: Following tests require writing-mode: sideways-*, which we do not plan to support today. imported/csswg-test/css-writing-modes-3/block-flow-direction-slr-043.xht [ Skip ] @@ -773,7 +773,7 @@ imported/web-platform-tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support [ Skip ] # crbug.com/441355: MutationObserver incorrect for replaceChild (causes timeout) -imported/web-platform-tests/dom/nodes/MutationObserver-childList.html [ Skip ] +imported/wpt/dom/nodes/MutationObserver-childList.html [ Skip ] # crbug.com/574461: update-w3c-deps imports .py file with x-bit cleared -imported/web-platform-tests/dom/nodes/Document-createElement-namespace-tests/generate.py [ Skip ] +imported/wpt/dom/nodes/Document-createElement-namespace-tests/generate.py [ Skip ]
diff --git a/third_party/WebKit/LayoutTests/WPTServeExpectations b/third_party/WebKit/LayoutTests/WPTServeExpectations index 8edbb34f..c33c47b 100644 --- a/third_party/WebKit/LayoutTests/WPTServeExpectations +++ b/third_party/WebKit/LayoutTests/WPTServeExpectations
@@ -32,7 +32,7 @@ crbug.com/508728 imported/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-cross-origin.html [ Failure ] crbug.com/508728 imported/web-platform-tests/html/webappapis/scripting/processing-model-2/runtime-error-cross-origin.html [ Failure ] crbug.com/508728 imported/web-platform-tests/html/webappapis/scripting/processing-model-2/runtime-error-data-url.html [ Failure ] -crbug.com/508728 imported/web-platform-tests/webstorage/document-domain.html [ Failure ] +crbug.com/508728 imported/wpt/webstorage/document-domain.html [ Failure ] # Pass when run with --enable-wptserve ([Failure] since expectations do not match): (crbug.com/508725) crbug.com/508725 imported/web-platform-tests/html/browsers/history/the-history-interface/history_pushstate_err.html [ Failure ] @@ -46,7 +46,7 @@ crbug.com/608457 imported/web-platform-tests/mediacapture-streams/MediaDevices-getUserMedia.html [ Failure ] crbug.com/608457 imported/web-platform-tests/mediacapture-streams/MediaStream-gettrackid.html [ Failure ] crbug.com/608457 imported/web-platform-tests/mediacapture-streams/MediaStreamTrack-id.html [ Failure ] -crbug.com/608457 imported/web-platform-tests/webrtc/simplecall.html [ Failure ] +crbug.com/608457 imported/wpt/webrtc/simplecall.html [ Failure ] # These tests time out because they are async tests that use getUserMedia(). crbug.com/608457 imported/web-platform-tests/mediacapture-streams/MediaStream-video-only.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/accessibility/multiselect-list-reports-active-option.html b/third_party/WebKit/LayoutTests/accessibility/multiselect-list-reports-active-option.html index 8d2f5ab8..68f497c 100644 --- a/third_party/WebKit/LayoutTests/accessibility/multiselect-list-reports-active-option.html +++ b/third_party/WebKit/LayoutTests/accessibility/multiselect-list-reports-active-option.html
@@ -29,9 +29,7 @@ shouldBe("accessibleThree.isSelectedOptionActive", "false"); // Change the selected index by simulating a down arrow keydown event. - var event = document.createEvent('KeyboardEvents'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, 'Down', 0, false, false, false, false, false); - menulist.dispatchEvent(event); + eventSender.keyDown('downArrow', []); shouldBe("accessibleOne.isSelected", "false"); shouldBe("accessibleOne.isSelectedOptionActive", "false"); @@ -41,9 +39,7 @@ shouldBe("accessibleThree.isSelectedOptionActive", "false"); // Extend the selection by simulating a Shift + Down Arrow keydown event. - var event = document.createEvent('KeyboardEvents'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, 'Down', 0, false, false, true, false, false); - menulist.dispatchEvent(event); + eventSender.keyDown('downArrow', ['shiftKey']); shouldBe("accessibleOne.isSelected", "false"); shouldBe("accessibleOne.isSelectedOptionActive", "false");
diff --git a/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/break-out-of-empty-list-item.js b/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/break-out-of-empty-list-item.js index 60801ca..c61c1f9 100644 --- a/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/break-out-of-empty-list-item.js +++ b/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/break-out-of-empty-list-item.js
@@ -6,16 +6,7 @@ function pressKey(key) { - if (window.KeyEvent) { - var ev = document.createEvent("KeyboardEvent"); - ev.initKeyEvent("keypress", true, true, window, 0,0,0,0, 0, key.charCodeAt(0)); - document.body.dispatchEvent(ev); - } - else { - var ev = document.createEvent("TextEvent"); - ev.initTextEvent('textInput', true, true, null, key.charAt(0)); - document.body.dispatchEvent(ev); - } + eventSender.keyDown(key); } function enterAtTarget(initialContent)
diff --git a/third_party/WebKit/LayoutTests/editing/style/highlight-insert-paragraph.html b/third_party/WebKit/LayoutTests/editing/style/highlight-insert-paragraph.html index e9c0ca0..b881d3e8 100644 --- a/third_party/WebKit/LayoutTests/editing/style/highlight-insert-paragraph.html +++ b/third_party/WebKit/LayoutTests/editing/style/highlight-insert-paragraph.html
@@ -11,16 +11,7 @@ <script type="text/javascript"> function pressKey( key ) { - if (window.KeyEvent) { - var ev = document.createEvent("KeyboardEvent"); - ev.initKeyEvent("keypress", true, true, window, 0,0,0,0, 0, key.charCodeAt(0)); - document.body.dispatchEvent(ev); - } - else { - var ev = document.createEvent("TextEvent"); - ev.initTextEvent('textInput', true, true, null, key.charAt(0)); - document.body.dispatchEvent(ev); - } + eventSender.keyDown(key, []); } if (window.testRunner)
diff --git a/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border-expected.txt b/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border-expected.txt index 4dbef1b..4fa6769 100644 --- a/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border-expected.txt
@@ -4,15 +4,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -PASS div1.style.getPropertyValue("border") is '5px solid green' -PASS div2.style.getPropertyValue("border") is '5px solid' -PASS div3.style.getPropertyValue("border") is '5px green' - NOTE: '5px green' is an illegal CSS value for 'border'. -PASS div4.style.getPropertyValue("border") is 'solid green' -PASS div5.style.getPropertyValue("border") is 'green' - NOTE: 'green' is an illegal CSS value for 'border'. -PASS div6.style.getPropertyValue("border") is '5px' -PASS div7.style.getPropertyValue("border") is 'solid' +PASS div1.style.getPropertyValue("border") is "5px solid green" +PASS div2.style.getPropertyValue("border") is "" +PASS div3.style.getPropertyValue("border") is "" +PASS div4.style.getPropertyValue("border") is "" +PASS div5.style.getPropertyValue("border") is "" +PASS div6.style.getPropertyValue("border") is "" +PASS div7.style.getPropertyValue("border") is "" PASS div8.style.getPropertyValue("border") is "" PASS div9.style.getPropertyValue("border") is "" PASS successfullyParsed is true
diff --git a/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border.html b/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border.html index d8751e6..11fef2a 100644 --- a/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border.html +++ b/third_party/WebKit/LayoutTests/fast/css/getPropertyValue-border.html
@@ -33,27 +33,25 @@ description("<a href=\"https://bugs.webkit.org/show_bug.cgi?id=15823\">Bug 15823: getPropertyValue for border returns null, should compute the shorthand value</a>"); var div1 = document.getElementById("border1"); - shouldBe('div1.style.getPropertyValue("border")', "'5px solid green'"); + shouldBeEqualToString('div1.style.getPropertyValue("border")', "5px solid green"); var div2 = document.getElementById("border2"); - shouldBe('div2.style.getPropertyValue("border")', "'5px solid'"); + shouldBeEqualToString('div2.style.getPropertyValue("border")', ""); var div3 = document.getElementById("border3"); - shouldBe('div3.style.getPropertyValue("border")', "'5px green'"); - debug(" NOTE: '5px green' is an illegal CSS value for 'border'."); + shouldBeEqualToString('div3.style.getPropertyValue("border")', ""); var div4 = document.getElementById("border4"); - shouldBe('div4.style.getPropertyValue("border")', "'solid green'"); + shouldBeEqualToString('div4.style.getPropertyValue("border")', ""); var div5 = document.getElementById("border5"); - shouldBe('div5.style.getPropertyValue("border")', "'green'"); - debug(" NOTE: 'green' is an illegal CSS value for 'border'."); + shouldBeEqualToString('div5.style.getPropertyValue("border")', ""); var div6 = document.getElementById("border6"); - shouldBe('div6.style.getPropertyValue("border")', "'5px'"); + shouldBeEqualToString('div6.style.getPropertyValue("border")', ""); var div7 = document.getElementById("border7"); - shouldBe('div7.style.getPropertyValue("border")', "'solid'"); + shouldBeEqualToString('div7.style.getPropertyValue("border")', ""); var div8 = document.getElementById("border8"); shouldBeEqualToString('div8.style.getPropertyValue("border")', "");
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLLabelElement/click-label.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLLabelElement/click-label.html index 868f696..64235b32 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLLabelElement/click-label.html +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLLabelElement/click-label.html
@@ -4,8 +4,7 @@ var clickcount = 0; function dispatchClickEvent(target) { // Create a click event and dispatch it - var event = document.createEvent('UIEvents'); - event.initUIEvent('click', true, true, window, 1) + var event = new MouseEvent('click'); target.dispatchEvent(event); }
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLMenuItemElement/menuitem-crash-asan.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLMenuItemElement/menuitem-crash-asan.html index b46dab9..a1f4c7b 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLMenuItemElement/menuitem-crash-asan.html +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLMenuItemElement/menuitem-crash-asan.html
@@ -14,8 +14,7 @@ var element = document.getElementById("domfuzz"); e.initEvent("fullscreenerror"); element.dispatchEvent(e); - e = document.createEvent("Event"); - e.initEvent("click"); + e = new MouseEvent("click"); element.dispatchEvent(e); } if (window.testRunner) {
diff --git a/third_party/WebKit/LayoutTests/fast/dom/css-shorthand-common-value.html b/third_party/WebKit/LayoutTests/fast/dom/css-shorthand-common-value.html index 51e82f9..87a39b1 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/css-shorthand-common-value.html +++ b/third_party/WebKit/LayoutTests/fast/dom/css-shorthand-common-value.html
@@ -13,7 +13,7 @@ if (window.testRunner) testRunner.dumpAsText(); var sheet = document.querySelector('style').sheet; - var expected = 'solid red'; + var expected = ''; var actual = sheet.cssRules[0].style.getPropertyValue('border'); if (expected == actual)
diff --git a/third_party/WebKit/LayoutTests/fast/events/tab-crash-with-image-map.html b/third_party/WebKit/LayoutTests/fast/events/tab-crash-with-image-map.html index b646ac5..e2c27e19 100644 --- a/third_party/WebKit/LayoutTests/fast/events/tab-crash-with-image-map.html +++ b/third_party/WebKit/LayoutTests/fast/events/tab-crash-with-image-map.html
@@ -2,14 +2,6 @@ <head> <script> - function dispatchTabPress(element, shiftKey) - { - var event = document.createEvent('KeyboardEvents'); - var tabKeyIdentifier = 'U+0009'; - event.initKeyboardEvent('keydown', true, true, document.defaultView, tabKeyIdentifier, 0, false, true, shiftKey, false, false); - element.dispatchEvent(event); - } - function test() { if (window.testRunner) { @@ -19,7 +11,7 @@ document.getElementById("link1").focus(); for (var i = 0; i < 40; ++i) { - dispatchTabPress(document, false); + eventSender.keyDown('\u0009'); } } </script>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-open-picker-with-f4-key.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-open-picker-with-f4-key.html index be96a1e..de24c2e 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-open-picker-with-f4-key.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-open-picker-with-f4-key.html
@@ -18,11 +18,9 @@ sendKey(document.getElementById('test'), 'F4'); shouldBeNonNull('internals.pagePopupWindow'); -function sendKey(input, keyName, ctrlKey, altKey) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName, 0, ctrlKey, altKey); +function sendKey(input, keyName) { input.focus(); - input.dispatchEvent(event); + eventSender.keyDown(keyName); } </script> </body>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-picker-open-without-focus.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-picker-open-without-focus.html index 34de8b4..b1b5228 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-picker-open-without-focus.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/date-picker-open-without-focus.html
@@ -10,7 +10,7 @@ input.focus(); input.remove(); input.offsetTop; -sendKey(input, "Down", false, true); +eventSender.keyDown("downArrow", ["altKey"]); if (window.internals.pagePopupWindow) { testFailed('Popup was opened.'); finishJSTest();
diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/datetimelocal-open-picker-with-f4-key.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/datetimelocal-open-picker-with-f4-key.html index 11b3737..80988fcd 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/datetimelocal-open-picker-with-f4-key.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/datetimelocal-open-picker-with-f4-key.html
@@ -18,11 +18,9 @@ sendKey(document.getElementById('test'), 'F4'); shouldBeNonNull('internals.pagePopupWindow'); -function sendKey(input, keyName, ctrlKey, altKey) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName, 0, ctrlKey, altKey); +function sendKey(input, keyName) { input.focus(); - input.dispatchEvent(event); + eventSender.keyDown(keyName); } </script> </body>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-open-picker-with-f4-key.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-open-picker-with-f4-key.html index 74954b1..a4b7a36 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-open-picker-with-f4-key.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-open-picker-with-f4-key.html
@@ -18,11 +18,9 @@ sendKey(document.getElementById('test'), 'F4'); shouldBeNonNull('internals.pagePopupWindow'); -function sendKey(input, keyName, ctrlKey, altKey) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName, 0, ctrlKey, altKey); +function sendKey(input, keyName) { input.focus(); - input.dispatchEvent(event); + eventSender.keyDown(keyName); } </script> </body>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/week-open-picker-with-f4-key.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/week-open-picker-with-f4-key.html index 9326b07d..4e5fbb7 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/week-open-picker-with-f4-key.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/week-open-picker-with-f4-key.html
@@ -18,11 +18,9 @@ sendKey(document.getElementById('test'), 'F4'); shouldBeNonNull('internals.pagePopupWindow'); -function sendKey(input, keyName, ctrlKey, altKey) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName, 0, ctrlKey, altKey); +function sendKey(input, keyName) { input.focus(); - input.dispatchEvent(event); + eventSender.keyDown(keyName); } </script> </body>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/focus2.html b/third_party/WebKit/LayoutTests/fast/forms/focus2.html index 93e6733..c9f68d6 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/focus2.html +++ b/third_party/WebKit/LayoutTests/fast/forms/focus2.html
@@ -105,13 +105,13 @@ parentElement.appendChild(anchor); } -function dispatchOptionTab(element, shiftKey) +function dispatchOptionTab(element) { - var event = document.createEvent("KeyboardEvents"); - var tabKeyIdentifier = "U+0009"; var isMac = navigator.platform.indexOf('Mac') == 0; - event.initKeyboardEvent("keydown", true, true, document.defaultView, tabKeyIdentifier, 0, false, isMac, shiftKey, false, false); - element.dispatchEvent(event); + var modifiers = []; + if (isMac) + modifiers = ["altKey"]; + eventSender.keyDown("\u0009", modifiers); } function setup() @@ -129,12 +129,12 @@ log('PARENT DOCUMENT:\n'); document.getElementsByTagName('input')[0].focus(); for (var i = 0; i < 14; ++i) //> - dispatchOptionTab(lastFocusedElement, false); + dispatchOptionTab(lastFocusedElement); lastFocusedElement.blur(); log('\nIFRAME DOCUMENT:\n'); document.getElementById('testIframe').contentDocument.getElementsByTagName('input')[0].focus(); for (var i = 0; i < 14; ++i) //> - dispatchOptionTab(lastFocusedElement, false); + dispatchOptionTab(lastFocusedElement); </script>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/form-associated-element.html b/third_party/WebKit/LayoutTests/fast/forms/form-associated-element.html index 657ee10..a30eeb4 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/form-associated-element.html +++ b/third_party/WebKit/LayoutTests/fast/forms/form-associated-element.html
@@ -70,7 +70,7 @@ for (var i = 0; i < elements.length; ++i) { // <label/> won't handle 'error', use 'click'. var eventType = (elements[i] instanceof HTMLLabelElement) ? "click" : "error"; - elements[i].dispatchEvent(new Event(eventType)); + elements[i].dispatchEvent(new MouseEvent(eventType)); } } testFormAssociation();
diff --git a/third_party/WebKit/LayoutTests/fast/forms/image/input-image-submit.html b/third_party/WebKit/LayoutTests/fast/forms/image/input-image-submit.html index c2db1a8..91dfebff 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/image/input-image-submit.html +++ b/third_party/WebKit/LayoutTests/fast/forms/image/input-image-submit.html
@@ -55,8 +55,6 @@ var y = image.offsetTop + 11; var clickEvent = document.createEvent('MouseEvent'); clickEvent.initMouseEvent('click', true, false, document.defaultView, 1, x, y, x, y, false, false, false, false, 0, document); - var enterEvent = document.createEvent('TextEvent'); - enterEvent.initTextEvent("textInput", true, true, document.defaultView, "\n"); var query = window.location.search; if (query.indexOf('state=') == -1) { @@ -108,7 +106,7 @@ state.value = 'to-image-on-submit'; image.type = 'text'; image.focus(); - image.dispatchEvent(enterEvent); + eventSender.keyDown('\n'); } else if (query.indexOf('state=to-image-on-submit') != -1) { // Should have image.x and image.y, but their values are 0. if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
diff --git a/third_party/WebKit/LayoutTests/fast/forms/number/number-blur-twice.html b/third_party/WebKit/LayoutTests/fast/forms/number/number-blur-twice.html index 2dea4ce..3aec1a0 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/number/number-blur-twice.html +++ b/third_party/WebKit/LayoutTests/fast/forms/number/number-blur-twice.html
@@ -27,9 +27,7 @@ num.focus(); document.execCommand('InsertText', false, '123'); document.execCommand('InsertText', false, 'a'); -var tabEvent = document.createEvent('KeyboardEvent'); -tabEvent.initKeyboardEvent('keydown', true, true, document.defaultView, 'U+0009'); -num.dispatchEvent(tabEvent); +eventSender.keyDown('\u0009'); shouldBe('numOfFocus', '1'); shouldBe('numOfBlur', '1');
diff --git a/third_party/WebKit/LayoutTests/fast/forms/number/number-outofrange.html b/third_party/WebKit/LayoutTests/fast/forms/number/number-outofrange.html index f526be79..4c1bf7d 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/number/number-outofrange.html +++ b/third_party/WebKit/LayoutTests/fast/forms/number/number-outofrange.html
@@ -17,27 +17,25 @@ function sendKeyEvent(element, key) { element.focus(); - var event = document.createEvent('KeyboardEvents'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, key, 0, false, false, false, false, false); - element.dispatchEvent(event); + eventSender.keyDown(key); } debug('Pressing the down arrow key on an input field of which value is lower than the minimum:'); -sendKeyEvent(lower, 'Down'); +sendKeyEvent(lower, 'downArrow'); var unchanged = "-10"; shouldBe('lower.value', 'unchanged'); debug('Pressing the up arrow key on the input:'); -sendKeyEvent(lower, 'Up'); +sendKeyEvent(lower, 'upArrow'); shouldBe('lower.value', 'lower.min'); debug('Pressing the up arrow key on an input field of which value is higher than the maximum:'); -sendKeyEvent(higher, 'Up'); +sendKeyEvent(higher, 'upArrow'); unchanged = "200"; shouldBe('higher.value', 'unchanged'); debug('Pressing the down arrow key on the input:'); -sendKeyEvent(higher, 'Down'); +sendKeyEvent(higher, 'downArrow'); shouldBe('higher.value', 'higher.max'); parent.innerHTML = '';
diff --git a/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt index 41e950da..19d61d85 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt
@@ -1,3 +1,9 @@ +CONSOLE WARNING: The specified value "foo" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)? +CONSOLE WARNING: The specified value "foo" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)? +CONSOLE WARNING: The specified value "foo" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)? +CONSOLE WARNING: The specified value "foo" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)? +CONSOLE WARNING: The specified value "foo" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)? +CONSOLE WARNING: The specified value "foo" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)? Check stepping-up and -down for number input from renderer. On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
diff --git a/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html b/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html index 8fecd96e..b4fc6a1 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html +++ b/third_party/WebKit/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html
@@ -4,16 +4,17 @@ <script src="../../../resources/js-test.js"></script> </head> <body> +<input id="test"></input> <script> description('Check stepping-up and -down for number input from renderer.'); -var input = document.createElement('input'); +var input = document.getElementById('test'); var invalidStateErr = '"InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable."'; +input.focus(); + function sendKey(keyName) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName); - input.dispatchEvent(event); + eventSender.keyDown(keyName); } function setInputAttributes(min, max, step, value) { @@ -28,12 +29,12 @@ if (typeof optionalStepCount != "undefined") if (optionalStepCount < 0) for (var i = 0; i < -optionalStepCount; i++) - sendKey('Down'); + sendKey('downArrow'); else for (var i = 0; i < optionalStepCount; i++) - sendKey('Up'); + sendKey('upArrow'); else - sendKey('Up'); + sendKey('upArrow'); return input.value; } @@ -42,12 +43,12 @@ if (typeof optionalStepCount != "undefined") if (optionalStepCount < 0) for (var i = 0; i < -optionalStepCount; i++) - sendKey('Up'); + sendKey('upArrow'); else for (var i = 0; i < optionalStepCount; i++) - sendKey('Down'); + sendKey('downArrow'); else - sendKey('Down'); + sendKey('downArrow'); return input.value; } @@ -59,13 +60,13 @@ if (typeof stepCount !== 'undefined') if (stepCount < 0) { for (var i = 0; i < -stepCount; i++) - sendKey('Down'); + sendKey('downArrow'); } else { for (var i = 0; i < stepCount; i++) - sendKey('Up'); + sendKey('upArrow'); } else - sendKey('Up'); + sendKey('upArrow'); return input.value; } @@ -74,13 +75,13 @@ if (typeof stepCount !== 'undefined') if (stepCount < 0) { for (var i = 0; i < -stepCount; i++) - sendKey('Up'); + sendKey('upArrow'); } else { for (var i = 0; i < stepCount; i++) - sendKey('Down'); + sendKey('downArrow'); } else - sendKey('Down'); + sendKey('downArrow'); return input.value; }
diff --git a/third_party/WebKit/LayoutTests/fast/forms/number/number-type-update-by-change-event.html b/third_party/WebKit/LayoutTests/fast/forms/number/number-type-update-by-change-event.html index db6a233c..cfdf22f 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/number/number-type-update-by-change-event.html +++ b/third_party/WebKit/LayoutTests/fast/forms/number/number-type-update-by-change-event.html
@@ -5,9 +5,7 @@ <input type="number" onchange="handleChange(this);"> <script> function sendKey(keyName) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName); - document.activeElement.dispatchEvent(event); + eventSender.keyDown(keyName); } function handleChange(element) { @@ -18,7 +16,7 @@ var changeEventCounter = 0; var numberInput = document.getElementsByTagName('input')[0]; numberInput.focus(); -sendKey('Up'); +sendKey('upArrow'); testPassed('if not crashed in ASAN build.'); shouldBe('changeEventCounter', '1');
diff --git a/third_party/WebKit/LayoutTests/fast/forms/onchange-change-type.html b/third_party/WebKit/LayoutTests/fast/forms/onchange-change-type.html index e6f8530..4263f00a 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/onchange-change-type.html +++ b/third_party/WebKit/LayoutTests/fast/forms/onchange-change-type.html
@@ -2,10 +2,8 @@ <head> <script src="../../resources/js-test.js"></script> <script> - function sendText(element, text) { - var event = document.createEvent('TextEvent'); - event.initTextEvent('textInput', true, true, document.defaultView, text); - element.dispatchEvent(event); + function sendText(text) { + document.execCommand('insertText', false, text); } function test() { @@ -21,7 +19,7 @@ } tf.focus(); - sendText(tf, 'input value'); + sendText('input value'); tf.blur(); debug('Should fire change event when type does not change.'); @@ -29,7 +27,7 @@ didFireOnChange = false; tf.focus(); - sendText(tf, 'new input value'); + sendText('new input value'); tf.setAttribute('type', 'password'); tf.blur();
diff --git a/third_party/WebKit/LayoutTests/fast/forms/range/range-keyoperation.html b/third_party/WebKit/LayoutTests/fast/forms/range/range-keyoperation.html index fbd560e3..7f9180254e 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/range/range-keyoperation.html +++ b/third_party/WebKit/LayoutTests/fast/forms/range/range-keyoperation.html
@@ -9,9 +9,7 @@ <script> function sendKey(element, keyName) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName); - element.dispatchEvent(event); + eventSender.keyDown(keyName); } var changeEventCounter = 0; @@ -30,67 +28,67 @@ debug('Tests for a horizontal range'); debug('Press the up arrow key:'); var lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"51"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Press the down arrow key:'); -sendKey(input, 'Down'); +sendKey(input, 'downArrow'); shouldBe('input.value', '"50"'); debug('Press the left arrow key:'); -sendKey(input, 'Left'); +sendKey(input, 'leftArrow'); shouldBe('input.value', '"49"'); debug('Press the right arrow key:'); -sendKey(input, 'Right'); +sendKey(input, 'rightArrow'); shouldBe('input.value', '"50"'); debug('Press the PageUp key:'); -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"60"'); debug('Press the PageDown key:'); -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"50"'); debug('Press the Home key:'); -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"0"'); debug('Press the End key:'); -sendKey(input, 'End'); +sendKey(input, 'end'); shouldBe('input.value', '"100"'); debug('Edge cases'); input.valueAsNumber = 0; lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Left'); +sendKey(input, 'leftArrow'); shouldBe('input.value', '"0"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'Right'); +sendKey(input, 'rightArrow'); shouldBe('input.value', '"1"'); input.valueAsNumber = 100; -sendKey(input, 'Right'); +sendKey(input, 'rightArrow'); shouldBe('input.value', '"100"'); -sendKey(input, 'Left'); +sendKey(input, 'leftArrow'); shouldBe('input.value', '"99"'); input.valueAsNumber = 0; lastChangeEventCounter = changeEventCounter; -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"0"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"0"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); input.valueAsNumber = 100; lastChangeEventCounter = changeEventCounter; -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"100"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'End'); +sendKey(input, 'end'); shouldBe('input.value', '"100"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); @@ -99,9 +97,9 @@ input.offsetLeft; debug(''); debug('RTL'); -sendKey(input, 'Left'); +sendKey(input, 'leftArrow'); shouldBeEqualToString('input.value', '51'); -sendKey(input, 'Right'); +sendKey(input, 'rightArrow'); shouldBeEqualToString('input.value', '50'); input.dir = 'ltr'; @@ -112,35 +110,35 @@ input.valueAsNumber = 50; debug('Tests for a vertical range'); debug('Press the up arrow key:'); -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"51"'); debug('Press the down arrow key:'); -sendKey(input, 'Down'); +sendKey(input, 'downArrow'); shouldBe('input.value', '"50"'); debug('Press the left arrow key:'); -sendKey(input, 'Left'); +sendKey(input, 'leftArrow'); shouldBe('input.value', '"51"'); debug('Press the right arrow key:'); -sendKey(input, 'Right'); +sendKey(input, 'rightArrow'); shouldBe('input.value', '"50"'); debug('Press the PageUp key:'); -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"60"'); debug('Press the PageDown key:'); -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"50"'); debug('Press the Home key:'); -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"100"'); debug('Press the End key:'); -sendKey(input, 'End'); +sendKey(input, 'end'); shouldBe('input.value', '"0"'); debug(''); @@ -152,79 +150,79 @@ debug('Press the up arrow key:'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"102"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Press the down arrow key:'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Down'); +sendKey(input, 'downArrow'); shouldBe('input.value', '"100"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Press the pageup key:'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"120"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Press the pagedown key:'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"100"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Press the home key:'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"200"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Press the end key:'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'End'); +sendKey(input, 'end'); shouldBe('input.value', '"0"'); shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); debug('Edge cases'); input.valueAsNumber = 199; -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"200"'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"200"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'Down'); +sendKey(input, 'downArrow'); shouldBe('input.value', '"198"'); input.valueAsNumber = 199; -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"200"'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"200"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"180"'); input.valueAsNumber = 1; -sendKey(input, 'Down'); +sendKey(input, 'downArrow'); shouldBe('input.value', '"0"'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'Down'); +sendKey(input, 'downArrow'); shouldBe('input.value', '"0"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"2"'); input.valueAsNumber = 1; -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"0"'); lastChangeEventCounter = changeEventCounter; -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"0"'); shouldBe('changeEventCounter', 'lastChangeEventCounter'); -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"20"'); debug(''); @@ -234,19 +232,19 @@ input.step = '3'; input.valueAsNumber = 6; -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"9"'); -sendKey(input, 'PageDown'); +sendKey(input, 'pageDown'); shouldBe('input.value', '"6"'); -sendKey(input, 'End'); +sendKey(input, 'end'); shouldBe('input.value', '"0"'); -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"9"'); -sendKey(input, 'End'); +sendKey(input, 'end'); shouldBe('input.value', '"0"'); @@ -258,20 +256,20 @@ input.value = '1'; input.disabled = true; -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"1"'); -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"1"'); -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"1"'); input.removeAttribute('disabled'); input.readOnly = true; -sendKey(input, 'Up'); +sendKey(input, 'upArrow'); shouldBe('input.value', '"1"'); -sendKey(input, 'Home'); +sendKey(input, 'home'); shouldBe('input.value', '"1"'); -sendKey(input, 'PageUp'); +sendKey(input, 'pageUp'); shouldBe('input.value', '"1"'); input.readOnly = false;
diff --git a/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt index afa32da..c651937 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt
@@ -1,3 +1,4 @@ + Check stepping-up and -down for range input from renderer. On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
diff --git a/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer.html b/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer.html index 0e88f4b..78485d9 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer.html +++ b/third_party/WebKit/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer.html
@@ -4,18 +4,19 @@ <script src="../../../resources/js-test.js"></script> </head> <body> +<input id="test"></input> <p id="description"></p> <div id="console"></div> <script> description('Check stepping-up and -down for range input from renderer.'); -var input = document.createElement('input'); +var input = document.getElementById('test'); var invalidStateErr = '"InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable."'; +input.focus(); + function sendKey(keyName) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName); - input.dispatchEvent(event); + eventSender.keyDown(keyName); } function setInputAttributes(min, max, step, value) { @@ -30,12 +31,12 @@ if (typeof optionalStepCount != "undefined") if (optionalStepCount < 0) for (var i = 0; i < -optionalStepCount; i++) - sendKey('Down'); + sendKey('downArrow'); else for (var i = 0; i < optionalStepCount; i++) - sendKey('Up'); + sendKey('upArrow'); else - sendKey('Up'); + sendKey('upArrow'); return input.value; } @@ -44,12 +45,12 @@ if (typeof optionalStepCount != "undefined") if (optionalStepCount < 0) for (var i = 0; i < -optionalStepCount; i++) - sendKey('Up'); + sendKey('upArrow'); else for (var i = 0; i < optionalStepCount; i++) - sendKey('Down'); + sendKey('downArrow'); else - sendKey('Down'); + sendKey('downArrow'); return input.value; } @@ -61,13 +62,13 @@ if (typeof stepCount !== 'undefined') if (stepCount < 0) { for (var i = 0; i < -stepCount; i++) - sendKey('Down'); + sendKey('downArrow'); } else { for (var i = 0; i < stepCount; i++) - sendKey('Up'); + sendKey('upArrow'); } else - sendKey('Up'); + sendKey('upArrow'); return input.value; } @@ -76,13 +77,13 @@ if (typeof stepCount !== 'undefined') if (stepCount < 0) { for (var i = 0; i < -stepCount; i++) - sendKey('Up'); + sendKey('upArrow'); } else { for (var i = 0; i < stepCount; i++) - sendKey('Down'); + sendKey('downArrow'); } else - sendKey('Down'); + sendKey('downArrow'); return input.value; }
diff --git a/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js b/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js index ec9d32c..8e952e6 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js +++ b/third_party/WebKit/LayoutTests/fast/forms/resources/common-wheel-event.js
@@ -1,8 +1,8 @@ function dispatchWheelEvent(element, deltaX, deltaY) { - var eventInit = { deltaX: -deltaX, deltaY: -deltaY }; - var event = new WheelEvent('mousewheel', eventInit); - element.dispatchEvent(event); + var rect = element.getClientRects()[0] + eventSender.mouseMoveTo(rect.left, rect.top); + eventSender.mouseScrollBy(deltaX, deltaY); } var input;
diff --git a/third_party/WebKit/LayoutTests/fast/forms/resources/picker-common.js b/third_party/WebKit/LayoutTests/fast/forms/resources/picker-common.js index d971330..8610f78 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/resources/picker-common.js +++ b/third_party/WebKit/LayoutTests/fast/forms/resources/picker-common.js
@@ -15,12 +15,6 @@ setTimeout(callback, 1); } -function sendKey(input, keyName, ctrlKey, altKey) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName, 0, ctrlKey, altKey); - input.dispatchEvent(event); -} - function rootWindow() { var currentWindow = window; while (currentWindow !== currentWindow.parent) { @@ -44,13 +38,12 @@ element.offsetTop; // Force to lay out element.focus(); if (element.tagName === "SELECT") { - sendKey(element, "Down", false, true); + eventSender.keyDown("downArrow", ["altKey"]); } else if (element.tagName === "INPUT") { if (element.type === "color") { - element.focus(); eventSender.keyDown(" "); } else { - sendKey(element, "Down", false, true); + eventSender.keyDown("downArrow", ["altKey"]); } } popupWindow = window.internals.pagePopupWindow;
diff --git a/third_party/WebKit/LayoutTests/fast/forms/select/menulist-no-renderer-onmousedown.html b/third_party/WebKit/LayoutTests/fast/forms/select/menulist-no-renderer-onmousedown.html index f8e60b63..7d15e44 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/select/menulist-no-renderer-onmousedown.html +++ b/third_party/WebKit/LayoutTests/fast/forms/select/menulist-no-renderer-onmousedown.html
@@ -6,9 +6,8 @@ if (window.testRunner) testRunner.dumpAsText(); var sl = document.getElementById('sl'); - var event = document.createEvent("MouseEvent"); - event.initMouseEvent("mousedown", true, true, window, 1, sl.offsetLeft, sl.offsetTop, sl.offsetLeft, sl.offsetTop, false, false, false, false, 0, document); - sl.dispatchEvent(event); + eventSender.mouseMoveTo(sl.offsetLeft, sl.offsetTop); + eventSender.mouseDown(1); } </script> </head>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/select/menulist-popup-crash.html b/third_party/WebKit/LayoutTests/fast/forms/select/menulist-popup-crash.html index 1ca0d9fa..2fbec0fe 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/select/menulist-popup-crash.html +++ b/third_party/WebKit/LayoutTests/fast/forms/select/menulist-popup-crash.html
@@ -40,9 +40,8 @@ function mouseDownOnSelect(selId) { var sl = document.getElementById(selId); - var event = document.createEvent("MouseEvent"); - event.initMouseEvent("mousedown", true, true, document.defaultView, 1, sl.offsetLeft, sl.offsetTop, sl.offsetLeft, sl.offsetTop, false, false, false, false, 0, document); - sl.dispatchEvent(event); + eventSender.mouseMoveTo(sl.offsetLeft, sl.offsetTop); + eventSender.mouseDown(1); } mouseDownOnSelect("sl1");
diff --git a/third_party/WebKit/LayoutTests/fast/forms/select/select-change-popup-to-listbox-in-event-handler.html b/third_party/WebKit/LayoutTests/fast/forms/select/select-change-popup-to-listbox-in-event-handler.html index a2722b3..5ad687a 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/select/select-change-popup-to-listbox-in-event-handler.html +++ b/third_party/WebKit/LayoutTests/fast/forms/select/select-change-popup-to-listbox-in-event-handler.html
@@ -9,13 +9,9 @@ function sendClick() { var select = document.getElementById("select"); - var rect = select.getBoundingClientRect(); - var evt = document.createEvent("MouseEvents"); - evt.initMouseEvent("mousedown", true, true, window, - 0, 0, 0, rect.top + 4, rect.left + 4, false, false, false, false, 0, null); - - select.dispatchEvent(evt); + eventSender.mouseMoveTo(select.offsetLeft + 4, select.offsetTop + 4); + eventSender.mouseDown(1); } window.addEventListener('load', sendClick, false);
diff --git a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html index 5229b6b5..4faf5a6 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html
@@ -181,7 +181,7 @@ shouldBeNull('document.getElementById("mock-page-popup")'); shouldBeEqualToString('document.getElementById("date").value', '2012-03-08'); - sendKey(document.getElementById('date'), "F4"); + eventSender.keyDown('F4'); if (document.getElementById('mock-page-popup')) testPassed("F4 opened picker.");
diff --git a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-key-operations.html index ace393a..242ccd6d 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-key-operations.html
@@ -153,7 +153,7 @@ shouldBeNull('document.getElementById("mock-page-popup")'); shouldBeEqualToString('document.getElementById("datetime-local").value', '2012-11-22T02:07'); - sendKey(document.getElementById('datetime-local'), 'F4'); + eventSender.keyDown('F4'); if (document.getElementById('mock-page-popup')) testPassed('F4 opened picker.');
diff --git a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/month-suggestion-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/month-suggestion-picker-key-operations.html index 89c7b779..a9e8aeb8 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/month-suggestion-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/month-suggestion-picker-key-operations.html
@@ -174,7 +174,7 @@ shouldBeNull('document.getElementById("mock-page-popup")'); shouldBeEqualToString('document.getElementById("month").value', '2016-12'); - sendKey(document.getElementById('month'), "F4"); + eventSender.keyDown('F4'); if (document.getElementById('mock-page-popup')) testPassed("F4 opened picker.");
diff --git a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html index a6fcf9b..1b43100 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html
@@ -154,7 +154,7 @@ shouldBeNull('document.getElementById("mock-page-popup")'); shouldBeEqualToString('document.getElementById("time").value', '02:07'); - sendKey(document.getElementById('time'), "F4"); + eventSender.keyDown('F4'); if (document.getElementById('mock-page-popup')) testPassed("F4 opened picker.");
diff --git a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/week-suggestion-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/week-suggestion-picker-key-operations.html index 6898d31..ef25490 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/week-suggestion-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/suggestion-picker/week-suggestion-picker-key-operations.html
@@ -184,7 +184,7 @@ shouldBeNull('document.getElementById("mock-page-popup")'); shouldBeEqualToString('document.getElementById("week").value', '2013-W18'); - sendKey(document.getElementById('week'), 'F4'); + eventSender.keyDown('F4'); if (document.getElementById('mock-page-popup')) testPassed('F4 opened picker.');
diff --git a/third_party/WebKit/LayoutTests/fast/forms/tabs-with-modifiers.html b/third_party/WebKit/LayoutTests/fast/forms/tabs-with-modifiers.html index f271aff2..347f833 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/tabs-with-modifiers.html +++ b/third_party/WebKit/LayoutTests/fast/forms/tabs-with-modifiers.html
@@ -60,10 +60,15 @@ function dispatchTab(element, shiftKey, metaKey, ctrlKey) { - var event = document.createEvent("KeyboardEvents"); - var tabKeyIdentifier = "U+0009"; - event.initKeyboardEvent("keydown", true, true, document.defaultView, tabKeyIdentifier, 0, ctrlKey, false, shiftKey, metaKey); - element.dispatchEvent(event); + var modifiers = []; + if (shiftKey) + modifiers.push("shiftKey"); + if (metaKey) + modifiers.push("metaKey"); + if (ctrlKey) + modifiers.push("ctrlKey"); + + eventSender.keyDown('\u0009', modifiers); } function setup()
diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus.html b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus.html index 0623985..afa0c01 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus.html +++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus.html
@@ -3,12 +3,6 @@ <script src="../../../resources/js-test.js"></script> <input id="timeInput" type="time" value="01:01" style="font-size:20px"> <script> -function dispatchKeyEventTo(type, key, target) { - var event = document.createEvent('KeyboardEvent'); - event.initKeyboardEvent(type, true, true, document.defaultView, key); - target.dispatchEvent(event); -} - function shadowPseudoIdOfFocused() { return internals.shadowPseudoId(internals.youngestShadowRoot(timeInput).activeElement); } @@ -19,7 +13,7 @@ var timeInput = document.getElementById('timeInput'); timeInput.focus(); shouldBe('document.activeElement', 'timeInput'); -dispatchKeyEventTo('keydown', 'Right', timeInput); +eventSender.keyDown('rightArrow'); shouldBeEqualToString('shadowPseudoIdOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); shouldBeEqualToString('timeInput.focus(); shadowPseudoIdOfFocused(timeInput)', '-webkit-datetime-edit-minute-field');
diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-open-picker-key-bindings.html b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-open-picker-key-bindings.html index 533ef463..ae2b9e29 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-open-picker-key-bindings.html +++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-open-picker-key-bindings.html
@@ -14,9 +14,9 @@ description('F4 or Alt+Down should not open the calendar picker.'); var input = document.getElementById('time'); -sendKey(input, 'F4', false, false); +eventSender.keyDown('F4'); shouldBeNull('document.getElementById("mock-page-popup")'); -sendKey(input, 'Down', false, true); +eventSender.keyDown('F4', ['altKey']); shouldBeNull('document.getElementById("mock-page-popup")'); finishJSTest();
diff --git a/third_party/WebKit/LayoutTests/fast/frames/focus-controller-crash-change-event.html b/third_party/WebKit/LayoutTests/fast/frames/focus-controller-crash-change-event.html index 24fcc0b7..7ca2b857 100644 --- a/third_party/WebKit/LayoutTests/fast/frames/focus-controller-crash-change-event.html +++ b/third_party/WebKit/LayoutTests/fast/frames/focus-controller-crash-change-event.html
@@ -18,9 +18,7 @@ }); a.addEventListener("keyup", function() { - var e = document.createEvent("KeyboardEvent"); - e.initKeyboardEvent('keydown', true, true, document.defaultView, 'U+0009', 0, false, false, false, false, false); - a.dispatchEvent(e); + eventSender.keyDown('\u0009'); }) document.body.offsetTop;
diff --git a/third_party/WebKit/LayoutTests/fast/html/empty-fragment-id-goto-top.html b/third_party/WebKit/LayoutTests/fast/html/empty-fragment-id-goto-top.html index fbb7d7b..23b90f71 100644 --- a/third_party/WebKit/LayoutTests/fast/html/empty-fragment-id-goto-top.html +++ b/third_party/WebKit/LayoutTests/fast/html/empty-fragment-id-goto-top.html
@@ -7,9 +7,7 @@ window.scrollTo(0, 1000); - var clickEvent = document.createEvent("HTMLEvents"); - clickEvent.initEvent("click", "true", "true"); - + var clickEvent = new MouseEvent('click'); var gotoTop = document.getElementById("gotoTop"); gotoTop.dispatchEvent(clickEvent);
diff --git a/third_party/WebKit/LayoutTests/fast/html/tab-order.html b/third_party/WebKit/LayoutTests/fast/html/tab-order.html index fda62c00..d828158 100644 --- a/third_party/WebKit/LayoutTests/fast/html/tab-order.html +++ b/third_party/WebKit/LayoutTests/fast/html/tab-order.html
@@ -15,12 +15,9 @@ } } - function dispatchTabPress(element, shiftKey) + function dispatchTabPress(element, modifiers) { - var event = document.createEvent('KeyboardEvents'); - var tabKeyIdentifier = 'U+0009'; - event.initKeyboardEvent('keydown', true, true, document.defaultView, tabKeyIdentifier, 0, false, false, shiftKey, false, false); - element.dispatchEvent(event); + eventSender.keyDown('\u0009', modifiers); } var lastFocusedElement = null; @@ -54,7 +51,7 @@ log('Tabbing forward....\n'); for (var i = 0; i < inputs.length; ++i) { if (inputs[i].tabIndex >= 0) - dispatchTabPress(document, false); + dispatchTabPress(document, []); } lastFocusedElement.blur(); @@ -62,7 +59,7 @@ log('\nTabbing backward....\n'); for (var i = 0; i < inputs.length; ++i) { if (inputs[i].tabIndex >= 0) - dispatchTabPress(document, true); + dispatchTabPress(document, ['shiftKey']); } log('\nTest finished\n');
diff --git a/third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto-expected.html b/third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto-expected.html new file mode 100644 index 0000000..90dbea2 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto-expected.html
@@ -0,0 +1,8 @@ +<!DOCTYPE html> +<style> +div { + border: thin solid black; + width: 5ch; +} +</style> +<div lang="en-us">a hy-<br>phen-<br>ation<br>test</div>
diff --git a/third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto.html b/third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto.html new file mode 100644 index 0000000..b9f4216e --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto.html
@@ -0,0 +1,10 @@ +<!DOCTYPE html> +<style> +div { + border: thin solid black; + -webkit-hyphens: auto; + hyphens: auto; + width: 5ch; +} +</style> +<div lang="en-us">a hyphenation test</div>
diff --git a/third_party/WebKit/LayoutTests/fast/text/letter-spacing-crash-expected.html b/third_party/WebKit/LayoutTests/fast/text/letter-spacing-crash-expected.html new file mode 100644 index 0000000..f31097e --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/text/letter-spacing-crash-expected.html
@@ -0,0 +1,8 @@ +<!DOCTYPE html> +<style> +* { writing-mode: vertical-lr; letter-spacing: 170141183460469231731687303715884105727mm; } +</style> +<body> +븿z𮧭7䓀?쎹Ry#퓣 另疺࣬ﲷ:F~G 仌Џ㪉# 딷旨 b*uE@T F7 墨򾄋j8,#􏢱 +PASS: did not crash. +</body>
diff --git a/third_party/WebKit/LayoutTests/fast/text/letter-spacing-crash.html b/third_party/WebKit/LayoutTests/fast/text/letter-spacing-crash.html new file mode 100644 index 0000000..f31097e --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/text/letter-spacing-crash.html
@@ -0,0 +1,8 @@ +<!DOCTYPE html> +<style> +* { writing-mode: vertical-lr; letter-spacing: 170141183460469231731687303715884105727mm; } +</style> +<body> +븿z𮧭7䓀?쎹Ry#퓣 另疺࣬ﲷ:F~G 仌Џ㪉# 딷旨 b*uE@T F7 墨򾄋j8,#􏢱 +PASS: did not crash. +</body>
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-constants.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/DOMException-constants.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-constants.html rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/DOMException-constants.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object.html rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object.js b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object.js rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object.worker.js b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object.worker.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/constructor-object.worker.js rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/constructor-object.worker.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/exceptions-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/exceptions-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/exceptions.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions.html rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/es-exceptions/exceptions.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/has-instance.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/has-instance.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/has-instance.html rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/has-instance.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/interface-object.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/interface-object.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/WebIDL/ecmascript-binding/interface-object.html rename to third_party/WebKit/LayoutTests/imported/wpt/WebIDL/ecmascript-binding/interface-object.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-as-proto-length-get-throws.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-as-proto-length-get-throws.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-as-proto-length-get-throws.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-as-proto-length-get-throws.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-empty-name.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-empty-name.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-empty-name.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-empty-name.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-supported-property-indices.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-supported-property-indices.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-supported-property-indices.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-supported-property-indices.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-supported-property-names.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-supported-property-names.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/HTMLCollection-supported-property-names.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/HTMLCollection-supported-property-names.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/domstringmap-supported-property-names.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/domstringmap-supported-property-names.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/domstringmap-supported-property-names.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/domstringmap-supported-property-names.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/namednodemap-supported-property-names-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/namednodemap-supported-property-names-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/namednodemap-supported-property-names-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/namednodemap-supported-property-names-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/namednodemap-supported-property-names.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/collections/namednodemap-supported-property-names.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/collections/namednodemap-supported-property-names.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/collections/namednodemap-supported-property-names.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/common.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/common.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/common.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/common.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/constants.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/constants.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/constants.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/constants.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-constants.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-constants.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-constants.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-constants.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-constructors.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-constructors.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-constructors.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-constructors.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-defaultPrevented-after-dispatch.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-defaultPrevented-after-dispatch.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-defaultPrevented.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-defaultPrevented.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-defaultPrevented.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-defaultPrevented.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-bubbles-false-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-bubbles-false-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-bubbles-false.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-bubbles-false.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-bubbles-false.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-bubbles-false.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-handlers-changed.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-handlers-changed.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-handlers-changed.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-handlers-changed.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-omitted-capture.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-omitted-capture.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-omitted-capture.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-omitted-capture.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-propagation-stopped.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-propagation-stopped.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-propagation-stopped.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-propagation-stopped.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-redispatch.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-redispatch.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-redispatch.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-redispatch.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-reenter.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-reenter.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-reenter.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-reenter.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-target-moved.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-target-moved.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-target-moved.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-target-moved.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-target-removed.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-target-removed.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-target-removed.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-target-removed.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-initEvent.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-initEvent.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-initEvent.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-initEvent.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-propagation.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-propagation.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-propagation.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-propagation.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-type-empty.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-type-empty.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-type-empty.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-type-empty.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-type.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-type.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-type.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-type.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/EventTarget-addEventListener.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/EventTarget-addEventListener.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/EventTarget-addEventListener.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/EventTarget-addEventListener.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/EventTarget-dispatchEvent-returnvalue.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/EventTarget-dispatchEvent-returnvalue.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/EventTarget-removeEventListener.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/EventTarget-removeEventListener.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/EventTarget-removeEventListener.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/EventTarget-removeEventListener.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/ProgressEvent.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/events/ProgressEvent.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/ProgressEvent.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/events/ProgressEvent.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/historical-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/historical-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/historical-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/historical-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/historical.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/historical.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/historical.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/historical.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/interface-objects.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/interface-objects.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/interface-objects.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/interface-objects.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/interfaces-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/interfaces-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/interfaces-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/interfaces-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/interfaces.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/interfaces.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/interfaces.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/interfaces.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-coverage-for-attributes-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-coverage-for-attributes-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-coverage-for-attributes-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-coverage-for-attributes-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-coverage-for-attributes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-coverage-for-attributes.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-coverage-for-attributes.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-coverage-for-attributes.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-stringifier.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-stringifier.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-stringifier.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-stringifier.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-value-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-value-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-value-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-value-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-value.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-value.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/lists/DOMTokenList-value.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/lists/DOMTokenList-value.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-appendChild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-appendChild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-appendChild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-appendChild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-appendData.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-appendData.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-appendData.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-appendData.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-data.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-data.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-data.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-data.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-deleteData.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-deleteData.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-deleteData.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-deleteData.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-insertData.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-insertData.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-insertData.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-insertData.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-remove.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-remove.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-remove.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-remove.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-replaceData.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-replaceData.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-replaceData.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-replaceData.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-substringData.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-substringData.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-substringData.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-substringData.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-surrogates.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-surrogates.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-surrogates.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/CharacterData-surrogates.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-after.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-after.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-after.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-after.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-before.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-before.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-before.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-before.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-remove.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-remove.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-remove.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-remove.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-replaceWith.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-replaceWith.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-replaceWith.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ChildNode-replaceWith.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Comment-Text-constructor.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Comment-Text-constructor.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Comment-Text-constructor.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Comment-Text-constructor.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Comment-constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Comment-constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Comment-constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Comment-constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createDocument-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createDocument-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocument.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createDocument.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocument.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createDocument.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocumentType.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createDocumentType.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocumentType.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createDocumentType.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createHTMLDocument.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createHTMLDocument.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createHTMLDocument.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-createHTMLDocument.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-hasFeature.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-hasFeature.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-hasFeature.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DOMImplementation-hasFeature.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-Element-getElementsByTagName.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-Element-getElementsByTagName.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-Element-getElementsByTagName.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-Element-getElementsByTagName.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-Element-getElementsByTagNameNS.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-Element-getElementsByTagNameNS.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-Element-getElementsByTagNameNS.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-Element-getElementsByTagNameNS.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-adoptNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-adoptNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-adoptNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-adoptNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-constructor-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-constructor-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-constructor-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-constructor-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_bmp.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_bmp.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_bmp.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_bmp.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_css.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_css.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_css.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_css.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_datauri_01.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_datauri_01.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_datauri_01.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_datauri_01.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_datauri_02.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_datauri_02.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_datauri_02.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_datauri_02.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_gif.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_gif.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_gif.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_gif.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_html.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_html.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_html.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_html.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_javascripturi-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_javascripturi-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_javascripturi-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_javascripturi-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_javascripturi.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_javascripturi.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_javascripturi.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_javascripturi.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_jpg.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_jpg.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_jpg.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_jpg.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_png.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_png.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_png.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_png.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_txt.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_txt.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/contenttype_txt.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/contenttype_txt.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/createDocument.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/createDocument.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/createDocument.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/createDocument.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/createHTMLDocument.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/createHTMLDocument.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/contentType/createHTMLDocument.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/contentType/createHTMLDocument.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/blob.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/blob.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/blob.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/blob.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/blob.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/blob.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/blob.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/blob.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/blob.xml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/blob.xml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/blob.xml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/blob.xml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/lib.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/lib.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/lib.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/lib.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/style.css b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/style.css similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/style.css rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/style.css
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.bmp b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.bmp similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.bmp rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.bmp Binary files differ
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.gif b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.gif similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.gif rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.gif Binary files differ
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.jpg b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.jpg similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.jpg rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.jpg Binary files differ
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.png b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.png similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/resources/t.png rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/resources/t.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/support/contenttype_setter.py b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/support/contenttype_setter.py similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-contentType/support/contenttype_setter.py rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-contentType/support/contenttype_setter.py
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createAttribute-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createAttribute-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createAttribute-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createAttribute-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createAttribute.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createAttribute.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createAttribute.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createAttribute.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createComment-createTextNode.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createComment-createTextNode.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createComment-createTextNode.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createComment-createTextNode.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createComment.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createComment.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createComment.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createComment.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElement-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElement-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElement.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElement.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElement.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElementNS.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElementNS.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElementNS.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElementNS.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElementNS.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElementNS.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createElementNS.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElementNS.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createEvent-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createEvent-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createEvent-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createEvent-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createEvent.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createEvent.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createEvent.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createEvent.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createEvent.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createEvent.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createEvent.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createEvent.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createProcessingInstruction-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createProcessingInstruction.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createProcessingInstruction.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createProcessingInstruction.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createProcessingInstruction.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createProcessingInstruction.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createProcessingInstruction.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createProcessingInstruction.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createProcessingInstruction.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createTextNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createTextNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createTextNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createTextNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createTreeWalker-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createTreeWalker-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createTreeWalker-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createTreeWalker-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createTreeWalker.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createTreeWalker.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-createTreeWalker.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createTreeWalker.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-doctype-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-doctype-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-doctype-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-doctype-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-doctype.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-doctype.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-doctype.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-doctype.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementById.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementById.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementById.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementById.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName-xhtml-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName-xhtml-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName-xhtml-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName-xhtml-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagName.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagName.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagNameNS.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagNameNS.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-getElementsByTagNameNS.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-getElementsByTagNameNS.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-implementation.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-implementation.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-implementation.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-implementation.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-importNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-importNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Document-importNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-importNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DocumentType-literal-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DocumentType-literal-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DocumentType-literal-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DocumentType-literal-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DocumentType-literal.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DocumentType-literal.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DocumentType-literal.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DocumentType-literal.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DocumentType-remove.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DocumentType-remove.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DocumentType-remove.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/DocumentType-remove.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElement-null-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElement-null-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElement-null-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElement-null-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElement-null.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElement-null.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElement-null.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElement-null.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-add-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-add-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-add-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-add-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-add.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-add.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-add.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-add.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-remove-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-remove-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-remove-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-remove-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-remove.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-remove.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-dynamic-remove.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-dynamic-remove.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-nochild-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-nochild-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-nochild-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-nochild-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-nochild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-nochild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-nochild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-nochild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-childElementCount.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-childElementCount.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-children-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-children-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-children.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-children.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-children.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-classlist-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-classlist-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-classlist-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-classlist-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-classlist.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-classlist.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-classlist.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-classlist.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-closest-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-closest-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-closest-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-closest-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-closest.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-closest.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-closest.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-closest.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-entity-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-entity-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-entity-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-entity-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-namespace-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-namespace-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-namespace-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-namespace-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-namespace.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-namespace.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-namespace.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-namespace.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-firstElementChild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-firstElementChild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByClassName.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByClassName.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByClassName.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByClassName.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByTagName-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByTagName-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByTagName.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByTagName.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByTagName.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByTagName.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByTagNameNS.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByTagNameNS.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-getElementsByTagNameNS.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-getElementsByTagNameNS.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-hasAttributes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-hasAttributes.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-hasAttributes.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-hasAttributes.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentElement-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentElement-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentElement-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentElement-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentElement.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentElement.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentElement.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentElement.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentText-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentText-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentText-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentText-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentText.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentText.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-insertAdjacentText.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-insertAdjacentText.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-lastElementChild-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-lastElementChild-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-lastElementChild-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-lastElementChild-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-lastElementChild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-lastElementChild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-lastElementChild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-lastElementChild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-matches.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-matches.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-matches.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-matches.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-nextElementSibling-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-nextElementSibling-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-nextElementSibling-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-nextElementSibling-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-nextElementSibling.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-nextElementSibling.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-nextElementSibling.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-nextElementSibling.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-previousElementSibling-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-previousElementSibling-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-previousElementSibling-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-previousElementSibling-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-previousElementSibling.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-previousElementSibling.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-previousElementSibling.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-previousElementSibling.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-remove.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-remove.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-remove.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-remove.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-removeAttributeNS.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-removeAttributeNS.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-removeAttributeNS.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-removeAttributeNS.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-siblingElement-null-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-siblingElement-null-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-siblingElement-null-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-siblingElement-null-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-siblingElement-null.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-siblingElement-null.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-siblingElement-null.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-siblingElement-null.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-tagName.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-tagName.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Element-tagName.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Element-tagName.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-attributes-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-attributes-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-attributes-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-attributes-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-attributes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-attributes.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-attributes.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-attributes.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-characterData-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-characterData-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-characterData-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-characterData-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-characterData.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-characterData.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-characterData.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-characterData.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-disconnect.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-disconnect.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-disconnect.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-disconnect.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-document-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-document-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-document-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-document-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-document.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-document.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-document.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-document.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-inner-outer-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-inner-outer-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-inner-outer-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-inner-outer-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-inner-outer.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-inner-outer.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-inner-outer.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-inner-outer.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-takeRecords.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-takeRecords.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/MutationObserver-takeRecords.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/MutationObserver-takeRecords.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-appendChild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-appendChild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-appendChild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-appendChild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-baseURI.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-baseURI.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-baseURI.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-baseURI.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-childNodes-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-childNodes-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-childNodes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-childNodes.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-childNodes.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-cloneNode-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-cloneNode-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-cloneNode-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-cloneNode-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-cloneNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-cloneNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-cloneNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-cloneNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-compareDocumentPosition.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-compareDocumentPosition.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-compareDocumentPosition.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-compareDocumentPosition.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-constants.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-constants.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-constants.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-constants.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-contains-xml.xml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-contains-xml.xml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-contains-xml.xml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-contains-xml.xml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-contains.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-contains.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-contains.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-contains.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-insertBefore-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-insertBefore-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-insertBefore-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-insertBefore-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-insertBefore.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-insertBefore.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-insertBefore.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-insertBefore.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-isEqualNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-isEqualNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-isEqualNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-isEqualNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-isSameNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-isSameNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-isSameNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-isSameNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupNamespaceURI-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-lookupNamespaceURI-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupNamespaceURI-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-lookupNamespaceURI-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupNamespaceURI.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-lookupNamespaceURI.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupNamespaceURI.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-lookupNamespaceURI.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupPrefix.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-lookupPrefix.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-lookupPrefix.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-lookupPrefix.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-nodeName-xhtml.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-nodeName-xhtml.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-nodeName-xhtml.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-nodeName-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-nodeName.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-nodeName.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-nodeName.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-nodeName.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-nodeValue.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-nodeValue.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-nodeValue.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-nodeValue.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-normalize.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-normalize.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-normalize.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-normalize.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-parentElement.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-parentElement.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-parentElement.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-parentElement.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-properties-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-properties-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-properties-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-properties-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-properties.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-properties.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-properties.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-properties.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-removeChild-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-removeChild-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-removeChild-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-removeChild-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-removeChild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-removeChild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-removeChild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-removeChild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-replaceChild-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-replaceChild-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-replaceChild-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-replaceChild-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-replaceChild.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-replaceChild.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-replaceChild.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-replaceChild.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-textContent-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-textContent-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-textContent-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-textContent-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-textContent.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-textContent.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-textContent.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-textContent.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ParentNode-append.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ParentNode-append.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ParentNode-append.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ParentNode-append.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ParentNode-prepend.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ParentNode-prepend.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ParentNode-prepend.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ParentNode-prepend.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ProcessingInstruction-literal-1.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ProcessingInstruction-literal-1.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ProcessingInstruction-literal-1.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ProcessingInstruction-literal-1.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ProcessingInstruction-literal-2.xhtml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ProcessingInstruction-literal-2.xhtml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ProcessingInstruction-literal-2.xhtml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ProcessingInstruction-literal-2.xhtml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Text-constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Text-constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Text-constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Text-constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Text-splitText.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Text-splitText.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Text-splitText.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Text-splitText.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/append-on-Document.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/append-on-Document.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/append-on-Document.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/append-on-Document.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/attributes-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/attributes-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/attributes-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/attributes-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/attributes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/attributes.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/attributes.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/attributes.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/attributes.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/attributes.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/attributes.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/attributes.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/case-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/case-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/case-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/case-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/case.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/case.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/case.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/case.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/case.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/case.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/case.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/case.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/creators.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/creators.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/creators.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/creators.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/encoding.py b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/encoding.py similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/encoding.py rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/encoding.py
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-01.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-01.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-01.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-01.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-02.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-02.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-02.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-02.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-03.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-03.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-03.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-03.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-04.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-04.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-04.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-04.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-05.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-05.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-05.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-05.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-06.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-06.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-06.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-06.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-07.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-07.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-07.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-07.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-08.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-08.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-08.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-08.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-09.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-09.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-09.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-09.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-10.xml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-10.xml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-10.xml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-10.xml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-11.xml b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-11.xml similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-11.xml rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-11.xml
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-12.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-12.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-12.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-12.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-13.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-13.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-13.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-13.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-14.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-14.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-14.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-14.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-15.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-15.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-15.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-15.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-16.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-16.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-16.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-16.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-17.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-17.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-17.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-17.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-18.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-18.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-18.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-18.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-19.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-19.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-19.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-19.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-20.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-20.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-20.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-20.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-21.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-21.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-21.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-21.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-22.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-22.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-22.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-22.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-23.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-23.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-23.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-23.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-24.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-24.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-24.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-24.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-25.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-25.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-25.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-25.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-26.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-26.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-26.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-26.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-27.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-27.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-27.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-27.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-28.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-28.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-28.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-28.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-29.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-29.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-29.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-29.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-30.htm b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-30.htm similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/getElementsByClassName-30.htm rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/getElementsByClassName-30.htm
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/insert-adjacent.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/insert-adjacent.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/insert-adjacent.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/insert-adjacent.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/mutationobservers.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/mutationobservers.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/mutationobservers.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/mutationobservers.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/prepend-on-Document.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/prepend-on-Document.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/prepend-on-Document.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/prepend-on-Document.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/productions.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/productions.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/productions.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/productions.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/remove-unscopable.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/remove-unscopable.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/remove-unscopable.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/remove-unscopable.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/rootNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/rootNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/rootNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/rootNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/selectors.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/selectors.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/selectors.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/selectors.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-attributes.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-attributes.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-attributes.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-attributes.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-cloneRange.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-cloneRange.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-cloneRange.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-cloneRange.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-collapse.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-collapse.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-collapse.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-collapse.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-commonAncestorContainer-2.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-commonAncestorContainer-2.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-commonAncestorContainer-2.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-commonAncestorContainer-2.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-commonAncestorContainer.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-commonAncestorContainer.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-commonAncestorContainer.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-commonAncestorContainer.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-comparePoint-2.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-comparePoint-2.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-comparePoint-2.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-comparePoint-2.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-detach.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-detach.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-detach.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-detach.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-intersectsNode-binding.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-intersectsNode-binding.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-intersectsNode-binding.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-intersectsNode-binding.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-intersectsNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-intersectsNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-intersectsNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-intersectsNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-selectNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-selectNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-selectNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-selectNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-stringifier.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-stringifier.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/ranges/Range-stringifier.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/ranges/Range-stringifier.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeFilter-constants.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeFilter-constants.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeFilter-constants.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeFilter-constants.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeIterator-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeIterator-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeIterator-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeIterator-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeIterator-removal.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeIterator-removal.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeIterator-removal.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeIterator-removal.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeIterator.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeIterator.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/NodeIterator.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/NodeIterator.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-acceptNode-filter.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-acceptNode-filter.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-basic.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-basic.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-basic.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-currentNode.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-currentNode.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-currentNode.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-currentNode.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-previousNodeLastChildReject.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-previousNodeLastChildReject.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-traversal-reject.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-traversal-reject.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-traversal-reject.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-traversal-reject.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-traversal-skip-most.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-traversal-skip-most.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-traversal-skip-most.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-traversal-skip-most.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-traversal-skip.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-traversal-skip.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-traversal-skip.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-traversal-skip.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-walking-outside-a-tree.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-walking-outside-a-tree.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker-walking-outside-a-tree.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker-walking-outside-a-tree.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker.html b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/TreeWalker.html rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/TreeWalker.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/traversal-support.js b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/traversal-support.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/traversal-support.js rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/traversal-support.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/unfinished/TODO b/third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/unfinished/TODO similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/traversal/unfinished/TODO rename to third_party/WebKit/LayoutTests/imported/wpt/dom/traversal/unfinished/TODO
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-basics.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/api-basics.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-basics.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/api-basics.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-invalid-label.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/api-invalid-label.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-invalid-label.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/api-invalid-label.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-replacement-encodings.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/api-replacement-encodings.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-replacement-encodings.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/api-replacement-encodings.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-surrogates-utf8.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/api-surrogates-utf8.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/api-surrogates-utf8.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/api-surrogates-utf8.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/big5-encoder.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/big5-encoder.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/big5-encoder.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/big5-encoder.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/gb18030-encoder.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/gb18030-encoder.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/gb18030-encoder.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/gb18030-encoder.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/gbk-encoder.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/gbk-encoder.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/gbk-encoder.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/gbk-encoder.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/idlharness-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/encoding/idlharness-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/idlharness-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/idlharness-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/idlharness.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/idlharness.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/idlharness.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/idlharness.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/iso-2022-jp-decoder-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/encoding/iso-2022-jp-decoder-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/iso-2022-jp-decoder-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/iso-2022-jp-decoder-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/iso-2022-jp-decoder.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/iso-2022-jp-decoder.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/iso-2022-jp-decoder.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/iso-2022-jp-decoder.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/iso-2022-jp-encoder.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/iso-2022-jp-encoder.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/iso-2022-jp-encoder.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/iso-2022-jp-encoder.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/resources/encodings.js b/third_party/WebKit/LayoutTests/imported/wpt/encoding/resources/encodings.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/resources/encodings.js rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/resources/encodings.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-byte-order-marks.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-byte-order-marks.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-byte-order-marks.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-byte-order-marks.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-single-byte-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-single-byte-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-single-byte-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-single-byte-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-single-byte.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-single-byte.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-single-byte.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-single-byte.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-streaming.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-streaming.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-streaming.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal-streaming.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-fatal.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-ignorebom.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-ignorebom.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-ignorebom.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-ignorebom.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-labels-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-labels-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-labels-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-labels-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-labels.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-labels.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-labels.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-labels.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-streaming.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-streaming.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-streaming.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-streaming.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-utf16-surrogates-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-utf16-surrogates-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-utf16-surrogates-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-utf16-surrogates-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-utf16-surrogates.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-utf16-surrogates.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-utf16-surrogates.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textdecoder-utf16-surrogates.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textencoder-constructor-non-utf-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textencoder-constructor-non-utf-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textencoder-constructor-non-utf-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textencoder-constructor-non-utf-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textencoder-constructor-non-utf.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textencoder-constructor-non-utf.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textencoder-constructor-non-utf.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textencoder-constructor-non-utf.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textencoder-utf16-surrogates.html b/third_party/WebKit/LayoutTests/imported/wpt/encoding/textencoder-utf16-surrogates.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textencoder-utf16-surrogates.html rename to third_party/WebKit/LayoutTests/imported/wpt/encoding/textencoder-utf16-surrogates.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/gamepad/idlharness.html b/third_party/WebKit/LayoutTests/imported/wpt/gamepad/idlharness.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/gamepad/idlharness.html rename to third_party/WebKit/LayoutTests/imported/wpt/gamepad/idlharness.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/create-touch-touchlist.html b/third_party/WebKit/LayoutTests/imported/wpt/touch-events/create-touch-touchlist.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/create-touch-touchlist.html rename to third_party/WebKit/LayoutTests/imported/wpt/touch-events/create-touch-touchlist.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/historical.html b/third_party/WebKit/LayoutTests/imported/wpt/touch-events/historical.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/historical.html rename to third_party/WebKit/LayoutTests/imported/wpt/touch-events/historical.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-globaleventhandler-interface.html b/third_party/WebKit/LayoutTests/imported/wpt/touch-events/touch-globaleventhandler-interface.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-globaleventhandler-interface.html rename to third_party/WebKit/LayoutTests/imported/wpt/touch-events/touch-globaleventhandler-interface.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-support.js b/third_party/WebKit/LayoutTests/imported/wpt/touch-events/touch-support.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-support.js rename to third_party/WebKit/LayoutTests/imported/wpt/touch-events/touch-support.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-touchevent-constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/touch-events/touch-touchevent-constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/touch-events/touch-touchevent-constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/touch-events/touch-touchevent-constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/idlharness-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/idlharness-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/idlharness-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/idlharness-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/idlharness.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/idlharness.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/idlharness.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/idlharness.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/resources/webperftestharness.js b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/resources/webperftestharness.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/resources/webperftestharness.js rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/resources/webperftestharness.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/resources/webperftestharnessextension.js b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/resources/webperftestharnessextension.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/resources/webperftestharnessextension.js rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/resources/webperftestharnessextension.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_clear_marks.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_clear_marks.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_clear_marks.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_clear_marks.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_clear_measures.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_clear_measures.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_clear_measures.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_clear_measures.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_entry_type.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_entry_type.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_entry_type.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_entry_type.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_exists.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_exists.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_exists.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_exists.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark_exceptions.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark_exceptions.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark_exceptions.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark_exceptions.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_mark_with_name_of_navigation_timing_optional_attribute.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_measure.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_measure.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_measure.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_measure.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_measure_exceptions.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_measure_exceptions.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_measure_exceptions.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_measure_exceptions.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_measure_navigation_timing.html b/third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_measure_navigation_timing.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/user-timing/test_user_timing_measure_navigation_timing.html rename to third_party/WebKit/LayoutTests/imported/wpt/user-timing/test_user_timing_measure_navigation_timing.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/README.md b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/README.md similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/README.md rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/README.md
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animatable/animate-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animatable/animate-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animatable/animate-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animatable/animate-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animatable/animate.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animatable/animate.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animatable/animate.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animatable/animate.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/delay.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/delay.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/delay.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/delay.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/direction.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/direction.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/direction.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/direction.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/duration.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/duration.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/duration.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/duration.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/easing.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/easing.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/easing.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/easing.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/endDelay.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/endDelay.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/endDelay.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/endDelay.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/fill.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/fill.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/fill.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/fill.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/getAnimations.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/getAnimations.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/getAnimations.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/getAnimations.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/getComputedStyle.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/getComputedStyle.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/getComputedStyle.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/getComputedStyle.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/iterationStart-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/iterationStart-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/iterationStart-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/iterationStart-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/iterationStart.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/iterationStart.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/iterationStart.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/iterationStart.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/iterations.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/iterations.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-effect-timing/iterations.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-effect-timing/iterations.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/discrete-animation.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/animation-types/discrete-animation.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/discrete-animation.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/animation-types/discrete-animation.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/not-animatable-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/animation-types/not-animatable-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/not-animatable-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/animation-types/not-animatable-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/not-animatable.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/animation-types/not-animatable.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/not-animatable.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/animation-types/not-animatable.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/keyframes/effect-value-context.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/keyframes/effect-value-context.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/keyframes/effect-value-context.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-model/keyframes/effect-value-context.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-timeline/document-timeline.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-timeline/document-timeline.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-timeline/document-timeline.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-timeline/document-timeline.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-timeline/idlharness-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-timeline/idlharness-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-timeline/idlharness-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-timeline/idlharness-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-timeline/idlharness.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-timeline/idlharness.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-timeline/idlharness.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation-timeline/idlharness.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/cancel.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/cancel.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/cancel.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/cancel.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finish-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finish-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finish-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finish-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finish.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finish.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finish.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finish.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finished-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finished-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finished-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finished-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finished.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finished.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/finished.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/finished.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/id.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/id.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/id.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/id.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/oncancel.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/oncancel.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/oncancel.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/oncancel.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/onfinish.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/onfinish.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/onfinish.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/onfinish.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/pause.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/pause.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/pause.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/pause.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/play.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/play.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/play.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/play.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playState.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playState.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playState.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playState.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playbackRate-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playbackRate-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playbackRate.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/playbackRate.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/playbackRate.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/ready.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/ready.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/ready.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/ready.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/reverse.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/reverse.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation/reverse.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/animation/reverse.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/constructor-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/constructor-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/constructor-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/constructor-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/effect-easing-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/effect-easing-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/effect-easing-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/effect-easing-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/effect-easing.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/effect-easing.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/effect-easing.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/effect-easing.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-currentIteration-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-currentIteration-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-currentIteration-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-currentIteration-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-currentIteration.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-currentIteration.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-currentIteration.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-currentIteration.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-progress-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-progress-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-progress-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-progress-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-progress.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-progress.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-progress.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming-progress.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/getComputedTiming.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/keyframe-handling.html b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/keyframe-handling.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/keyframe-handling.html rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/keyframe-effect/keyframe-handling.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/resources/effect-easing-tests.js b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/resources/effect-easing-tests.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/resources/effect-easing-tests.js rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/resources/effect-easing-tests.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/testcommon.js b/third_party/WebKit/LayoutTests/imported/wpt/web-animations/testcommon.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/testcommon.js rename to third_party/WebKit/LayoutTests/imported/wpt/web-animations/testcommon.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/datachannel-emptystring-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/datachannel-emptystring-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/datachannel-emptystring-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/datachannel-emptystring-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/datachannel-emptystring.html b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/datachannel-emptystring.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/datachannel-emptystring.html rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/datachannel-emptystring.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/no-media-call-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/no-media-call-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/no-media-call-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/no-media-call-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/no-media-call.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/no-media-call.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/promises-call-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/promises-call-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/promises-call-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/promises-call-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/promises-call.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/promises-call.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-idl-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/simplecall-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/simplecall-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/simplecall-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/simplecall-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/simplecall.html b/third_party/WebKit/LayoutTests/imported/wpt/webrtc/simplecall.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/simplecall.html rename to third_party/WebKit/LayoutTests/imported/wpt/webrtc/simplecall.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/README.md b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/README.md similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/README.md rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/README.md
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/document-domain-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/document-domain-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/document-domain-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/document-domain-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/document-domain.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/document-domain.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/document-domain.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/document-domain.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/eventTestHarness.js b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/eventTestHarness.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/eventTestHarness.js rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/eventTestHarness.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_basic.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_basic.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_basic.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_basic.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_basic.js b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_basic.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_basic.js rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_basic.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_body_attribute.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_body_attribute.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_body_attribute.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_body_attribute.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_body_attribute.js b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_body_attribute.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_body_attribute.js rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_body_attribute.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_case_sensitive.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_case_sensitive.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_case_sensitive.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_case_sensitive.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_case_sensitive.js b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_case_sensitive.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_case_sensitive.js rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_case_sensitive.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_constructor.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_constructor.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_constructor.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_constructor.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_constructor_eventinit.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_constructor_eventinit.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_constructor_eventinit.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_constructor_eventinit.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_key.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_key.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_key.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_key.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_newvalue.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_newvalue.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_newvalue.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_newvalue.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_oldvalue.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_oldvalue.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_oldvalue.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_oldvalue.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_removeitem.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_removeitem.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_removeitem.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_removeitem.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_storagearea.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_storagearea.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_storagearea.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_storagearea.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_storageeventinit.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_storageeventinit.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_storageeventinit.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_storageeventinit.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_url.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_url.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_local_url.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_local_url.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_key.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_key.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_key.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_key.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_newvalue.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_newvalue.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_newvalue.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_newvalue.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_oldvalue.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_oldvalue.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_oldvalue.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_oldvalue.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_removeitem.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_removeitem.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_removeitem.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_removeitem.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_storagearea.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_storagearea.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_storagearea.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_storagearea.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_storageeventinit.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_storageeventinit.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_storageeventinit.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_storageeventinit.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_url.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_url.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_session_url.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_session_url.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_setattribute.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_setattribute.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_setattribute.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_setattribute.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_setattribute.js b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_setattribute.js similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/event_setattribute.js rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/event_setattribute.js
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/idlharness-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/idlharness-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/idlharness-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/idlharness-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/idlharness.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/idlharness.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/idlharness.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/idlharness.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/missing_arguments.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/missing_arguments.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/missing_arguments.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/missing_arguments.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/event_body_handler.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/event_body_handler.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/event_body_handler.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/event_body_handler.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/event_setattribute_handler.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/event_setattribute_handler.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/event_setattribute_handler.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/event_setattribute_handler.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_change_item_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_change_item_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_change_item_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_change_item_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_set_item_clear_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_set_item_clear_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_set_item_clear_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_set_item_clear_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_set_item_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_set_item_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_set_item_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_set_item_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_set_item_remove_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_set_item_remove_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/local_set_item_remove_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/local_set_item_remove_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_change_item_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_change_item_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_change_item_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_change_item_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_set_item_clear_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_set_item_clear_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_set_item_clear_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_set_item_clear_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_set_item_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_set_item_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_set_item_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_set_item_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_set_item_remove_iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_set_item_remove_iframe.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/session_set_item_remove_iframe.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/session_set_item_remove_iframe.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/storage_local_window_open_second.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/storage_local_window_open_second.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/storage_local_window_open_second.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/storage_local_window_open_second.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/storage_session_window_open_second.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/storage_session_window_open_second.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/resources/storage_session_window_open_second.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/resources/storage_session_window_open_second.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_builtins-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_builtins-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_builtins-expected.txt rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_builtins-expected.txt
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_builtins.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_builtins.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_builtins.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_builtins.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_clear.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_clear.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_clear.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_clear.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_enumerate.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_enumerate.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_enumerate.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_enumerate.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_functions_not_overwritten.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_functions_not_overwritten.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_functions_not_overwritten.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_functions_not_overwritten.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_getitem.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_getitem.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_getitem.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_getitem.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_in.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_in.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_in.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_in.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_indexing.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_indexing.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_indexing.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_indexing.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_key.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_key.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_key.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_key.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_key_empty_string.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_key_empty_string.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_key_empty_string.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_key_empty_string.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_length.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_length.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_length.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_length.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_local_setitem_quotaexceedederr.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_local_setitem_quotaexceedederr.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_local_setitem_quotaexceedederr.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_local_setitem_quotaexceedederr.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_local_window_open.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_local_window_open.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_local_window_open.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_local_window_open.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_removeitem.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_removeitem.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_removeitem.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_removeitem.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_session_setitem_quotaexceedederr.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_session_setitem_quotaexceedederr.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_session_setitem_quotaexceedederr.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_session_setitem_quotaexceedederr.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_session_window_open.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_session_window_open.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_session_window_open.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_session_window_open.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_set_value_enumerate.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_set_value_enumerate.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_set_value_enumerate.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_set_value_enumerate.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_setitem.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_setitem.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_setitem.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_setitem.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_string_conversion.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_string_conversion.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_string_conversion.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_string_conversion.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_supported_property_names.html b/third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_supported_property_names.html similarity index 100% rename from third_party/WebKit/LayoutTests/imported/web-platform-tests/webstorage/storage_supported_property_names.html rename to third_party/WebKit/LayoutTests/imported/wpt/webstorage/storage_supported_property_names.html
diff --git a/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png b/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png index 3b269e42..35077ef3 100644 --- a/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png +++ b/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png b/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png index 356859e..5704ef1 100644 --- a/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png +++ b/third_party/WebKit/LayoutTests/platform/linux/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png b/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png index 7bbf8b8..13f664b 100644 --- a/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png b/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png index 7904cca..08727c8 100644 --- a/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac-mac10.9/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png b/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png index 0d942954..450d52a 100644 --- a/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-deep-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png b/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png index 41e8ed7b..0841643 100644 --- a/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/win/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png b/third_party/WebKit/LayoutTests/platform/win/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png index e913d4b..39381753 100644 --- a/third_party/WebKit/LayoutTests/platform/win/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png +++ b/third_party/WebKit/LayoutTests/platform/win/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/win7/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png b/third_party/WebKit/LayoutTests/platform/win7/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png new file mode 100644 index 0000000..e913d4b --- /dev/null +++ b/third_party/WebKit/LayoutTests/platform/win7/transforms/3d/point-mapping/3d-point-mapping-preserve-3d-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/svg/custom/tabindex-order.html b/third_party/WebKit/LayoutTests/svg/custom/tabindex-order.html index a3fe411c..bc505d2 100644 --- a/third_party/WebKit/LayoutTests/svg/custom/tabindex-order.html +++ b/third_party/WebKit/LayoutTests/svg/custom/tabindex-order.html
@@ -15,12 +15,9 @@ } } - function dispatchTabPress(element, shiftKey) + function dispatchTabPress(element, modifiers) { - var event = document.createEvent('KeyboardEvents'); - var tabKeyIdentifier = 'U+0009'; - event.initKeyboardEvent('keydown', true, true, document.defaultView, tabKeyIdentifier, 0, false, false, shiftKey, false, false); - element.dispatchEvent(event); + eventSender.keyDown('\u0009', modifiers); } var lastFocusedElement = null; @@ -54,7 +51,7 @@ log('Tabbing forward....\n'); for (var i = 0; i < rects.length; ++i) { if (rects[i].tabIndex >= 0) - dispatchTabPress(document, false); + dispatchTabPress(document, []); } lastFocusedElement.blur(); @@ -62,7 +59,7 @@ log('\nTabbing backward....\n'); for (var i = 0; i < rects.length; ++i) { if (rects[i].tabIndex >= 0) - dispatchTabPress(document, true); + dispatchTabPress(document, ['shiftKey']); } log('\nTest finished\n');
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp index ce69fab..a5792c8 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
@@ -770,6 +770,10 @@ ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerialize(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) { m_writer.writeReferenceCount(m_nextObjectReference); + + if (value.IsEmpty()) + return handleError(InputError, "The empty property cannot be cloned.", next); + uint32_t objectReference; if ((value->IsObject() || value->IsDate() || value->IsRegExp()) && m_objectPool.tryGet(value.As<v8::Object>(), &objectReference)) { @@ -777,16 +781,11 @@ // that we grey and write below). ASSERT(!value->IsString()); m_writer.writeObjectReference(objectReference); - } else { - return doSerializeValue(value, next); + return nullptr; } - return 0; -} + if (value->IsObject()) + return doSerializeObject(value.As<v8::Object>(), next); -ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeValue(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) -{ - if (value.IsEmpty()) - return handleError(InputError, "The empty property name cannot be cloned.", next); if (value->IsUndefined()) { m_writer.writeUndefined(); } else if (value->IsNull()) { @@ -803,72 +802,106 @@ m_writer.writeNumber(value.As<v8::Number>()->Value()); } else if (value->IsString()) { writeString(value); - } else if (value->IsObject()) { - v8::Local<v8::Object> jsObject = value.As<v8::Object>(); - - uint32_t arrayBufferIndex; - uint32_t imageBitmapIndex; - uint32_t offscreenCanvasIndex; - if (V8ArrayBufferView::hasInstance(value, isolate())) { - return writeAndGreyArrayBufferView(jsObject, next); - } else if (V8MessagePort::hasInstance(value, isolate())) { - uint32_t messagePortIndex; - if (!m_transferredMessagePorts.tryGet(jsObject, &messagePortIndex)) - return handleError(DataCloneError, "A MessagePort could not be cloned.", next); - m_writer.writeTransferredMessagePort(messagePortIndex); - return nullptr; - } else if (V8ArrayBuffer::hasInstance(value, isolate()) && m_transferredArrayBuffers.tryGet(jsObject, &arrayBufferIndex)) { - return writeTransferredArrayBuffer(value, arrayBufferIndex, next); - } else if (V8ImageBitmap::hasInstance(value, isolate()) && m_transferredImageBitmaps.tryGet(jsObject, &imageBitmapIndex)) { - return writeTransferredImageBitmap(value, imageBitmapIndex, next); - } else if (V8SharedArrayBuffer::hasInstance(value, isolate()) && m_transferredArrayBuffers.tryGet(jsObject, &arrayBufferIndex)) { - return writeTransferredSharedArrayBuffer(value, arrayBufferIndex, next); - } else if (V8OffscreenCanvas::hasInstance(value, isolate()) && m_transferredOffscreenCanvas.tryGet(jsObject, &offscreenCanvasIndex)) { - return writeTransferredOffscreenCanvas(value, offscreenCanvasIndex, next); - } - - greyObject(jsObject); - if (value->IsDate()) { - m_writer.writeDate(value.As<v8::Date>()->ValueOf()); - } else if (value->IsStringObject()) { - writeStringObject(value); - } else if (value->IsNumberObject()) { - writeNumberObject(value); - } else if (value->IsBooleanObject()) { - writeBooleanObject(value); - } else if (value->IsArray()) { - return startArrayState(value.As<v8::Array>(), next); - } else if (value->IsMap()) { - return startMapState(value.As<v8::Map>(), next); - } else if (value->IsSet()) { - return startSetState(value.As<v8::Set>(), next); - } else if (V8File::hasInstance(value, isolate())) { - return writeFile(value, next); - } else if (V8Blob::hasInstance(value, isolate())) { - return writeBlob(value, next); - } else if (V8FileList::hasInstance(value, isolate())) { - return writeFileList(value, next); - } else if (V8ImageData::hasInstance(value, isolate())) { - writeImageData(value); - } else if (value->IsRegExp()) { - writeRegExp(value); - } else if (V8ImageBitmap::hasInstance(value, isolate())) { - return writeImageBitmap(value, next); - } else if (V8ArrayBuffer::hasInstance(value, isolate())) { - return writeArrayBuffer(value, next); - } else if (V8CompositorProxy::hasInstance(value, isolate())) { - return writeCompositorProxy(value, next); - } else if (isHostObject(jsObject) || jsObject->IsCallable() || value->IsNativeError()) { - return handleError(DataCloneError, "An object could not be cloned.", next); - } else { - return startObjectState(jsObject, next); - } } else { return handleError(DataCloneError, "A value could not be cloned.", next); } return nullptr; } +ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeObject(v8::Local<v8::Object> jsObject, ScriptValueSerializer::StateBase* next) +{ + DCHECK(!jsObject.IsEmpty()); + + if (V8ArrayBufferView::hasInstance(jsObject, isolate())) { + return writeAndGreyArrayBufferView(jsObject, next); + } + if (V8MessagePort::hasInstance(jsObject, isolate())) { + uint32_t messagePortIndex; + if (!m_transferredMessagePorts.tryGet(jsObject, &messagePortIndex)) + return handleError(DataCloneError, "A MessagePort could not be cloned.", next); + m_writer.writeTransferredMessagePort(messagePortIndex); + return nullptr; + } + uint32_t arrayBufferIndex; + if (V8ArrayBuffer::hasInstance(jsObject, isolate()) && m_transferredArrayBuffers.tryGet(jsObject, &arrayBufferIndex)) { + return writeTransferredArrayBuffer(jsObject, arrayBufferIndex, next); + } + uint32_t imageBitmapIndex; + if (V8ImageBitmap::hasInstance(jsObject, isolate()) && m_transferredImageBitmaps.tryGet(jsObject, &imageBitmapIndex)) { + return writeTransferredImageBitmap(jsObject, imageBitmapIndex, next); + } + if (V8SharedArrayBuffer::hasInstance(jsObject, isolate()) && m_transferredArrayBuffers.tryGet(jsObject, &arrayBufferIndex)) { + return writeTransferredSharedArrayBuffer(jsObject, arrayBufferIndex, next); + } + uint32_t offscreenCanvasIndex; + if (V8OffscreenCanvas::hasInstance(jsObject, isolate()) && m_transferredOffscreenCanvas.tryGet(jsObject, &offscreenCanvasIndex)) { + return writeTransferredOffscreenCanvas(jsObject, offscreenCanvasIndex, next); + } + + greyObject(jsObject); + + if (jsObject->IsDate()) { + m_writer.writeDate(jsObject.As<v8::Date>()->ValueOf()); + return nullptr; + } + if (jsObject->IsStringObject()) { + writeStringObject(jsObject); + return nullptr; + } + if (jsObject->IsNumberObject()) { + writeNumberObject(jsObject); + return nullptr; + } + if (jsObject->IsBooleanObject()) { + writeBooleanObject(jsObject); + return nullptr; + } + if (jsObject->IsArray()) { + return startArrayState(jsObject.As<v8::Array>(), next); + } + if (jsObject->IsMap()) { + return startMapState(jsObject.As<v8::Map>(), next); + } + if (jsObject->IsSet()) { + return startSetState(jsObject.As<v8::Set>(), next); + } + + if (V8File::hasInstance(jsObject, isolate())) { + return writeFile(jsObject, next); + } + if (V8Blob::hasInstance(jsObject, isolate())) { + return writeBlob(jsObject, next); + } + if (V8FileList::hasInstance(jsObject, isolate())) { + return writeFileList(jsObject, next); + } + if (V8ImageData::hasInstance(jsObject, isolate())) { + writeImageData(jsObject); + return nullptr; + } + if (jsObject->IsRegExp()) { + writeRegExp(jsObject); + return nullptr; + } + + if (V8ImageBitmap::hasInstance(jsObject, isolate())) { + return writeImageBitmap(jsObject, next); + } + if (V8ArrayBuffer::hasInstance(jsObject, isolate())) { + return writeArrayBuffer(jsObject, next); + } + if (V8CompositorProxy::hasInstance(jsObject, isolate())) { + return writeCompositorProxy(jsObject, next); + } + + // Since IsNativeError is expensive, this check should always be the last check. + if (isHostObject(jsObject) || jsObject->IsCallable() || jsObject->IsNativeError()) { + return handleError(DataCloneError, "An object could not be cloned.", next); + } + + return startObjectState(jsObject, next); +} + ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeArrayBuffer(v8::Local<v8::Value> arrayBuffer, ScriptValueSerializer::StateBase* next) { return doSerialize(arrayBuffer, next);
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h index b311507..a02185d 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h
@@ -366,7 +366,7 @@ typedef CollectionState<v8::Set> SetState; // Functions used by serialization states. - virtual StateBase* doSerializeValue(v8::Local<v8::Value>, StateBase* next); + virtual StateBase* doSerializeObject(v8::Local<v8::Object>, StateBase* next); private: StateBase* doSerialize(v8::Local<v8::Value>, StateBase* next);
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8CSSStyleDeclarationCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8CSSStyleDeclarationCustom.cpp index bb76d78e..96b6d9aeb 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8CSSStyleDeclarationCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8CSSStyleDeclarationCustom.cpp
@@ -175,8 +175,6 @@ void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!v8Name->IsString()) - return; // NOTE: cssPropertyInfo lookups incur several mallocs. // Successful lookups have the same cost the first time, but are cached. if (cssPropertyInfo(v8Name.As<v8::String>())) { @@ -187,9 +185,6 @@ void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; - // Search the style declaration. CSSPropertyID unresolvedProperty = cssPropertyInfo(name.As<v8::String>()); @@ -212,8 +207,6 @@ void V8CSSStyleDeclaration::namedPropertySetterCustom(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder()); CSSPropertyID unresolvedProperty = cssPropertyInfo(name.As<v8::String>()); if (!unresolvedProperty)
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp index 8848b68..8b0d73b 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp
@@ -94,29 +94,21 @@ void V8HTMLEmbedElement::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; getScriptableObjectProperty<V8HTMLEmbedElement>(name.As<v8::String>(), info); } void V8HTMLObjectElement::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; getScriptableObjectProperty<V8HTMLObjectElement>(name.As<v8::String>(), info); } void V8HTMLEmbedElement::namedPropertySetterCustom(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; setScriptableObjectProperty<V8HTMLEmbedElement>(name.As<v8::String>(), value, info); } void V8HTMLObjectElement::namedPropertySetterCustom(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; setScriptableObjectProperty<V8HTMLObjectElement>(name.As<v8::String>(), value, info); }
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp index 8a1af71..1c42741 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
@@ -282,8 +282,6 @@ void V8Window::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); DOMWindow* window = V8Window::toImpl(info.Holder()); if (!window)
diff --git a/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp b/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp index 0fb7352..a0ee508f 100644 --- a/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp +++ b/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp
@@ -312,29 +312,26 @@ doWriteUint32(value); } -ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::doSerializeValue(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) +ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::doSerializeObject(v8::Local<v8::Object> jsObject, ScriptValueSerializer::StateBase* next) { - bool isDOMFileSystem = V8DOMFileSystem::hasInstance(value, isolate()); - bool isCryptoKey = V8CryptoKey::hasInstance(value, isolate()); - bool isRTCCertificate = V8RTCCertificate::hasInstance(value, isolate()); - if (isDOMFileSystem || isCryptoKey || isRTCCertificate) { - v8::Local<v8::Object> jsObject = value.As<v8::Object>(); - if (jsObject.IsEmpty()) - return handleError(DataCloneError, "An object could not be cloned.", next); - greyObject(jsObject); + DCHECK(!jsObject.IsEmpty()); - if (isDOMFileSystem) - return writeDOMFileSystem(value, next); - if (isCryptoKey) { - if (!writeCryptoKey(value)) - return handleError(DataCloneError, "Couldn't serialize key data", next); - return nullptr; - } - if (isRTCCertificate) - return writeRTCCertificate(value, next); - ASSERT_NOT_REACHED(); + if (V8DOMFileSystem::hasInstance(jsObject, isolate())) { + greyObject(jsObject); + return writeDOMFileSystem(jsObject, next); } - return ScriptValueSerializer::doSerializeValue(value, next); + if (V8CryptoKey::hasInstance(jsObject, isolate())) { + greyObject(jsObject); + if (!writeCryptoKey(jsObject)) + return handleError(DataCloneError, "Couldn't serialize key data", next); + return nullptr; + } + if (V8RTCCertificate::hasInstance(jsObject, isolate())) { + greyObject(jsObject); + return writeRTCCertificate(jsObject, next); + } + + return ScriptValueSerializer::doSerializeObject(jsObject, next); } bool SerializedScriptValueReaderForModules::read(v8::Local<v8::Value>* value, ScriptValueCompositeCreator& creator)
diff --git a/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.h b/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.h index 60f9525..d083e12 100644 --- a/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.h +++ b/third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.h
@@ -76,7 +76,7 @@ ScriptValueSerializerForModules(SerializedScriptValueWriter&, const Transferables*, WebBlobInfoArray*, BlobDataHandleMap&, v8::TryCatch&, ScriptState*); private: - ScriptValueSerializer::StateBase* doSerializeValue(v8::Local<v8::Value>, ScriptValueSerializer::StateBase* next) override; + ScriptValueSerializer::StateBase* doSerializeObject(v8::Local<v8::Object>, ScriptValueSerializer::StateBase* next) override; ScriptValueSerializer::StateBase* writeDOMFileSystem(v8::Local<v8::Value>, ScriptValueSerializer::StateBase* next); bool writeCryptoKey(v8::Local<v8::Value>);
diff --git a/third_party/WebKit/Source/bindings/templates/interface.cpp b/third_party/WebKit/Source/bindings/templates/interface.cpp index 932323f..e0ca851 100644 --- a/third_party/WebKit/Source/bindings/templates/interface.cpp +++ b/third_party/WebKit/Source/bindings/templates/interface.cpp
@@ -167,8 +167,6 @@ {% set getter = named_property_getter %} static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -204,6 +202,8 @@ {% set getter = named_property_getter %} static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; {% if getter.is_custom %} {{v8_class}}::namedPropertyGetterCustom(name, info); {% else %} @@ -222,8 +222,6 @@ {% set setter = named_property_setter %} static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); {% if setter.has_exception_state %} v8::String::Utf8Value namedProperty(nameString); @@ -275,6 +273,8 @@ {% set setter = named_property_setter %} static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; {% if setter.is_custom %} {{v8_class}}::namedPropertySetterCustom(name, v8Value, info); {% else %} @@ -295,8 +295,6 @@ communicate property attributes. #} static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!name->IsString()) - return; {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -324,6 +322,8 @@ {% set getter = named_property_getter %} static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; {% if getter.is_custom_property_query %} {{v8_class}}::namedPropertyQueryCustom(name, info); {% else %} @@ -341,8 +341,6 @@ {% set deleter = named_property_deleter %} static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { - if (!name->IsString()) - return; {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); {% if deleter.is_raises_exception %} @@ -379,6 +377,8 @@ {% set deleter = named_property_deleter %} static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; {% if deleter.is_custom %} {{v8_class}}::namedPropertyDeleterCustom(name, info); {% else %}
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp index f401512..6d00e93 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp
@@ -104,21 +104,29 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexed::namedPropertyGetterCustom(name, info); } static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexed::namedPropertySetterCustom(name, v8Value, info); } static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexed::namedPropertyQueryCustom(name, info); } static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexed::namedPropertyDeleterCustom(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp index e1f19ea2..952df79 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp
@@ -104,21 +104,29 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedGlobal::namedPropertyGetterCustom(name, info); } static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedGlobal::namedPropertySetterCustom(name, v8Value, info); } static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedGlobal::namedPropertyQueryCustom(name, info); } static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedGlobal::namedPropertyDeleterCustom(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp index 8e82838..4a97e6b 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp
@@ -104,21 +104,29 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedPrimaryGlobal::namedPropertyGetterCustom(name, info); } static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedPrimaryGlobal::namedPropertySetterCustom(name, v8Value, info); } static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedPrimaryGlobal::namedPropertyQueryCustom(name, info); } static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; V8TestIntegerIndexedPrimaryGlobal::namedPropertyDeleterCustom(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp index 2f00995..aca14c68 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
@@ -1875,8 +1875,6 @@ static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -1888,13 +1886,13 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestInterfaceImplementationV8Internal::namedPropertyGetter(name, info); } static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); V8StringResource<> propertyName(nameString); @@ -1911,13 +1909,13 @@ static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestInterfaceImplementationV8Internal::namedPropertySetter(name, v8Value, info); } static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!name->IsString()) - return; TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -1932,13 +1930,13 @@ static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; TestInterfaceImplementationV8Internal::namedPropertyQuery(name, info); } static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { - if (!name->IsString()) - return; TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); DeleteResult result = impl->anonymousNamedDeleter(propertyName); @@ -1948,6 +1946,8 @@ static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; TestInterfaceImplementationV8Internal::namedPropertyDeleter(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp index 17ed8b9..610da9c 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp
@@ -448,8 +448,6 @@ static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -465,13 +463,13 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestInterface2V8Internal::namedPropertyGetter(name, info); } static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); v8::String::Utf8Value namedProperty(nameString); ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); @@ -495,13 +493,13 @@ static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestInterface2V8Internal::namedPropertySetter(name, v8Value, info); } static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!name->IsString()) - return; TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -516,13 +514,13 @@ static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; TestInterface2V8Internal::namedPropertyQuery(name, info); } static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { - if (!name->IsString()) - return; TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -536,6 +534,8 @@ static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; TestInterface2V8Internal::namedPropertyDeleter(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp index 3d875032..65e66fb 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp
@@ -207,21 +207,29 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestInterface3::namedPropertyGetterCustom(name, info); } static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; V8TestInterface3::namedPropertySetterCustom(name, v8Value, info); } static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; V8TestInterface3::namedPropertyQueryCustom(name, info); } static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; V8TestInterface3::namedPropertyDeleterCustom(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp index 41de4ff..05ef0b0 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -11378,8 +11378,6 @@ static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestObject* impl = V8TestObject::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -11392,13 +11390,13 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestObjectV8Internal::namedPropertyGetter(name, info); } static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestObject* impl = V8TestObject::toImpl(info.Holder()); V8StringResource<> propertyName(nameString); @@ -11416,13 +11414,13 @@ static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestObjectV8Internal::namedPropertySetter(name, v8Value, info); } static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!name->IsString()) - return; TestObject* impl = V8TestObject::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -11438,13 +11436,13 @@ static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; TestObjectV8Internal::namedPropertyQuery(name, info); } static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { - if (!name->IsString()) - return; TestObject* impl = V8TestObject::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); ScriptState* scriptState = ScriptState::current(info.GetIsolate()); @@ -11455,6 +11453,8 @@ static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; TestObjectV8Internal::namedPropertyDeleter(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp index 81d0fee..3599ce7 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp
@@ -65,8 +65,6 @@ static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -79,13 +77,13 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestSpecialOperationsV8Internal::namedPropertyGetter(name, info); } static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder()); V8StringResource<> propertyName(nameString); @@ -105,13 +103,13 @@ static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestSpecialOperationsV8Internal::namedPropertySetter(name, v8Value, info); } static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!name->IsString()) - return; TestSpecialOperations* impl = V8TestSpecialOperations::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -126,6 +124,8 @@ static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; TestSpecialOperationsV8Internal::namedPropertyQuery(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp index 0f46f8d5..389791b 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp
@@ -49,8 +49,6 @@ static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestSpecialOperationsNotEnumerable* impl = V8TestSpecialOperationsNotEnumerable::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -62,6 +60,8 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestSpecialOperationsNotEnumerableV8Internal::namedPropertyGetter(name, info); }
diff --git a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp index ccd4da3..7b6d1761 100644 --- a/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp
@@ -681,8 +681,6 @@ static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(nameString); @@ -694,13 +692,13 @@ static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestInterface5ImplementationV8Internal::namedPropertyGetter(name, info); } static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { - if (!name->IsString()) - return; auto nameString = name.As<v8::String>(); TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); V8StringResource<> propertyName(nameString); @@ -717,13 +715,13 @@ static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { + if (!name->IsString()) + return; TestInterface5ImplementationV8Internal::namedPropertySetter(name, v8Value, info); } static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { - if (!name->IsString()) - return; TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); v8::String::Utf8Value namedProperty(name); @@ -738,13 +736,13 @@ static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) { + if (!name->IsString()) + return; TestInterface5ImplementationV8Internal::namedPropertyQuery(name, info); } static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { - if (!name->IsString()) - return; TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder()); AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); DeleteResult result = impl->anonymousNamedDeleter(propertyName); @@ -754,6 +752,8 @@ static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { + if (!name->IsString()) + return; TestInterface5ImplementationV8Internal::namedPropertyDeleter(name, info); }
diff --git a/third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp b/third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp index 3a438d4..deb1d2d 100644 --- a/third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp +++ b/third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp
@@ -357,7 +357,7 @@ template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const { - return static_cast<float>(computeLengthDouble(conversionData)); + return clampTo<float>(computeLengthDouble(conversionData)); } template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
diff --git a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp index 8192c4d0..d04a302 100644 --- a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp +++ b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
@@ -278,7 +278,7 @@ // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified. if (!shorthandPropertyAppeared.test(CSSPropertyBorder - firstCSSProperty)) { - value = borderPropertyValue(ReturnNullOnUncommonValues); + value = borderPropertyValue(); if (value.isNull()) shorthandPropertyAppeared.set(CSSPropertyBorder - firstCSSProperty); else @@ -435,7 +435,7 @@ case CSSPropertyBackground: return getLayeredShorthandValue(backgroundShorthand()); case CSSPropertyBorder: - return borderPropertyValue(OmitUncommonValues); + return borderPropertyValue(); case CSSPropertyBorderTop: return getShorthandValue(borderTopShorthand()); case CSSPropertyBorderRight: @@ -893,19 +893,15 @@ return res; } -String StylePropertySerializer::borderPropertyValue(CommonValueMode valueMode) const +String StylePropertySerializer::borderPropertyValue() const { const StylePropertyShorthand properties[3] = { borderWidthShorthand(), borderStyleShorthand(), borderColorShorthand() }; String commonValue; StringBuilder result; for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) { String value = getCommonValue(properties[i]); - if (value.isNull()) { - if (valueMode == ReturnNullOnUncommonValues) - return String(); - ASSERT(valueMode == OmitUncommonValues); - continue; - } + if (value.isNull()) + return String(); if (!i) commonValue = value; else if (!commonValue.isNull() && commonValue != value)
diff --git a/third_party/WebKit/Source/core/css/StylePropertySerializer.h b/third_party/WebKit/Source/core/css/StylePropertySerializer.h index 42bb7fd4..e075dad 100644 --- a/third_party/WebKit/Source/core/css/StylePropertySerializer.h +++ b/third_party/WebKit/Source/core/css/StylePropertySerializer.h
@@ -41,8 +41,7 @@ String getPropertyValue(CSSPropertyID) const; private: String getCommonValue(const StylePropertyShorthand&) const; - enum CommonValueMode { OmitUncommonValues, ReturnNullOnUncommonValues }; - String borderPropertyValue(CommonValueMode) const; + String borderPropertyValue() const; String getLayeredShorthandValue(const StylePropertyShorthand&) const; String get4Values(const StylePropertyShorthand&) const; String borderSpacingValue(const StylePropertyShorthand&) const;
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index 0db7245..d22323f 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -6000,6 +6000,11 @@ visitor->traceWrappers( Supplementable<Document>::m_supplements.get( FontFaceSet::supplementName())); + for (int i = 0; i < numNodeListInvalidationTypes; ++i) { + for (auto list : m_nodeLists[i]) { + visitor->traceWrappers(list); + } + } ContainerNode::traceWrappers(visitor); }
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp index aa0b479..88b0334 100644 --- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp +++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -907,7 +907,17 @@ bool FrameSelection::setSelectedRange(const EphemeralRange& range, TextAffinity affinity, SelectionDirectionalMode directional, SetSelectionOptions options) { - return m_selectionEditor->setSelectedRange(range, affinity, directional, options); + if (range.isNull()) + return false; + m_selectionEditor->resetLogicalRange(); + // Since |FrameSeleciton::setSelection()| dispatches events and DOM tree + // can be modified by event handlers, we should create |Range| object before + // calling it. + Range* logicalRange = createRange(range); + VisibleSelection newSelection(range.startPosition(), range.endPosition(), affinity, directional == SelectionDirectionalMode::Directional); + setSelection(newSelection, options); + m_selectionEditor->setLogicalRange(logicalRange); + return true; } Range* FrameSelection::firstRange() const
diff --git a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp index b70bc15b..8c63eac 100644 --- a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp +++ b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
@@ -837,11 +837,10 @@ return x; } -bool SelectionEditor::setSelectedRange(const EphemeralRange& range, TextAffinity affinity, SelectionDirectionalMode directional, FrameSelection::SetSelectionOptions options) +// TODO(yosin) We should utilize |resetLogicalRange()| in other places where +// reset |m_logicalRange|. +void SelectionEditor::resetLogicalRange() { - if (range.isNull()) - return false; - // Non-collapsed ranges are not allowed to start at the end of a line that is wrapped, // they start at the beginning of the next line instead if (m_logicalRange) { @@ -849,16 +848,13 @@ m_logicalRange = nullptr; } stopObservingVisibleSelectionChangeIfNecessary(); +} - // Since |FrameSeleciton::setSelection()| dispatches events and DOM tree - // can be modified by event handlers, we should create |Range| object before - // calling it. - m_logicalRange = createRange(range); - - VisibleSelection newSelection(range.startPosition(), range.endPosition(), affinity, directional == SelectionDirectionalMode::Directional); - m_frameSelection->setSelection(newSelection, options); +void SelectionEditor::setLogicalRange(Range* range) +{ + DCHECK(!m_logicalRange) << "A logical range should be one."; + m_logicalRange = range; startObservingVisibleSelectionChange(); - return true; } Range* SelectionEditor::firstRange() const
diff --git a/third_party/WebKit/Source/core/editing/SelectionEditor.h b/third_party/WebKit/Source/core/editing/SelectionEditor.h index a6b9a34..9afbd4b 100644 --- a/third_party/WebKit/Source/core/editing/SelectionEditor.h +++ b/third_party/WebKit/Source/core/editing/SelectionEditor.h
@@ -64,6 +64,10 @@ // |VisibleSelection|'s |firstRange()| is returned. Range* firstRange() const; + // There functions are exposed for |FrameSelection|. + void resetLogicalRange(); + void setLogicalRange(Range*); + // VisibleSelectionChangeObserver interface. void didChangeVisibleSelection() override;
diff --git a/third_party/WebKit/Source/core/editing/VisiblePosition.cpp b/third_party/WebKit/Source/core/editing/VisiblePosition.cpp index 912d7534..e716d78 100644 --- a/third_party/WebKit/Source/core/editing/VisiblePosition.cpp +++ b/third_party/WebKit/Source/core/editing/VisiblePosition.cpp
@@ -77,6 +77,12 @@ return VisiblePositionTemplate<Strategy>(upstreamPosition); } +template <typename Strategy> +VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::firstPositionInNode(Node* node) +{ + return create(PositionWithAffinityTemplate<Strategy>(PositionTemplate<Strategy>::firstPositionInNode(node))); +} + VisiblePosition createVisiblePosition(const Position& position, TextAffinity affinity) { return createVisiblePosition(PositionWithAffinity(position, affinity));
diff --git a/third_party/WebKit/Source/core/editing/VisiblePosition.h b/third_party/WebKit/Source/core/editing/VisiblePosition.h index 180bda2..1350653c 100644 --- a/third_party/WebKit/Source/core/editing/VisiblePosition.h +++ b/third_party/WebKit/Source/core/editing/VisiblePosition.h
@@ -94,6 +94,8 @@ PositionWithAffinityTemplate<Strategy> toPositionWithAffinity() const { return m_positionWithAffinity; } TextAffinity affinity() const { return m_positionWithAffinity.affinity(); } + static VisiblePositionTemplate<Strategy> firstPositionInNode(Node*); + DEFINE_INLINE_TRACE() { visitor->trace(m_positionWithAffinity);
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp index 854cc42..56b16b56 100644 --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -1341,7 +1341,7 @@ Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEditableElement(editableType) : node->document().documentElement(); if (!rootElement) return VisiblePosition(); - return createVisiblePosition(Position::firstPositionInNode(rootElement)); + return VisiblePosition::firstPositionInNode(rootElement); } VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutUnit lineDirectionPoint, EditableType editableType) @@ -1730,7 +1730,7 @@ { Position position = visiblePosition.deepEquivalent(); Element* startBlock = position.computeContainerNode() ? enclosingBlock(position.computeContainerNode(), rule) : 0; - return startBlock ? createVisiblePosition(Position::firstPositionInNode(startBlock)) : VisiblePosition(); + return startBlock ? VisiblePosition::firstPositionInNode(startBlock) : VisiblePosition(); } VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBoundaryCrossingRule rule) @@ -1816,7 +1816,7 @@ if (!highestRoot) return VisiblePosition(); - return createVisiblePosition(Position::firstPositionInNode(highestRoot)); + return VisiblePosition::firstPositionInNode(highestRoot); } VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition)
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp index 8563826..05d072d 100644 --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1021,7 +1021,7 @@ visiblePos = createVisiblePosition(pos, VP_DEFAULT_AFFINITY); visibleParagraphStart = startOfParagraph(visiblePos); visibleParagraphEnd = endOfParagraph(visiblePos); - moveParagraphs(visibleParagraphStart, visibleParagraphEnd, createVisiblePosition(Position::firstPositionInNode(newBlock)), editingState); + moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition::firstPositionInNode(newBlock), editingState); if (editingState->isAborted()) return nullptr; @@ -1540,7 +1540,7 @@ // Don't avoid block level anchors, because that would insert content into the wrong paragraph. if (enclosingAnchor && !isEnclosingBlock(enclosingAnchor)) { - VisiblePosition firstInAnchor = createVisiblePosition(Position::firstPositionInNode(enclosingAnchor)); + VisiblePosition firstInAnchor = VisiblePosition::firstPositionInNode(enclosingAnchor); VisiblePosition lastInAnchor = createVisiblePosition(lastPositionInNode(enclosingAnchor)); // If visually just after the anchor, insert *inside* the anchor unless it's the last // VisiblePosition in the document, to match NSTextView. @@ -1607,7 +1607,7 @@ if (!parentElement) break; // Do not split a node when doing so introduces an empty node. - VisiblePosition positionInParent = createVisiblePosition(Position::firstPositionInNode(parentElement)); + VisiblePosition positionInParent = VisiblePosition::firstPositionInNode(parentElement); VisiblePosition positionInNode = createVisiblePosition(firstPositionInOrBeforeNode(node)); if (positionInParent.deepEquivalent() != positionInNode.deepEquivalent()) splitElement(parentElement, node);
diff --git a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp index 84810315..0bfb8b2a 100644 --- a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
@@ -49,7 +49,7 @@ static bool isTableCellEmpty(Node* cell) { DCHECK(isTableCell(cell)) << cell; - return createVisiblePosition(Position::firstPositionInNode(cell)).deepEquivalent() == createVisiblePosition(lastPositionInNode(cell)).deepEquivalent(); + return VisiblePosition::firstPositionInNode(cell).deepEquivalent() == createVisiblePosition(lastPositionInNode(cell)).deepEquivalent(); } static bool isTableRowEmpty(Node* row) @@ -394,7 +394,7 @@ } if (node == m_startBlock) { - VisiblePosition previous = previousPositionOf(createVisiblePosition(Position::firstPositionInNode(m_startBlock.get()))); + VisiblePosition previous = previousPositionOf(VisiblePosition::firstPositionInNode(m_startBlock.get())); if (previous.isNotNull() && !isEndOfBlock(previous)) m_needPlaceholder = true; }
diff --git a/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp b/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp index 3c00f07..706bcbb 100644 --- a/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp
@@ -177,7 +177,7 @@ } // The selection is inside a blockquote i.e. enclosingNode is a blockquote - VisiblePosition positionInEnclosingBlock = createVisiblePosition(Position::firstPositionInNode(enclosingElement)); + VisiblePosition positionInEnclosingBlock = VisiblePosition::firstPositionInNode(enclosingElement); // If the blockquote is inline, the start of the enclosing block coincides with // positionInEnclosingBlock. VisiblePosition startOfEnclosingBlock = (enclosingElement->layoutObject() && enclosingElement->layoutObject()->isInline()) ? positionInEnclosingBlock : startOfBlock(positionInEnclosingBlock);
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp index 4f7b680..43a1bcc 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp
@@ -278,10 +278,10 @@ if (editingState->isAborted()) return false; - Node* firstChildInList = enclosingListChild(createVisiblePosition(Position::firstPositionInNode(listElement)).deepEquivalent().anchorNode(), listElement); + Node* firstChildInList = enclosingListChild(VisiblePosition::firstPositionInNode(listElement).deepEquivalent().anchorNode(), listElement); Element* outerBlock = firstChildInList && isBlockFlowElement(*firstChildInList) ? toElement(firstChildInList) : listElement; - moveParagraphWithClones(createVisiblePosition(Position::firstPositionInNode(listElement)), createVisiblePosition(lastPositionInNode(listElement)), newList, outerBlock, editingState); + moveParagraphWithClones(VisiblePosition::firstPositionInNode(listElement), createVisiblePosition(lastPositionInNode(listElement)), newList, outerBlock, editingState); if (editingState->isAborted()) return false; @@ -305,7 +305,7 @@ if (rangeEndIsInList && newList) currentSelection.setEnd(newList, lastOffsetInNode(newList), IGNORE_EXCEPTION); - setEndingSelection(createVisiblePosition(Position::firstPositionInNode(newList))); + setEndingSelection(VisiblePosition::firstPositionInNode(newList)); return true; } @@ -332,7 +332,7 @@ VisiblePosition end; DCHECK(listChildNode); if (isHTMLLIElement(*listChildNode)) { - start = createVisiblePosition(Position::firstPositionInNode(listChildNode)); + start = VisiblePosition::firstPositionInNode(listChildNode); end = createVisiblePosition(lastPositionInNode(listChildNode)); nextListChild = listChildNode->nextSibling(); previousListChild = listChildNode->previousSibling();
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp index dad54bf..a361cba 100644 --- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -571,7 +571,7 @@ // FIXME: Tolerate differences in id, class, and style attributes. if (element->parentNode() && isNonTableCellHTMLBlockElement(element) && areIdenticalElements(*element, *element->parentNode()) - && createVisiblePosition(Position::firstPositionInNode(element->parentNode())).deepEquivalent() == createVisiblePosition(Position::firstPositionInNode(element)).deepEquivalent() + && VisiblePosition::firstPositionInNode(element->parentNode()).deepEquivalent() == VisiblePosition::firstPositionInNode(element).deepEquivalent() && createVisiblePosition(lastPositionInNode(element->parentNode())).deepEquivalent() == createVisiblePosition(lastPositionInNode(element)).deepEquivalent()) { insertedNodes.willRemoveNodePreservingChildren(*element); removeNodePreservingChildren(element, editingState); @@ -1351,7 +1351,7 @@ insertNodeAfter(newListItem, enclosingBlockElement, editingState); if (editingState->isAborted()) return; - setEndingSelection(createVisiblePosition(Position::firstPositionInNode(newListItem))); + setEndingSelection(VisiblePosition::firstPositionInNode(newListItem)); } else { // Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph // block's style seems to annoy users.
diff --git a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp index 9544a09d..41d0f6ed 100644 --- a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
@@ -522,7 +522,7 @@ // If we have a caret selection at the beginning of a cell, we have nothing to do. Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivalent(), &isTableCell); - if (enclosingTableCell && visibleStart.deepEquivalent() == createVisiblePosition(Position::firstPositionInNode(enclosingTableCell)).deepEquivalent()) + if (enclosingTableCell && visibleStart.deepEquivalent() == VisiblePosition::firstPositionInNode(enclosingTableCell).deepEquivalent()) return; // If the caret is at the start of a paragraph after a table, move content into the last table cell.
diff --git a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp index 23805707..76db925 100644 --- a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp +++ b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
@@ -514,9 +514,7 @@ { if (!contains(resource)) return; - // TODO(hiroshige): RELEASE_ASSERT() is used here to check whether - // crbug.com/570043 was fixed and should be reverted before going to beta. - RELEASE_ASSERT(m_deadSize >= resource->size()); + ASSERT(m_deadSize >= resource->size()); m_liveSize += resource->size(); m_deadSize -= resource->size(); } @@ -525,9 +523,6 @@ { if (!contains(resource)) return; - // TODO(hiroshige): RELEASE_ASSERT() is used here to check whether - // crbug.com/570043 was fixed and should be reverted before going to beta. - RELEASE_ASSERT(m_liveSize >= resource->size()); m_liveSize -= resource->size(); m_deadSize += resource->size(); removeFromLiveDecodedResourcesList(getEntryForResource(resource)); @@ -549,13 +544,11 @@ insertInLRUList(entry, lruListFor(entry->m_accessCount, newSize)); ptrdiff_t delta = newSize - oldSize; - // TODO(hiroshige): RELEASE_ASSERT()s are used below to check whether - // crbug.com/570043 was fixed and should be reverted before going to beta. if (resource->hasClientsOrObservers()) { - RELEASE_ASSERT(delta >= 0 || m_liveSize >= static_cast<size_t>(-delta) ); + ASSERT(delta >= 0 || m_liveSize >= static_cast<size_t>(-delta) ); m_liveSize += delta; } else { - RELEASE_ASSERT(delta >= 0 || m_deadSize >= static_cast<size_t>(-delta) ); + ASSERT(delta >= 0 || m_deadSize >= static_cast<size_t>(-delta) ); m_deadSize += delta; } }
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp index 7555efb..5c8f232 100644 --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -269,9 +269,9 @@ clearCopiedImage(); if (layoutObject()) layoutObject()->setMayNeedPaintInvalidation(); + m_dirtyRect.unite(rect); if (m_context && m_context->is2d() && m_context->shouldAntialias() && page() && page()->deviceScaleFactor() > 1.0f) m_dirtyRect.inflate(1); - m_dirtyRect.unite(rect); if (m_context && m_context->is2d() && hasImageBuffer()) buffer()->didDraw(rect); }
diff --git a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp index 470740c6..c39f9fab 100644 --- a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
@@ -393,7 +393,7 @@ VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) const { if (index <= 0) - return createVisiblePosition(Position::firstPositionInNode(innerEditorElement())); + return VisiblePosition::firstPositionInNode(innerEditorElement()); Position start, end; bool selected = Range::selectNodeContents(innerEditorElement(), start, end); if (!selected)
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.h b/third_party/WebKit/Source/core/layout/LayoutBlock.h index 483b1a3..7358ca7 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlock.h +++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h
@@ -384,8 +384,6 @@ virtual void removeLeftoverAnonymousBlock(LayoutBlock* child); - void dirtyLinesFromChangedChild(LayoutObject* child) final { m_lineBoxes.dirtyLinesFromChangedChild(LineLayoutItem(this), LineLayoutItem(child)); } - TrackedLayoutBoxListHashSet* positionedObjectsInternal() const; TrackedLayoutBoxListHashSet* percentHeightDescendantsInternal() const;
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h index 4b47f102..0a2ddd6b 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
@@ -400,6 +400,8 @@ virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG + void dirtyLinesFromChangedChild(LayoutObject* child) final { m_lineBoxes.dirtyLinesFromChangedChild(LineLayoutItem(this), LineLayoutItem(child)); } + bool isPagedOverflow(const ComputedStyle&); enum FlowThreadType {
diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h b/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h index c251d09..c79f3c3 100644 --- a/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h +++ b/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
@@ -68,6 +68,7 @@ DISALLOW_NEW(); public: SVGInlineTextMetricsIterator() { reset(LineLayoutSVGInlineText()); } + explicit SVGInlineTextMetricsIterator(LineLayoutSVGInlineText textLineLayout) { reset(textLineLayout); } void advanceToTextStart(LineLayoutSVGInlineText textLineLayout, unsigned startCharacterOffset) {
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp index f2c8cd5..1d7780c 100644 --- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp +++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp
@@ -19,6 +19,7 @@ #include "core/layout/svg/SVGTextLayoutAttributesBuilder.h" +#include "core/layout/api/LineLayoutSVGInlineText.h" #include "core/layout/svg/LayoutSVGInline.h" #include "core/layout/svg/LayoutSVGInlineText.h" #include "core/layout/svg/LayoutSVGText.h" @@ -33,16 +34,14 @@ SVGCharacterDataMap& characterDataMap = text.characterDataMap(); characterDataMap.clear(); - const Vector<SVGTextMetrics>& metricsList = text.metricsList(); - auto metricsEnd = metricsList.end(); - unsigned currentPosition = 0; - for (auto metrics = metricsList.begin(); metrics != metricsEnd; currentPosition += metrics->length(), ++metrics) { - if (metrics->isEmpty()) + LineLayoutSVGInlineText textLineLayout(&text); + for (SVGInlineTextMetricsIterator iterator(textLineLayout); !iterator.isAtEnd(); iterator.next()) { + if (iterator.metrics().isEmpty()) continue; auto it = allCharactersMap.find(valueListPosition + 1); if (it != allCharactersMap.end()) - characterDataMap.set(currentPosition + 1, it->value); + characterDataMap.set(iterator.characterOffset() + 1, it->value); // Increase the position in the value/attribute list with one for each // "character unit" (that will be displayed.)
diff --git a/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp b/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp index f8ff6279..959527b9 100644 --- a/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp
@@ -188,7 +188,7 @@ ASSERT(document().frame()); // Find selection start - VisiblePosition start = createVisiblePosition(Position::firstPositionInNode(const_cast<SVGTextContentElement*>(this))); + VisiblePosition start = VisiblePosition::firstPositionInNode(const_cast<SVGTextContentElement*>(this)); for (unsigned i = 0; i < charnum; ++i) start = nextPositionOf(start);
diff --git a/third_party/WebKit/Source/platform/heap/asm/BUILD.gn b/third_party/WebKit/Source/platform/heap/asm/BUILD.gn index d3a5e6a..6c87950 100644 --- a/third_party/WebKit/Source/platform/heap/asm/BUILD.gn +++ b/third_party/WebKit/Source/platform/heap/asm/BUILD.gn
@@ -42,6 +42,10 @@ sources = [ "SaveRegisters_mips.S", ] + } else if (current_cpu == "mips64el") { + sources = [ + "SaveRegisters_mips64.S", + ] } if (current_cpu == "arm") {
diff --git a/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp b/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp index ca2b39fe..0792e3d 100644 --- a/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp +++ b/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp
@@ -4,11 +4,38 @@ #include "platform/text/Hyphenation.h" +#include "wtf/RetainPtr.h" +#include "wtf/text/StringView.h" + namespace blink { -PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString&) +class HyphenationCF : public Hyphenation { +public: + HyphenationCF(RetainPtr<CFLocaleRef>& localeCF) + : m_localeCF(localeCF) + { + DCHECK(m_localeCF); + } + + size_t lastHyphenLocation(const StringView& text, size_t beforeIndex) const override + { + CFIndex result = CFStringGetHyphenationLocationBeforeIndex( + text.toString()->createCFString().get(), beforeIndex, + CFRangeMake(0, text.length()), 0, m_localeCF.get(), 0); + return result == kCFNotFound ? 0 : result; + } + +private: + RetainPtr<CFLocaleRef> m_localeCF; +}; + +PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale) { - return nullptr; + RetainPtr<CFStringRef> localeCFString = locale.impl()->createCFString(); + RetainPtr<CFLocaleRef> localeCF = adoptCF(CFLocaleCreate(kCFAllocatorDefault, localeCFString.get())); + if (!CFStringIsHyphenationAvailableForLocale(localeCF.get())) + return nullptr; + return adoptRef(new HyphenationCF(localeCF)); } } // namespace blink
diff --git a/third_party/brotli/README.chromium b/third_party/brotli/README.chromium index 15cb9eb..dde1512 100644 --- a/third_party/brotli/README.chromium +++ b/third_party/brotli/README.chromium
@@ -14,6 +14,8 @@ - This only includes the enc/, dec/ and tools/ directories, the README.md and the LICENSE files, removing unneeded direcories such as docs, tests, and tools. +- Lines 659 of enc/hash.h and 66 of enc/cluster.h were modified to eliminate + build errors that appeared on Windows. - BUILD.gn: Added. - brotli.gyp: Added. - enc/static_dict_lut.h: split up into two files (enc/static_dict_lut.h,
diff --git a/third_party/brotli/enc/cluster.h b/third_party/brotli/enc/cluster.h index 5054faf..28d7c98 100644 --- a/third_party/brotli/enc/cluster.h +++ b/third_party/brotli/enc/cluster.h
@@ -63,7 +63,7 @@ idx1 = t; } bool store_pair = false; - HistogramPair p; + HistogramPair p = {}; p.idx1 = idx1; p.idx2 = idx2; p.cost_diff = 0.5 * ClusterCostDiff(cluster_size[idx1], cluster_size[idx2]);
diff --git a/third_party/brotli/enc/hash.h b/third_party/brotli/enc/hash.h index 8716863b..227be1d 100644 --- a/third_party/brotli/enc/hash.h +++ b/third_party/brotli/enc/hash.h
@@ -656,7 +656,7 @@ void Init(int lgwin, size_t position, size_t bytes, bool is_last) { if (need_init_) { window_mask_ = (1u << lgwin) - 1u; - invalid_pos_ = static_cast<uint32_t>(-window_mask_); + invalid_pos_ = static_cast<uint32_t>(0 - window_mask_); for (uint32_t i = 0; i < kBucketSize; i++) { buckets_[i] = invalid_pos_; }
diff --git a/third_party/libvpx/BUILD.gn b/third_party/libvpx/BUILD.gn index 0ea7345e..cebdb117 100644 --- a/third_party/libvpx/BUILD.gn +++ b/third_party/libvpx/BUILD.gn
@@ -272,7 +272,7 @@ } else { sources = libvpx_srcs_x86_64 } - } else if (current_cpu == "mipsel") { + } else if (current_cpu == "mipsel" || current_cpu == "mips64el") { sources = libvpx_srcs_mips } else if (current_cpu == "arm") { if (arm_use_neon) {
diff --git a/third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h b/third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h index 3a29c3af..dad634c 100644 --- a/third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h +++ b/third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h
@@ -49,15 +49,21 @@ // in debug builds. // LS_WARNING: Something that may warrant investigation. // LS_ERROR: Something that should not have occurred. +// LS_NONE: A level < LS_ERROR, used to disable logging. // Note that LoggingSeverity is mapped over to chromiums verbosity levels where // anything lower than or equal to the current verbosity level is written to // file which is the opposite of logging severity in libjingle where higher // severity numbers than or equal to the current severity level are written to // file. Also, note that the values are explicitly defined here for convenience // since the command line flag must be set using numerical values. +// +// LS_NONE is present so we can LogToDebug(LS_NONE) i.e. for ordinal +// comparisons with other log levels. +// // TODO(tommi): To keep things simple, we should just use the same values for // these constants as Chrome does. -enum LoggingSeverity { LS_ERROR = 1, +enum LoggingSeverity { LS_NONE = 0, + LS_ERROR = 1, LS_WARNING = 2, LS_INFO = 3, LS_VERBOSE = 4, @@ -130,7 +136,7 @@ class LogMessage { public: - static void LogToDebug(int min_sev); + static void LogToDebug(LoggingSeverity min_sev); }; // When possible, pass optional state variable to track various data across
diff --git a/third_party/webrtc_overrides/webrtc/base/logging.cc b/third_party/webrtc_overrides/webrtc/base/logging.cc index db888c1..797dc33 100644 --- a/third_party/webrtc_overrides/webrtc/base/logging.cc +++ b/third_party/webrtc_overrides/webrtc/base/logging.cc
@@ -13,8 +13,10 @@ #include <algorithm> #include <iomanip> +#include <string> #include "base/atomicops.h" +#include "base/command_line.h" #include "base/logging.h" #include "base/strings/string_util.h" #include "base/threading/platform_thread.h" @@ -49,6 +51,16 @@ base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0; #endif +void InitChromiumLoggingAndCommandLine() { + // 0 means no arguments, so the null argv is never touched + base::CommandLine::Init(0, nullptr); + + // Chromium checks for the presence of --v when deciding log level. + // Note that the *value* of --v doesn't matter for this check. + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("v", ""); + logging::InitLogging(logging::LoggingSettings()); +} + ///////////////////////////////////////////////////////////////////////////// // Constant Labels ///////////////////////////////////////////////////////////////////////////// @@ -80,6 +92,10 @@ inline int WebRtcSevToChromeSev(LoggingSeverity sev) { switch (sev) { + case LS_NONE: + // Used to set the log level for "no logging", so must be less + // than LOG_ERROR. + return ::logging::LOG_FATAL; case LS_ERROR: return ::logging::LOG_ERROR; case LS_WARNING: @@ -201,8 +217,8 @@ } // static -void LogMessage::LogToDebug(int min_sev) { - logging::SetMinLogLevel(min_sev); +void LogMessage::LogToDebug(LoggingSeverity min_sev) { + logging::SetMinLogLevel(WebRtcSevToChromeSev(min_sev)); } // Note: this function is a copy from the overriden libjingle implementation.
diff --git a/third_party/webrtc_overrides/webrtc/base/logging.h b/third_party/webrtc_overrides/webrtc/base/logging.h index e9ca47e0..67893926 100644 --- a/third_party/webrtc_overrides/webrtc/base/logging.h +++ b/third_party/webrtc_overrides/webrtc/base/logging.h
@@ -26,6 +26,15 @@ #include "third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h" +// If WebRTC code is built inside Chromium but run standalone, +// Chromium logging will be used but not initialised. This is usually +// OK, but in certain cases we do want that initialisation, so we +// expose it here. For example, you must call this if you want to +// decrease the log level below -1, as done by the libfuzzer fuzzers. +namespace rtc { + void InitChromiumLoggingAndCommandLine(); +} + ////////////////////////////////////////////////////////////////////// // WebRTC macros which in DiagnosticLogMessage are mapped over to // their VLOG equivalent in base/logging.h.
diff --git a/tools/android/loading/analyze.py b/tools/android/loading/analyze.py index 05b0a9d..30305f3 100755 --- a/tools/android/loading/analyze.py +++ b/tools/android/loading/analyze.py
@@ -35,6 +35,7 @@ import options import request_dependencies_lens import request_track +import xvfb_helper # TODO(mattcary): logging.info isn't that useful, as the whole (tools) world # uses logging info; we need to introduce logging modules to get finer-grained @@ -99,9 +100,12 @@ Returns: JSON dict of logged information (ie, a dict that describes JSON). """ + xvfb_process = None if OPTIONS.local: chrome_ctl = controller.LocalChromeController() - chrome_ctl.SetHeadless(OPTIONS.headless) + if OPTIONS.headless: + xvfb_process = xvfb_helper.LaunchXvfb() + chrome_ctl.SetChromeEnvOverride(xvfb_helper.GetChromeEnvironment()) else: chrome_ctl = controller.RemoteChromeController( device_setup.GetFirstDevice()) @@ -117,6 +121,10 @@ connection.ClearCache() trace = loading_trace.LoadingTrace.RecordUrlNavigation( url, connection, chrome_ctl.ChromeMetadata()) + + if xvfb_process: + xvfb_process.terminate() + return trace.ToJsonDict()
diff --git a/tools/android/loading/cloud/backend/clovis_task_handler.py b/tools/android/loading/cloud/backend/clovis_task_handler.py index 5a8be028..ddd07bb2 100644 --- a/tools/android/loading/cloud/backend/clovis_task_handler.py +++ b/tools/android/loading/cloud/backend/clovis_task_handler.py
@@ -46,3 +46,8 @@ clovis_task.Action()) return handler.Run(clovis_task) + + def Finalize(self): + """Called once before the handler is destroyed.""" + for handler in self._handlers.values(): + handler.Finalize()
diff --git a/tools/android/loading/cloud/backend/report_task_handler.py b/tools/android/loading/cloud/backend/report_task_handler.py index ef2335c0..24a891bc 100644 --- a/tools/android/loading/cloud/backend/report_task_handler.py +++ b/tools/android/loading/cloud/backend/report_task_handler.py
@@ -3,6 +3,7 @@ # found in the LICENSE file. import json +import math import uuid from googleapiclient import errors @@ -106,6 +107,10 @@ self._failure_database.AddFailure('big_query_insert_error', str(insert_error.get('errors'))) + def Finalize(self): + """Called once before the handler is destroyed.""" + pass + def Run(self, clovis_task): """Runs a 'report' clovis_task. @@ -131,6 +136,12 @@ self._logger.error('Failed generating report for: ' + path) self._failure_database.AddFailure('report_generation_failed', path) continue + # Filter out bad values. + for key, value in report.items(): + if type(value) is float and (math.isnan(value) or math.isinf(value)): + self._logger.error('Invalid %s for URL:%s' % (key, report.get('url'))) + self._failure_database.AddFailure('invalid_bigquery_value', key) + del report[key] rows.append(report) if rows:
diff --git a/tools/android/loading/cloud/backend/trace_task_handler.py b/tools/android/loading/cloud/backend/trace_task_handler.py index d718ab7..82777ba 100644 --- a/tools/android/loading/cloud/backend/trace_task_handler.py +++ b/tools/android/loading/cloud/backend/trace_task_handler.py
@@ -6,6 +6,7 @@ import os import re import sys +import traceback import common.clovis_paths from common.clovis_task import ClovisTask @@ -14,6 +15,7 @@ from failure_database import FailureDatabase import loading_trace import options +import xvfb_helper class TraceTaskHandler(object): @@ -33,6 +35,7 @@ self._base_path = base_path self._is_initialized = False self._trace_database = None + self._xvfb_process = None trace_database_filename = common.clovis_paths.TRACE_DATABASE_PREFIX if instance_name: trace_database_filename += '_%s.json' % instance_name @@ -49,6 +52,8 @@ return self._is_initialized = True + self._xvfb_process = xvfb_helper.LaunchXvfb() + # Recover any existing traces in case the worker died. self._DownloadTraceDatabase() if self._trace_database.ToJsonDict(): @@ -107,7 +112,7 @@ # Set up the controller. chrome_ctl = controller.LocalChromeController() - chrome_ctl.SetHeadless(True) + chrome_ctl.SetChromeEnvOverride(xvfb_helper.GetChromeEnvironment()) if emulate_device: chrome_ctl.SetDeviceEmulation(emulate_device) if emulate_network: @@ -123,7 +128,8 @@ except controller.ChromeControllerError as e: e.Dump(sys.stderr) except Exception as e: - sys.stderr.write(str(e)) + sys.stderr.write('Unknown exception:\n' + str(e)) + traceback.print_exc(file=sys.stderr) if trace: with open(filename, 'w') as f: @@ -174,6 +180,14 @@ remote_log_location = remote_trace_location + '.log' self._google_storage_accessor.UploadFile(log_filename, remote_log_location) + def Finalize(self): + """Called once before the handler is destroyed.""" + if self._xvfb_process: + try: + self._xvfb_process.terminate() + except OSError: + self._logger.error('Could not terminate Xvfb.') + def Run(self, clovis_task): """Runs a 'trace' clovis_task.
diff --git a/tools/android/loading/cloud/backend/worker.py b/tools/android/loading/cloud/backend/worker.py index e0ebebf..3d44f1e 100644 --- a/tools/android/loading/cloud/backend/worker.py +++ b/tools/android/loading/cloud/backend/worker.py
@@ -174,6 +174,7 @@ def _Finalize(self): """Called before exiting.""" self._logger.info('Done') + self._clovis_task_handler.Finalize() # Upload the worker log. if self._worker_log_path: self._logger.info('Uploading worker log.')
diff --git a/tools/android/loading/controller.py b/tools/android/loading/controller.py index 511685f..7ea59a0e 100644 --- a/tools/android/loading/controller.py +++ b/tools/android/loading/controller.py
@@ -86,8 +86,8 @@ Args: log: String containing the log of the running Chrome instance that was - running. It will be interleaved with xvfb with headless desktop or - interleaved with any other running Android package. + running. It will be interleaved with any other running Android + package. """ self.error_type, self.error_value, self.error_traceback = sys.exc_info() super(ChromeControllerError, self).__init__(repr(self.error_value)) @@ -410,7 +410,7 @@ self._using_temp_profile_dir = self._profile_dir is None if self._using_temp_profile_dir: self._profile_dir = tempfile.mkdtemp(suffix='.profile') - self._headless = False + self._chrome_env_override = None self._metadata['platform'] = { 'os': platform.system()[0] + '-' + platform.release(), 'product_model': 'unknown' @@ -420,13 +420,13 @@ if self._using_temp_profile_dir: shutil.rmtree(self._profile_dir) - def SetHeadless(self, headless=True): - """Set a headless run. + def SetChromeEnvOverride(self, env): + """Set the environment for Chrome. Args: - headless: true if the chrome instance should be headless. + env: (dict) Environment. """ - self._headless = headless + self._chrome_env_override = env @contextlib.contextmanager def Open(self): @@ -445,19 +445,10 @@ tempfile.NamedTemporaryFile(prefix="chrome_controller_", suffix='.log') chrome_process = None try: - chrome_env_override = {} + chrome_env_override = self._chrome_env_override or {} if self._wpr_attributes: chrome_env_override.update(self._wpr_attributes.chrome_env_override) - if self._headless: - assert 'DISPLAY' not in chrome_env_override, \ - 'DISPLAY environment variable is reserved for headless.' - chrome_env_override['DISPLAY'] = 'localhost:99' - xvfb_cmd = ['Xvfb', ':99', '-screen', '0', '1600x1200x24'] - logging.info(common_util.GetCommandLineForLogging(xvfb_cmd)) - xvfb_process = \ - subprocess.Popen(xvfb_cmd, stdout=tmp_log.file, stderr=tmp_log.file) - chrome_env = os.environ.copy() chrome_env.update(chrome_env_override) @@ -500,8 +491,6 @@ del tmp_log if chrome_process: chrome_process.kill() - if self._headless: - xvfb_process.kill() def ResetBrowserState(self): """Override for chrome state reseting."""
diff --git a/tools/android/loading/dependency_graph.py b/tools/android/loading/dependency_graph.py index da55ad2..a2c1f17 100644 --- a/tools/android/loading/dependency_graph.py +++ b/tools/android/loading/dependency_graph.py
@@ -129,6 +129,18 @@ else: return self._deps_graph.Cost(path_list=path_list, costs_out=costs_out) + def AncestorRequests(self, descendants): + """Return requests that are ancestors of a set of requests. + + Args: + descendants: ([Request]) List of requests. + + Returns: + List of Requests that are ancestors of descendants. + """ + return [n.request for n in self.graph.AncestorNodes( + self._nodes_by_id[r.request_id] for r in descendants)] + def _HandleTimingDependencies(self): try: for n in self._deps_graph.TopologicalSort():
diff --git a/tools/android/loading/graph.py b/tools/android/loading/graph.py index 7c2d275..23c4ef8d 100644 --- a/tools/android/loading/graph.py +++ b/tools/android/loading/graph.py
@@ -161,18 +161,23 @@ should_stop: (callable) Returns True when a node should stop the exploration and be skipped. """ - visited = set() - fifo = collections.deque([n for n in roots if not should_stop(n)]) - while len(fifo) != 0: - node = fifo.pop() - if should_stop(node): - continue - visited.add(node) - for e in self.OutEdges(node): - if e.to_node not in visited and not should_stop(e.to_node): - visited.add(e.to_node) - fifo.appendleft(e.to_node) - return list(visited) + return self._ExploreFrom( + roots, lambda n: (e.to_node for e in self.OutEdges(n)), + should_stop=should_stop) + + def AncestorNodes(self, descendants): + """Returns a set of nodes that are ancestors of a set of nodes. + + This is not quite the opposite of ReachableNodes, because (in a tree) it + will not include |descendants|. + + Args: + descendants: ([Node]) List of nodes to start from. + + """ + return set(self._ExploreFrom( + descendants, + lambda n: (e.from_node for e in self.InEdges(n)))) - set(descendants) def Cost(self, roots=None, path_list=None, costs_out=None): """Compute the cost of the graph. @@ -246,3 +251,26 @@ edges.append(edge) result = DirectedGraph(index_to_node.values(), edges) return result + + def _ExploreFrom(self, initial, expand, should_stop=lambda n: False): + """Explore from a set of nodes. + + Args: + initial: ([Node]) List of nodes to start from. + expand: (callable) Given a node, return an iterator of nodes to explore + from that node. + should_stop: (callable) Returns True when a node should stop the + exploration and be skipped. + """ + visited = set() + fifo = collections.deque([n for n in initial if not should_stop(n)]) + while fifo: + node = fifo.pop() + if should_stop(node): + continue + visited.add(node) + for n in expand(node): + if n not in visited and not should_stop(n): + visited.add(n) + fifo.appendleft(n) + return list(visited)
diff --git a/tools/android/loading/graph_unittest.py b/tools/android/loading/graph_unittest.py index e0e5f5b9..28e9e21 100644 --- a/tools/android/loading/graph_unittest.py +++ b/tools/android/loading/graph_unittest.py
@@ -143,6 +143,36 @@ set([6]), set(n.index for n in g.ReachableNodes([nodes[6]]))) + def testAncestorNodes(self, serialize=False): + (nodes, _, g) = self.MakeGraph( + 7, + [(0, 1), + (0, 2), + (1, 3), + (3, 4), + (5, 6)], serialize) + self.assertSetEqual( + set([0, 1, 3]), + set(n.index for n in g.AncestorNodes([nodes[4]]))) + self.assertSetEqual( + set([0, 1]), + set(n.index for n in g.AncestorNodes([nodes[3]]))) + self.assertSetEqual( + set([0]), + set(n.index for n in g.AncestorNodes([nodes[1]]))) + self.assertSetEqual( + set(), + set(n.index for n in g.AncestorNodes([nodes[0]]))) + self.assertSetEqual( + set([0]), + set(n.index for n in g.AncestorNodes([nodes[2]]))) + self.assertSetEqual( + set([5]), + set(n.index for n in g.AncestorNodes([nodes[6]]))) + self.assertSetEqual( + set(), + set(n.index for n in g.AncestorNodes([nodes[5]]))) + def testCost(self, serialize=False): (nodes, edges, g) = self.MakeGraph( 7,
diff --git a/tools/android/loading/loading_graph_view.py b/tools/android/loading/loading_graph_view.py index c312af0..67c993c 100644 --- a/tools/android/loading/loading_graph_view.py +++ b/tools/android/loading/loading_graph_view.py
@@ -5,6 +5,7 @@ """Views a trace as an annotated request dependency graph.""" import dependency_graph +import request_dependencies_lens class RequestNode(dependency_graph.RequestNode): @@ -52,6 +53,11 @@ self._graph = None self._BuildGraph() + @classmethod + def FromTrace(cls, trace): + """Create a graph from a trace with no additional annotation.""" + return cls(trace, request_dependencies_lens.RequestDependencyLens(trace)) + def RemoveAds(self): """Updates the graph to remove the Ads. @@ -62,6 +68,34 @@ roots, should_stop=lambda n: n.is_ad or n.is_tracking)] self._BuildGraph() + def GetInversionsAtTime(self, msec): + """Return the inversions, if any for an event. + + An inversion is when a node is finished before an event, but an ancestor is + not finished. For example, an image is loaded before a first paint, but the + HTML which requested the image has not finished loading at the time of the + paint due to incremental parsing. + + Args: + msec: the time of the event, from the same base as requests. + + Returns: + The inverted Requests, ordered by start time, or None if there is no + inversion. + """ + completed_requests = [] + for rq in self._requests: + if rq.end_msec <= msec: + completed_requests.append(rq) + inversions = [] + for rq in self._graph.AncestorRequests(completed_requests): + if rq.end_msec > msec: + inversions.append(rq) + if inversions: + inversions.sort(key=lambda rq: rq.start_msec) + return inversions + return None + @property def deps_graph(self): return self._graph
diff --git a/tools/android/loading/loading_graph_view_unittest.py b/tools/android/loading/loading_graph_view_unittest.py index b1a93c0..d134d8e 100644 --- a/tools/android/loading/loading_graph_view_unittest.py +++ b/tools/android/loading/loading_graph_view_unittest.py
@@ -79,6 +79,29 @@ [TestRequests.FIRST_REDIRECT_REQUEST.request_id]) self.assertSetEqual(expected_request_ids, request_ids) + def testEventInversion(self): + self._UpdateRequestTiming({ + '1234.redirect.1': (0, 0), + '1234.redirect.2': (0, 0), + '1234.1': (10, 100), + '1234.12': (20, 50), + '1234.42': (40, 70), + '1234.56': (40, 150)}) + graph_view = loading_graph_view.LoadingGraphView( + self.trace, self.deps_lens) + self.assertEqual(None, graph_view.GetInversionsAtTime(40)) + self.assertEqual('1234.1', graph_view.GetInversionsAtTime(60)[0].request_id) + self.assertEqual('1234.1', graph_view.GetInversionsAtTime(80)[0].request_id) + self.assertEqual(None, graph_view.GetInversionsAtTime(110)) + self.assertEqual(None, graph_view.GetInversionsAtTime(160)) + + def _UpdateRequestTiming(self, changes): + for rq in self.trace.request_track.GetEvents(): + if rq.request_id in changes: + start_msec, end_msec = changes[rq.request_id] + rq.timing.request_time = float(start_msec) / 1000 + rq.timing.loading_finished = end_msec - start_msec + if __name__ == '__main__': unittest.main()
diff --git a/tools/android/loading/report.py b/tools/android/loading/report.py index 50fedd4..b74658f4 100644 --- a/tools/android/loading/report.py +++ b/tools/android/loading/report.py
@@ -7,6 +7,7 @@ When executed as a script, takes a trace filename and print the report. """ +from loading_graph_view import LoadingGraphView import loading_trace from network_activity_lens import NetworkActivityLens from user_satisfied_lens import ( @@ -31,11 +32,7 @@ 'blink.user_timing', 'navigationStart') self._navigation_start_msec = min( e.start_msec for e in navigation_start_events) - # TODO(lizeb): This is not PLT. Should correlate with - # RenderFrameImpl::didStopLoading. - self._max_msec = max( - r.end_msec or -1 for r in self.trace.request_track.GetEvents()) - + self._load_end_msec = self._ComputePlt(trace) network_lens = NetworkActivityLens(self.trace) if network_lens.total_download_bytes > 0: self._contentful_byte_frac = ( @@ -48,6 +45,12 @@ self._contentful_byte_frac = float('Nan') self._significant_byte_frac = float('Nan') + graph = LoadingGraphView.FromTrace(trace) + self._contentful_inversion = graph.GetInversionsAtTime( + self._contentful_paint_msec) + self._significant_inversion = graph.GetInversionsAtTime( + self._significant_paint_msec) + def GenerateReport(self): """Returns a report as a dict.""" return { @@ -57,9 +60,18 @@ - self._navigation_start_msec), 'significant_paint_ms': (self._significant_paint_msec - self._navigation_start_msec), - 'plt_ms': self._max_msec - self._navigation_start_msec, + 'plt_ms': self._load_end_msec - self._navigation_start_msec, 'contentful_byte_frac': self._contentful_byte_frac, - 'significant_byte_frac': self._significant_byte_frac,} + 'significant_byte_frac': self._significant_byte_frac, + + # Take the first (earliest) inversions. + 'contentful_inversion': (self._contentful_inversion[0].url + if self._contentful_inversion + else None), + 'significant_inversion': (self._significant_inversion[0].url + if self._significant_inversion + else None) + } @classmethod def FromTraceFilename(cls, filename): @@ -67,6 +79,19 @@ trace = loading_trace.LoadingTrace.FromJsonFile(filename) return LoadingReport(trace) + @classmethod + def _ComputePlt(cls, trace): + mark_load_events = trace.tracing_track.GetMatchingEvents( + 'devtools.timeline', 'MarkLoad') + # Some traces contain several load events for the main frame. + main_frame_load_events = filter( + lambda e: e.args['data']['isMainFrame'], mark_load_events) + if main_frame_load_events: + return max(e.start_msec for e in main_frame_load_events) + # Main frame onLoad() didn't finish. Take the end of the last completed + # request. + return max(r.end_msec or -1 for r in trace.request_track.GetEvents()) + if __name__ == '__main__': import sys
diff --git a/tools/android/loading/report_unittest.py b/tools/android/loading/report_unittest.py index d5b2304..cdb6a8d6 100644 --- a/tools/android/loading/report_unittest.py +++ b/tools/android/loading/report_unittest.py
@@ -18,40 +18,49 @@ _SIGNIFICANT_PAINT = 50 _DURATION = 400 _REQUEST_OFFSET = 5 + _LOAD_END_TIME = 1280 + _MAIN_FRAME_ID = 1 - @classmethod - def _MakeTrace(cls): - trace_creator = test_utils.TraceCreator() - requests = [trace_creator.RequestAt(cls._FIRST_REQUEST_TIME), - trace_creator.RequestAt( - cls._NAVIGATION_START_TIME + cls._REQUEST_OFFSET, - cls._DURATION)] - requests[0].timing.receive_headers_end = 0 - requests[1].timing.receive_headers_end = 0 - requests[0].encoded_data_length = 128 - requests[1].encoded_data_length = 1024 - trace = trace_creator.CreateTrace( - requests, - [{'ts': cls._NAVIGATION_START_TIME * cls.MILLI_TO_MICRO, 'ph': 'R', - 'cat': 'blink.user_timing', - 'name': 'navigationStart', - 'args': {'frame': 1}}, - {'ts': cls._CONTENTFUL_PAINT * cls.MILLI_TO_MICRO, 'ph': 'I', - 'cat': 'blink.user_timing', - 'name': 'firstContentfulPaint', - 'args': {'frame': 1}}, - {'ts': cls._TEXT_PAINT * cls.MILLI_TO_MICRO, 'ph': 'I', - 'cat': 'blink.user_timing', - 'name': 'firstPaint', - 'args': {'frame': 1}}, - {'ts': 90 * cls.MILLI_TO_MICRO, 'ph': 'I', - 'cat': 'blink', - 'name': 'FrameView::synchronizedPaint'}, - {'ts': cls._SIGNIFICANT_PAINT * cls.MILLI_TO_MICRO, 'ph': 'I', - 'cat': 'foobar', 'name': 'biz', - 'args': {'counters': { - 'LayoutObjectsThatHadNeverHadLayout': 10 - }}}], 1) + def setUp(self): + self.trace_creator = test_utils.TraceCreator() + self.requests = [self.trace_creator.RequestAt(self._FIRST_REQUEST_TIME), + self.trace_creator.RequestAt( + self._NAVIGATION_START_TIME + self._REQUEST_OFFSET, + self._DURATION)] + self.requests[0].timing.receive_headers_end = 0 + self.requests[1].timing.receive_headers_end = 0 + self.requests[0].encoded_data_length = 128 + self.requests[1].encoded_data_length = 1024 + + self.trace_events = [ + {'ts': self._NAVIGATION_START_TIME * self.MILLI_TO_MICRO, 'ph': 'R', + 'cat': 'blink.user_timing', + 'name': 'navigationStart', + 'args': {'frame': 1}}, + {'ts': self._LOAD_END_TIME * self.MILLI_TO_MICRO, 'ph': 'I', + 'cat': 'devtools.timeline', + 'name': 'MarkLoad', + 'args': {'data': {'isMainFrame': True}}}, + {'ts': self._CONTENTFUL_PAINT * self.MILLI_TO_MICRO, 'ph': 'I', + 'cat': 'blink.user_timing', + 'name': 'firstContentfulPaint', + 'args': {'frame': self._MAIN_FRAME_ID}}, + {'ts': self._TEXT_PAINT * self.MILLI_TO_MICRO, 'ph': 'I', + 'cat': 'blink.user_timing', + 'name': 'firstPaint', + 'args': {'frame': self._MAIN_FRAME_ID}}, + {'ts': 90 * self.MILLI_TO_MICRO, 'ph': 'I', + 'cat': 'blink', + 'name': 'FrameView::synchronizedPaint'}, + {'ts': self._SIGNIFICANT_PAINT * self.MILLI_TO_MICRO, 'ph': 'I', + 'cat': 'foobar', 'name': 'biz', + 'args': {'counters': { + 'LayoutObjectsThatHadNeverHadLayout': 10 + }}}] + + def _MakeTrace(self): + trace = self.trace_creator.CreateTrace( + self.requests, self.trace_events, self._MAIN_FRAME_ID) return trace def testGenerateReport(self): @@ -64,10 +73,38 @@ loading_report['significant_paint_ms']) self.assertEqual(self._CONTENTFUL_PAINT - self._NAVIGATION_START_TIME, loading_report['contentful_paint_ms']) - self.assertEqual(self._REQUEST_OFFSET + self._DURATION, - loading_report['plt_ms']) - self.assertAlmostEqual(0.34, loading_report['contentful_byte_frac']) - self.assertAlmostEqual(0.184, loading_report['significant_byte_frac'], 2) + self.assertAlmostEqual(self._LOAD_END_TIME - self._NAVIGATION_START_TIME, + loading_report['plt_ms']) + self.assertAlmostEqual(0.34, loading_report['contentful_byte_frac'], 2) + self.assertAlmostEqual(0.1844, loading_report['significant_byte_frac'], 2) + self.assertEqual(None, loading_report['contentful_inversion']) + self.assertEqual(None, loading_report['significant_inversion']) + + def testInversion(self): + self.requests[0].timing.loading_finished = 4 * ( + self._REQUEST_OFFSET + self._DURATION) + self.requests[1].initiator['type'] = 'parser' + self.requests[1].initiator['url'] = self.requests[0].url + for e in self.trace_events: + if e['name'] == 'firstContentfulPaint': + e['ts'] = self.MILLI_TO_MICRO * ( + self._FIRST_REQUEST_TIME + self._REQUEST_OFFSET + + self._DURATION + 1) + break + loading_report = report.LoadingReport(self._MakeTrace()).GenerateReport() + self.assertEqual(self.requests[0].url, + loading_report['contentful_inversion']) + self.assertEqual(None, loading_report['significant_inversion']) + + def testPltNoLoadEvents(self): + trace = self._MakeTrace() + # Change the MarkLoad events. + for e in trace.tracing_track.GetEvents(): + if e.name == 'MarkLoad': + e.tracing_event['name'] = 'dummy' + loading_report = report.LoadingReport(trace).GenerateReport() + self.assertAlmostEqual(self._REQUEST_OFFSET + self._DURATION, + loading_report['plt_ms']) if __name__ == '__main__':
diff --git a/tools/android/loading/request_dependencies_lens_unittest.py b/tools/android/loading/request_dependencies_lens_unittest.py index 67ab3f5c..bf2d858 100644 --- a/tools/android/loading/request_dependencies_lens_unittest.py +++ b/tools/android/loading/request_dependencies_lens_unittest.py
@@ -72,6 +72,15 @@ @classmethod def CreateLoadingTrace(cls, trace_events=None): + # This creates a set of requests with the following dependency structure. + # + # 1234.redirect.1 -> 1234.redirect.2 + # 1234.redirect.2 -> 1234.1 + # 1234.1 -> 1234.12 + # 1234.1 -> 1234.42 + # 1234.1 -> 1234.56 + # 1234.12 -> 1234.13 + trace = test_utils.LoadingTraceFromEvents( [cls.FIRST_REDIRECT_REQUEST, cls.SECOND_REDIRECT_REQUEST, cls.REDIRECTED_REQUEST, cls.REQUEST, cls.JS_REQUEST, cls.JS_REQUEST_2,
diff --git a/tools/android/loading/xvfb_helper.py b/tools/android/loading/xvfb_helper.py new file mode 100644 index 0000000..4939e76 --- /dev/null +++ b/tools/android/loading/xvfb_helper.py
@@ -0,0 +1,19 @@ +# 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 os +import subprocess + + +def LaunchXvfb(): + """Launches Xvfb for running Chrome in headless mode, and returns the + subprocess.""" + xvfb_cmd = ['Xvfb', ':99', '-screen', '0', '1600x1200x24'] + return subprocess.Popen(xvfb_cmd, stdout=open(os.devnull, 'wb'), + stderr=subprocess.STDOUT) + + +def GetChromeEnvironment(): + """Returns the environment for Chrome to run in headless mode with Xvfb.""" + return {'DISPLAY': 'localhost:99'}
diff --git a/tools/checklicenses/checklicenses.py b/tools/checklicenses/checklicenses.py index 80c9615f..94611a90 100755 --- a/tools/checklicenses/checklicenses.py +++ b/tools/checklicenses/checklicenses.py
@@ -145,10 +145,10 @@ 'chrome/common/extensions/docs/server2/third_party': [ 'UNKNOWN', ], - 'courgette/third_party/bsdiff_create.cc': [ # http://crbug.com/98095 + 'courgette/third_party/bsdiff/bsdiff_create.cc': [ # http://crbug.com/98095 'UNKNOWN', ], - 'courgette/third_party/qsufsort.h': [ # http://crbug.com/98095 + 'courgette/third_party/bsdiff/qsufsort.h': [ # http://crbug.com/98095 'UNKNOWN', ], 'native_client': [ # http://crbug.com/98099
diff --git a/tools/gdb/gdb_chrome.py b/tools/gdb/gdb_chrome.py index dc65149..9d72743 100644 --- a/tools/gdb/gdb_chrome.py +++ b/tools/gdb/gdb_chrome.py
@@ -211,7 +211,7 @@ class TimeTicksPrinter(TimeDeltaPrinter): def __init__(self, val): - self._timedelta = datetime.timedelta(microseconds=int(val['ticks_'])) + self._timedelta = datetime.timedelta(microseconds=int(val['us_'])) pp_set.add_printer('base::TimeTicks', '^base::TimeTicks$', TimeTicksPrinter)
diff --git a/tools/include_tracer.py b/tools/include_tracer.py index 567a797..30061d79 100755 --- a/tools/include_tracer.py +++ b/tools/include_tracer.py
@@ -112,7 +112,6 @@ 'third_party/WebKit/Source/public', 'third_party/WebKit/Source/web', 'third_party/WebKit/Source/wtf', - 'third_party/cld', 'third_party/google_toolbox_for_mac/src', 'third_party/icu/public/common', 'third_party/icu/public/i18n',
diff --git a/tools/perf/benchmarks/page_cycler_v2.py b/tools/perf/benchmarks/page_cycler_v2.py new file mode 100644 index 0000000..f6654e99 --- /dev/null +++ b/tools/perf/benchmarks/page_cycler_v2.py
@@ -0,0 +1,43 @@ +# 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. + +"""The page cycler v2. + +For details, see design doc: +https://docs.google.com/document/d/1EZQX-x3eEphXupiX-Hq7T4Afju5_sIdxPWYetj7ynd0 +""" + +from core import perf_benchmark +import page_sets + +from telemetry.page import cache_temperature +from telemetry.timeline import tracing_category_filter +from telemetry.web_perf import timeline_based_measurement + +class _PageCyclerV2(perf_benchmark.PerfBenchmark): + def CreateTimelineBasedMeasurementOptions(self): + cat_filter = tracing_category_filter.TracingCategoryFilter( + filter_string='*,blink.console,navigation,blink.user_timing,loading') + + tbm_options = timeline_based_measurement.Options( + overhead_level=cat_filter) + tbm_options.SetTimelineBasedMetric('firstPaintMetric') + return tbm_options + +class PageCyclerTypical25(_PageCyclerV2): + """Page load time benchmark for a 25 typical web pages. + + Designed to represent typical, not highly optimized or highly popular web + sites. Runs against pages recorded in June, 2014. + """ + options = {'pageset_repeat': 3} + + @classmethod + def Name(cls): + return 'page_cycler_v2.typical_25' + + def CreateStorySet(self, options): + return page_sets.Typical25PageSet(run_no_page_interactions=True, + cache_temperatures=[ + cache_temperature.PCV1_COLD, cache_temperature.PCV1_WARM])
diff --git a/tools/perf/benchmarks/smoothness.py b/tools/perf/benchmarks/smoothness.py index 0891977..66dd4fce 100644 --- a/tools/perf/benchmarks/smoothness.py +++ b/tools/perf/benchmarks/smoothness.py
@@ -94,6 +94,7 @@ @benchmark.Disabled('android') # crbug.com/373812 +@benchmark.Disabled('win-reference') # crbug.com/612810 class SmoothnessToughWebGLCases(_Smoothness): page_set = page_sets.ToughWebglCasesPageSet
diff --git a/tools/perf/benchmarks/tab_switching.py b/tools/perf/benchmarks/tab_switching.py index 2b063f9..2cd77df 100644 --- a/tools/perf/benchmarks/tab_switching.py +++ b/tools/perf/benchmarks/tab_switching.py
@@ -28,6 +28,7 @@ @benchmark.Enabled('has tabs') +@benchmark.Disabled('mac-reference') # http://crbug.com/612774 @benchmark.Disabled('android') # http://crbug.com/460084 class TabSwitchingTypical25(perf_benchmark.PerfBenchmark): """This test records the MPArch.RWH_TabSwitchPaintDuration histogram.
diff --git a/tools/perf/page_sets/typical_25.py b/tools/perf/page_sets/typical_25.py index f871ede..8f056c1 100644 --- a/tools/perf/page_sets/typical_25.py +++ b/tools/perf/page_sets/typical_25.py
@@ -6,6 +6,7 @@ from profile_creators import profile_generator from telemetry.page import page as page_module +from telemetry.page import cache_temperature as cache_temperature_module from telemetry.page import shared_page_state from telemetry import story @@ -39,10 +40,12 @@ class Typical25Page(page_module.Page): def __init__(self, url, page_set, run_no_page_interactions, - shared_page_state_class=shared_page_state.SharedDesktopPageState): + shared_page_state_class=shared_page_state.SharedDesktopPageState, + cache_temperature=None): super(Typical25Page, self).__init__( url=url, page_set=page_set, - shared_page_state_class=shared_page_state_class) + shared_page_state_class=shared_page_state_class, + cache_temperature=cache_temperature) self._run_no_page_interactions = run_no_page_interactions def RunPageInteractions(self, action_runner): @@ -57,10 +60,13 @@ """ Pages designed to represent the median, not highly optimized web """ def __init__(self, run_no_page_interactions=False, - page_class=Typical25Page): + page_class=Typical25Page, + cache_temperatures=None): super(Typical25PageSet, self).__init__( archive_data_file='data/typical_25.json', cloud_storage_bucket=story.PARTNER_BUCKET) + if cache_temperatures is None: + cache_temperatures = [cache_temperature_module.ANY] urls_list = [ # Why: Alexa games #48 @@ -104,5 +110,6 @@ ] for url in urls_list: - self.AddStory( - page_class(url, self, run_no_page_interactions)) + for temp in cache_temperatures: + self.AddStory(page_class( + url, self, run_no_page_interactions, cache_temperature=temp))
diff --git a/ui/accessibility/platform/atk_util_auralinux.cc b/ui/accessibility/platform/atk_util_auralinux.cc index 98e98dff..46ad3be 100644 --- a/ui/accessibility/platform/atk_util_auralinux.cc +++ b/ui/accessibility/platform/atk_util_auralinux.cc
@@ -53,45 +53,7 @@ const char kGnomeAccessibilityEnabledKey[] = "/desktop/gnome/interface/accessibility"; -bool PlatformShouldEnableAccessibility() { - GConfClient* client = gconf_client_get_default(); - if (!client) { - LOG(ERROR) << "gconf_client_get_default failed"; - return false; - } - - GError* error = nullptr; - gboolean value = gconf_client_get_bool(client, - kGnomeAccessibilityEnabledKey, - &error); - g_object_unref(client); - - if (error) { - VLOG(1) << "gconf_client_get_bool failed"; - g_error_free(error); - return false; - } - - return value; -} - -#else // !defined(USE_GCONF) - -bool PlatformShouldEnableAccessibility() { - // TODO(iceman): implement this for non-GNOME desktops. - return false; -} - -#endif // defined(USE_GCONF) - -bool ShouldEnableAccessibility() { - char* enable_accessibility = getenv(kAccessibilityEnabled); - if ((enable_accessibility && atoi(enable_accessibility) == 1) || - PlatformShouldEnableAccessibility()) - return true; - - return false; -} +#endif } // namespace @@ -199,9 +161,6 @@ // Register our util class. g_type_class_unref(g_type_class_ref(ATK_UTIL_AURALINUX_TYPE)); - if (!ShouldEnableAccessibility()) - return; - init_task_runner->PostTaskAndReply( FROM_HERE, base::Bind( @@ -218,7 +177,33 @@ #if defined(USE_GCONF) void AtkUtilAuraLinux::CheckIfAccessibilityIsEnabledOnFileThread() { - is_enabled_ = AccessibilityModuleInitOnFileThread(); + char* enable_accessibility = getenv(kAccessibilityEnabled); + if ((enable_accessibility && atoi(enable_accessibility) == 1) || + CheckPlatformAccessibilitySupportOnFileThread()) + is_enabled_ = AccessibilityModuleInitOnFileThread(); +} + +bool AtkUtilAuraLinux::CheckPlatformAccessibilitySupportOnFileThread() { + GConfClient* client = gconf_client_get_default(); + if (!client) { + LOG(ERROR) << "gconf_client_get_default failed"; + return false; + } + + GError* error = nullptr; + bool is_enabled = gconf_client_get_bool(client, + kGnomeAccessibilityEnabledKey, + &error); + + g_object_unref(client); + + if (error) { + VLOG(1) << "gconf_client_get_bool failed"; + g_error_free(error); + return false; + } + + return is_enabled; } void AtkUtilAuraLinux::FinishAccessibilityInitOnUIThread() {
diff --git a/ui/accessibility/platform/atk_util_auralinux.h b/ui/accessibility/platform/atk_util_auralinux.h index f609109e..8342a129 100644 --- a/ui/accessibility/platform/atk_util_auralinux.h +++ b/ui/accessibility/platform/atk_util_auralinux.h
@@ -31,6 +31,7 @@ friend struct base::DefaultSingletonTraits<AtkUtilAuraLinux>; void CheckIfAccessibilityIsEnabledOnFileThread(); + bool CheckPlatformAccessibilitySupportOnFileThread(); void FinishAccessibilityInitOnUIThread(); #if defined(USE_GCONF)
diff --git a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java index 239315d..4b80797 100644 --- a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java +++ b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
@@ -17,7 +17,6 @@ import android.os.Build; import android.os.Handler; import android.os.Process; -import android.preference.PreferenceManager; import android.text.TextUtils; import android.util.SparseArray; import android.view.View; @@ -25,6 +24,7 @@ import org.chromium.base.ActivityState; import org.chromium.base.ApplicationStatus; import org.chromium.base.Callback; +import org.chromium.base.ContextUtils; import org.chromium.ui.UiUtils; import java.lang.ref.WeakReference; @@ -211,8 +211,7 @@ Activity activity = getActivity().get(); assert activity != null; - SharedPreferences.Editor editor = - PreferenceManager.getDefaultSharedPreferences(activity).edit(); + SharedPreferences.Editor editor = ContextUtils.getAppSharedPreferences().edit(); for (int i = 0; i < permissions.length; i++) { editor.putBoolean(getHasRequestedPermissionKey(permissions[i]), true); } @@ -282,7 +281,7 @@ // Check whether we have ever asked for this permission by checking whether we saved // a preference associated with it before. String permissionQueriedKey = getHasRequestedPermissionKey(permission); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); + SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); if (!prefs.getBoolean(permissionQueriedKey, false)) return true; return false;
diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc index 1c91acf..9f9288d5 100644 --- a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc +++ b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
@@ -72,7 +72,10 @@ size_t map_size = stride_ * size_.height(); data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED, dmabuf_fd, 0); - CHECK_NE(data_, MAP_FAILED); + if (data_ == MAP_FAILED) { + PLOG(ERROR) << "Failed mmap()."; + base::TerminateBecauseOutOfMemory(map_size); + } } ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
diff --git a/ui/views/mus/views_mus_test_suite.cc b/ui/views/mus/views_mus_test_suite.cc index 6373735f..2919115d 100644 --- a/ui/views/mus/views_mus_test_suite.cc +++ b/ui/views/mus/views_mus_test_suite.cc
@@ -42,7 +42,12 @@ class PlatformTestHelperMus : public PlatformTestHelper { public: - PlatformTestHelperMus() {} + PlatformTestHelperMus() { + ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( + &WindowManagerConnection::CreateNativeWidgetMus, + base::Unretained(WindowManagerConnection::Get()), + std::map<std::string, std::vector<uint8_t>>())); + } ~PlatformTestHelperMus() override {} private: