diff --git a/DEPS b/DEPS index 71b198fc..cfa4438 100644 --- a/DEPS +++ b/DEPS
@@ -130,7 +130,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '09fc536c66c644ad0ec55b8048d5efe11e4af7c7', + 'catapult_revision': 'a9cf2fa54a3334ff6834e0598c782156e0b3d364', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -318,7 +318,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '873be6fd45b7e0eee2d9d46e3a3c348a553c05d9', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '9c02a833e207d457f7ccc8175b930b4cb8bf687f', # DevTools node modules. Used on Linux buildbots only. 'src/third_party/devtools-node-modules': {
diff --git a/ash/fast_ink/fast_ink_view.cc b/ash/fast_ink/fast_ink_view.cc index cb681a1..69c55cb 100644 --- a/ash/fast_ink/fast_ink_view.cc +++ b/ash/fast_ink/fast_ink_view.cc
@@ -406,7 +406,8 @@ gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gles2->GenMailboxCHROMIUM(resource->mailbox.name); - gles2->ProduceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.name); + gles2->ProduceTextureDirectCHROMIUM(resource->texture, + resource->mailbox.name); } gfx::Size buffer_size = gpu_memory_buffer_->GetSize();
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index 52055e5..aa9b13f 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc
@@ -598,10 +598,11 @@ if (result.output_snippet.length() > kOutputSnippetBytesLimit) { if (result.status == TestResult::TEST_SUCCESS) result.status = TestResult::TEST_EXCESSIVE_OUTPUT; - result.output_snippet = StringPrintf( - "<truncated (%" PRIuS " bytes)>\n", result.output_snippet.length()) + - result.output_snippet.substr( - result.output_snippet.length() - kOutputSnippetLinesLimit) + + result.output_snippet = + StringPrintf("<truncated (%" PRIuS " bytes)>\n", + result.output_snippet.length()) + + result.output_snippet.substr(result.output_snippet.length() - + kOutputSnippetBytesLimit) + "\n"; }
diff --git a/cc/resources/display_resource_provider.cc b/cc/resources/display_resource_provider.cc index c989fb6..04209ae 100644 --- a/cc/resources/display_resource_provider.cc +++ b/cc/resources/display_resource_provider.cc
@@ -413,8 +413,8 @@ GLES2Interface* gl = ContextGL(); DCHECK(gl); - resource->gl_id = gl->CreateAndConsumeTextureCHROMIUM( - resource->target, resource->mailbox.name); + resource->gl_id = + gl->CreateAndConsumeTextureCHROMIUM(resource->mailbox.name); resource->SetLocallyUsed(); }
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 98434f8..630fbb6 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc
@@ -699,7 +699,7 @@ gpu::gles2::GLES2Interface* gl = resource_provider_->ContextGL(); DCHECK(gl); gl->GenMailboxCHROMIUM(mailbox_.name); - gl->ProduceTextureDirectCHROMIUM(texture_id_, target_, mailbox_.name); + gl->ProduceTextureDirectCHROMIUM(texture_id_, mailbox_.name); } GLuint ResourceProvider::ScopedWriteLockGL::ConsumeTexture( @@ -707,8 +707,7 @@ DCHECK(gl); DCHECK(!mailbox_.IsZero()); - GLuint texture_id = - gl->CreateAndConsumeTextureCHROMIUM(target_, mailbox_.name); + GLuint texture_id = gl->CreateAndConsumeTextureCHROMIUM(mailbox_.name); DCHECK(texture_id); LazyAllocate(gl, texture_id); @@ -932,8 +931,7 @@ gpu::gles2::GLES2Interface* gl = ContextGL(); DCHECK(gl); gl->GenMailboxCHROMIUM(resource->mailbox.name); - gl->ProduceTextureDirectCHROMIUM(resource->gl_id, resource->target, - resource->mailbox.name); + gl->ProduceTextureDirectCHROMIUM(resource->gl_id, resource->mailbox.name); resource->SetLocallyUsed(); }
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index e60a3e1..39c3214ed 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc
@@ -109,10 +109,10 @@ MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); - MOCK_METHOD3(produceTextureDirectCHROMIUM, - void(GLuint texture, GLenum target, const GLbyte* mailbox)); - MOCK_METHOD2(createAndConsumeTextureCHROMIUM, - unsigned(GLenum target, const GLbyte* mailbox)); + MOCK_METHOD2(produceTextureDirectCHROMIUM, + void(GLuint texture, const GLbyte* mailbox)); + MOCK_METHOD1(createAndConsumeTextureCHROMIUM, + unsigned(const GLbyte* mailbox)); // Force all textures to be consecutive numbers starting at "1", // so we easily can test for them. @@ -209,7 +209,7 @@ gpu::CommandBufferId::FromUnsafeValue(0x123), fence_sync); sync_token_data.SetVerifyFlush(); - // Commit the produceTextureCHROMIUM calls at this point, so that + // Commit the ProduceTextureDirectCHROMIUM calls at this point, so that // they're associated with the sync point. for (const std::unique_ptr<PendingProduceTexture>& pending_texture : pending_produce_textures_) { @@ -302,7 +302,6 @@ } void produceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) override { // Delay moving the texture into the mailbox until the next // sync token, so that it is not visible to other contexts that @@ -314,8 +313,7 @@ pending_produce_textures_.push_back(std::move(pending)); } - GLuint createAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) override { + GLuint createAndConsumeTextureCHROMIUM(const GLbyte* mailbox) override { GLuint texture_id = createTexture(); base::AutoLock lock_for_texture_access(namespace_->lock); scoped_refptr<TestTexture> texture = @@ -488,8 +486,7 @@ unsigned texture = child_context_->createTexture(); gpu::Mailbox gpu_mailbox; child_context_->genMailboxCHROMIUM(gpu_mailbox.name); - child_context_->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, - gpu_mailbox.name); + child_context_->produceTextureDirectCHROMIUM(texture, gpu_mailbox.name); child_context_->genSyncToken(child_context_->insertFenceSync(), sync_token->GetData()); EXPECT_TRUE(sync_token->HasData()); @@ -869,8 +866,8 @@ gpu::Mailbox external_mailbox; child_context_->genMailboxCHROMIUM(external_mailbox.name); - child_context_->produceTextureDirectCHROMIUM( - external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); + child_context_->produceTextureDirectCHROMIUM(external_texture_id, + external_mailbox.name); gpu::SyncToken external_sync_token; child_context_->genSyncToken(child_context_->insertFenceSync(), external_sync_token.GetData()); @@ -997,8 +994,8 @@ // A sync point is specified directly and should be used. gpu::Mailbox external_mailbox; child_context_->genMailboxCHROMIUM(external_mailbox.name); - child_context_->produceTextureDirectCHROMIUM( - external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); + child_context_->produceTextureDirectCHROMIUM(external_texture_id, + external_mailbox.name); gpu::SyncToken external_sync_token; child_context_->genSyncToken(child_context_->insertFenceSync(), external_sync_token.GetData()); @@ -1898,8 +1895,7 @@ resource_ids_to_transfer.push_back(id); std::vector<viz::TransferableResource> list; - EXPECT_CALL(*child_context, - produceTextureDirectCHROMIUM(_, GL_TEXTURE_2D, _)); + EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _)); child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, &list); @@ -1908,8 +1904,7 @@ ASSERT_EQ(1u, list.size()); EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter); - EXPECT_CALL(*parent_context, - createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) + EXPECT_CALL(*parent_context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(parent_texture_id)); parent_resource_provider->ReceiveFromChild(child_id, list); @@ -1983,7 +1978,7 @@ GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); gpu::Mailbox mailbox; context()->genMailboxCHROMIUM(mailbox.name); - context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name); + context()->produceTextureDirectCHROMIUM(texture, mailbox.name); gpu::SyncToken sync_token; context()->genSyncToken(context()->insertFenceSync(), sync_token.GetData()); EXPECT_TRUE(sync_token.HasData()); @@ -2019,13 +2014,12 @@ context()->waitSyncToken(list[0].mailbox_holder.sync_token.GetConstData()); unsigned other_texture = - context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + context()->createAndConsumeTextureCHROMIUM(mailbox.name); uint8_t test_data[4] = { 0 }; context()->GetPixels(gfx::Size(1, 1), viz::RGBA_8888, test_data); EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); - context()->produceTextureDirectCHROMIUM(other_texture, GL_TEXTURE_2D, - mailbox.name); + context()->produceTextureDirectCHROMIUM(other_texture, mailbox.name); context()->deleteTexture(other_texture); context()->genSyncToken(context()->insertFenceSync(), list[0].mailbox_holder.sync_token.GetData()); @@ -2075,13 +2069,12 @@ context()->waitSyncToken(list[0].mailbox_holder.sync_token.GetConstData()); unsigned other_texture = - context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + context()->createAndConsumeTextureCHROMIUM(mailbox.name); uint8_t test_data[4] = { 0 }; context()->GetPixels(gfx::Size(1, 1), viz::RGBA_8888, test_data); EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); - context()->produceTextureDirectCHROMIUM(other_texture, GL_TEXTURE_2D, - mailbox.name); + context()->produceTextureDirectCHROMIUM(other_texture, mailbox.name); context()->deleteTexture(other_texture); context()->genSyncToken(context()->insertFenceSync(), list[0].mailbox_holder.sync_token.GetData()); @@ -2103,8 +2096,7 @@ } context()->waitSyncToken(release_sync_token.GetConstData()); - texture = - context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + texture = context()->createAndConsumeTextureCHROMIUM(mailbox.name); context()->deleteTexture(texture); } @@ -2598,13 +2590,12 @@ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); - unsigned target = GL_TEXTURE_2D; const GLuint64 current_fence_sync = child_context->GetNextFenceSync(); EXPECT_CALL(*child_context, bindTexture(_, _)).Times(0); EXPECT_CALL(*child_context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); - EXPECT_CALL(*child_context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*child_context, createAndConsumeTextureCHROMIUM(_)).Times(0); gpu::Mailbox gpu_mailbox; memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); @@ -2615,8 +2606,8 @@ base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource)); GLuint filter = mailbox_nearest_neighbor ? GL_NEAREST : GL_LINEAR; - auto resource = viz::TransferableResource::MakeGL(gpu_mailbox, filter, - target, sync_token); + auto resource = viz::TransferableResource::MakeGL( + gpu_mailbox, filter, GL_TEXTURE_2D, sync_token); viz::ResourceId resource_id = child_resource_provider->ImportResource(resource, std::move(callback)); @@ -2652,11 +2643,11 @@ resource_provider->WaitSyncToken(mapped_resource_id); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)) + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(texture_id)); - EXPECT_CALL(*context, bindTexture(target, texture_id)); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); // The sampler will reset these if |mailbox_nearest_neighbor| does not // match |sampler_filter|. @@ -2675,12 +2666,10 @@ // When done with it, a sync point should be inserted, but no produce is // necessary. EXPECT_CALL(*child_context, bindTexture(_, _)).Times(0); - EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _, _)) - .Times(0); + EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _)).Times(0); EXPECT_CALL(*child_context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*child_context, createAndConsumeTextureCHROMIUM(_, _)) - .Times(0); + EXPECT_CALL(*child_context, createAndConsumeTextureCHROMIUM(_)).Times(0); } EXPECT_EQ(0u, returned_to_child.size()); @@ -2765,20 +2754,19 @@ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); const GLuint64 current_fence_sync = child_context->GetNextFenceSync(); - unsigned target = GL_TEXTURE_EXTERNAL_OES; EXPECT_CALL(*child_context, bindTexture(_, _)).Times(0); EXPECT_CALL(*child_context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); - EXPECT_CALL(*child_context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*child_context, produceTextureDirectCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*child_context, createAndConsumeTextureCHROMIUM(_)).Times(0); gpu::Mailbox gpu_mailbox; memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); std::unique_ptr<viz::SingleReleaseCallback> callback = viz::SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); - auto resource = viz::TransferableResource::MakeGL(gpu_mailbox, GL_LINEAR, - target, sync_token); + auto resource = viz::TransferableResource::MakeGL( + gpu_mailbox, GL_LINEAR, GL_TEXTURE_EXTERNAL_OES, sync_token); viz::ResourceId resource_id = child_resource_provider->ImportResource(resource, std::move(callback)); @@ -2817,10 +2805,10 @@ unsigned texture_id = 1; - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)) + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(texture_id)); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); DisplayResourceProvider::ScopedReadLockGL lock(resource_provider.get(), mapped_resource_id); @@ -2829,10 +2817,10 @@ // When done with it, a sync point should be inserted, but no produce is // necessary. EXPECT_CALL(*context, bindTexture(_, _)).Times(0); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); EXPECT_CALL(*context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)).Times(0); Mock::VerifyAndClearExpectations(context); } EXPECT_EQ(0u, returned_to_child.size()); @@ -2863,12 +2851,11 @@ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); const GLuint64 current_fence_sync = context->GetNextFenceSync(); - unsigned target = GL_TEXTURE_2D; EXPECT_CALL(*context, bindTexture(_, _)).Times(0); EXPECT_CALL(*context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)).Times(0); // Receive a resource from the child. std::vector<viz::ReturnedResource> returned; @@ -2885,8 +2872,8 @@ for (int i = 0; i < 100; ++i) { gpu::Mailbox gpu_mailbox; memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); - auto resource = viz::TransferableResource::MakeGL(gpu_mailbox, GL_LINEAR, - target, sync_token); + auto resource = viz::TransferableResource::MakeGL( + gpu_mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token); resource.id = i; resource_provider->ReceiveFromChild(child, {resource}); auto& map = resource_provider->GetChildToParentMap(child); @@ -2924,8 +2911,8 @@ EXPECT_CALL(*context, bindTexture(_, _)).Times(0); EXPECT_CALL(*context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)).Times(0); viz::ResourceId id = MakeGpuResourceAndSendToDisplay( 'a', GL_LINEAR, GL_TEXTURE_2D, sync_token, resource_provider.get()); @@ -2967,8 +2954,8 @@ EXPECT_CALL(*context, bindTexture(_, _)).Times(0); EXPECT_CALL(*context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)).Times(0); viz::ResourceId id = MakeGpuResourceAndSendToDisplay( 'h', GL_LINEAR, GL_TEXTURE_2D, sync_token, resource_provider.get()); @@ -3003,8 +2990,8 @@ EXPECT_CALL(*context, bindTexture(_, _)).Times(0); EXPECT_CALL(*context, waitSyncToken(_)).Times(0); - EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _)).Times(0); + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)).Times(0); auto resource = viz::TransferableResource::MakeGL( gpu::Mailbox::Generate(), GL_LINEAR, GL_TEXTURE_2D, gpu::SyncToken()); @@ -3533,12 +3520,11 @@ ResourceProvider::ScopedWriteLockGL lock(resource_provider.get(), id); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, - produceTextureDirectCHROMIUM(kTextureId, GL_TEXTURE_2D, _)); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(kTextureId, _)); lock.CreateMailbox(); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(kWorkerTextureId)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kWorkerTextureId)); EXPECT_CALL(*context, texImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format), @@ -3559,7 +3545,7 @@ lock.CreateMailbox(); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(kWorkerTextureId)); EXPECT_EQ(kWorkerTextureId, lock.ConsumeTexture(context_provider->ContextGL())); @@ -3619,12 +3605,11 @@ ResourceProvider::ScopedWriteLockGL lock(resource_provider.get(), id); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, - produceTextureDirectCHROMIUM(kTextureId, GL_TEXTURE_2D, _)); + EXPECT_CALL(*context, produceTextureDirectCHROMIUM(kTextureId, _)); lock.CreateMailbox(); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(kWorkerTextureId)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kWorkerTextureId)); EXPECT_CALL(*context, texStorage2DImageCHROMIUM(GL_TEXTURE_2D, GL_RGBA8_OES, @@ -3645,7 +3630,7 @@ lock.CreateMailbox(); Mock::VerifyAndClearExpectations(context); - EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) + EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_)) .WillOnce(Return(kWorkerTextureId)); EXPECT_EQ(kWorkerTextureId, lock.ConsumeTexture(context_provider->ContextGL()));
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc index 8799963c..ad2dd560 100644 --- a/cc/resources/video_resource_updater.cc +++ b/cc/resources/video_resource_updater.cc
@@ -272,7 +272,6 @@ ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id); gl->ProduceTextureDirectCHROMIUM( lock.GetTexture(), - resource_provider_->GetResourceTextureTarget(resource_id), mailbox.name); } all_resources_.push_front( @@ -835,8 +834,8 @@ gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); - uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM( - mailbox_holder.texture_target, mailbox_holder.mailbox.name); + uint32_t src_texture_id = + gl->CreateAndConsumeTextureCHROMIUM(mailbox_holder.mailbox.name); gl->CopySubTextureCHROMIUM( src_texture_id, 0, GL_TEXTURE_2D, lock.GetTexture(), 0, 0, 0, 0, 0, output_plane_resource_size.width(), output_plane_resource_size.height(),
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 68c48f3..11c9484d 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc
@@ -239,8 +239,7 @@ if (sync_token.HasData()) gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); - GLuint texture_id = - gl->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint texture_id = gl->CreateAndConsumeTextureCHROMIUM(mailbox.name); GLuint fbo = 0; gl->GenFramebuffers(1, &fbo);
diff --git a/cc/test/test_gles2_interface.cc b/cc/test/test_gles2_interface.cc index 29a0aed..1ff09cc 100644 --- a/cc/test/test_gles2_interface.cc +++ b/cc/test/test_gles2_interface.cc
@@ -355,21 +355,14 @@ test_context_->genMailboxCHROMIUM(mailbox); } -void TestGLES2Interface::ProduceTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) { - test_context_->produceTextureCHROMIUM(target, mailbox); -} - void TestGLES2Interface::ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) { - test_context_->produceTextureDirectCHROMIUM(texture, target, mailbox); + test_context_->produceTextureDirectCHROMIUM(texture, mailbox); } GLuint TestGLES2Interface::CreateAndConsumeTextureCHROMIUM( - GLenum target, const GLbyte* mailbox) { - return test_context_->createAndConsumeTextureCHROMIUM(target, mailbox); + return test_context_->createAndConsumeTextureCHROMIUM(mailbox); } void TestGLES2Interface::ResizeCHROMIUM(GLuint width,
diff --git a/cc/test/test_gles2_interface.h b/cc/test/test_gles2_interface.h index bcaae230..7231d19 100644 --- a/cc/test/test_gles2_interface.h +++ b/cc/test/test_gles2_interface.h
@@ -148,12 +148,9 @@ GLsizei count, const GLenum* attachments) override; void GenMailboxCHROMIUM(GLbyte* mailbox) override; - void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override; void ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) override; - GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) override; + GLuint CreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox) override; void ResizeCHROMIUM(GLuint width, GLuint height,
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc index deb573e..db85788b 100644 --- a/cc/test/test_web_graphics_context_3d.cc +++ b/cc/test/test_web_graphics_context_3d.cc
@@ -477,7 +477,6 @@ } GLuint TestWebGraphicsContext3D::createAndConsumeTextureCHROMIUM( - GLenum target, const GLbyte* mailbox) { return createTexture(); }
diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h index 6fab5680..f0286c5 100644 --- a/cc/test/test_web_graphics_context_3d.h +++ b/cc/test/test_web_graphics_context_3d.h
@@ -192,12 +192,9 @@ const void* pixels) {} virtual void genMailboxCHROMIUM(GLbyte* mailbox); - virtual void produceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) {} virtual void produceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) {} - virtual GLuint createAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox); + virtual GLuint createAndConsumeTextureCHROMIUM(const GLbyte* mailbox); virtual void loseContextCHROMIUM(GLenum current, GLenum other);
diff --git a/chrome/android/java/res/layout/download_item_view.xml b/chrome/android/java/res/layout/download_item_view.xml index 27e9ba99..90eb962 100644 --- a/chrome/android/java/res/layout/download_item_view.xml +++ b/chrome/android/java/res/layout/download_item_view.xml
@@ -37,6 +37,8 @@ android:layout_below="@+id/filename_completed_view" /> </RelativeLayout> + <include layout="@layout/list_menu_button" /> + <!-- Shown for downloads that haven't been completed. --> <RelativeLayout android:id="@+id/progress_layout" @@ -109,6 +111,7 @@ android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:padding="8dp" + android:paddingEnd="@dimen/selectable_list_layout_row_padding" android:background="?attr/selectableItemBackground" android:contentDescription="@string/download_notification_cancel_button" android:src="@drawable/btn_close"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/BackendProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/BackendProvider.java index 90b49d95..88a3dd5 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/BackendProvider.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/BackendProvider.java
@@ -42,6 +42,24 @@ void updateLastAccessTime(String downloadGuid, boolean isOffTheRecord); } + /** + * Processes actions from the UI that require front end management before hitting the backend. + * This should eventually get merged into a proper delegate with other UI actions, but currently + * that is not possible. + */ + public static interface UIDelegate { + /** + * Requests that {@code item} be deleted. This might not hit the backend quiet yet if the + * user can undo the action. + */ + void deleteItem(DownloadHistoryItemWrapper item); + + /** + * Requests that {@code item} be shared. + */ + void shareItem(DownloadHistoryItemWrapper item); + } + /** Returns the {@link DownloadDelegate} that works with the Downloads backend. */ DownloadDelegate getDownloadDelegate(); @@ -54,6 +72,9 @@ /** Returns the {@link SelectionDelegate} that tracks selected items. */ SelectionDelegate<DownloadHistoryItemWrapper> getSelectionDelegate(); + /** Returns the {@link UIDelegate} responsible for handling download system UI events. */ + UIDelegate getUIDelegate(); + /** Destroys the BackendProvider. */ void destroy(); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java index 3b330dd3..462ea36e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
@@ -263,7 +263,7 @@ if (wrapper.hasBeenExternallyRemoved()) { sDeletedFileTracker.add(wrapper); - wrapper.remove(); + wrapper.removePermanently(); mFilePathsToItemsMap.removeItem(wrapper); RecordUserAction.record("Android.DownloadManager.Item.ExternallyDeleted"); return true;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java index 3d005bb..0ec3d19d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
@@ -111,6 +111,26 @@ return filter == getFilterType() || filter == DownloadFilter.FILTER_ALL; } + /** Called when this download should be shared. */ + void share() { + mBackendProvider.getUIDelegate().shareItem(this); + } + + /** + * Starts the delete process, which may or may not immediately delete the item or bring up a UI + * surface first. + */ + void startRemove() { + mBackendProvider.getUIDelegate().deleteItem(this); + } + + /** + * @return Whether or not this item can be interacted with or not. This will change based on + * the current selection state of the owning list. */ + boolean isInteractive() { + return !mBackendProvider.getSelectionDelegate().isSelectionEnabled(); + } + /** @return Item that is being wrapped. */ abstract Object getItem(); @@ -197,7 +217,7 @@ * * @return Whether the file associated with the download item was deleted. */ - abstract boolean remove(); + abstract boolean removePermanently(); protected void recordOpenSuccess() { RecordUserAction.record("Android.DownloadManager.Item.OpenSucceeded"); @@ -362,7 +382,7 @@ } @Override - public boolean remove() { + public boolean removePermanently() { // Tell the DownloadManager to remove the file from history. mBackendProvider.getDownloadDelegate().removeDownload(getId(), isOffTheRecord()); mBackendProvider.getThumbnailProvider().removeThumbnailsFromDisk(getId()); @@ -552,7 +572,7 @@ } @Override - public boolean remove() { + public boolean removePermanently() { getOfflineContentProvider().removeItem(mItem.id); return true; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemView.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemView.java index 8a1a300..15cfbd7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemView.java
@@ -22,6 +22,8 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.download.DownloadUtils; import org.chromium.chrome.browser.util.FeatureUtilities; +import org.chromium.chrome.browser.widget.ListMenuButton; +import org.chromium.chrome.browser.widget.ListMenuButton.Item; import org.chromium.chrome.browser.widget.MaterialProgressBar; import org.chromium.chrome.browser.widget.ThumbnailProvider; import org.chromium.chrome.browser.widget.TintedImageButton; @@ -29,13 +31,14 @@ import org.chromium.components.offline_items_collection.OfflineItem.Progress; import org.chromium.ui.UiUtils; +import java.util.List; import java.util.Locale; /** * The view for a downloaded item displayed in the Downloads list. */ public class DownloadItemView extends SelectableItemView<DownloadHistoryItemWrapper> - implements ThumbnailProvider.ThumbnailRequest { + implements ThumbnailProvider.ThumbnailRequest, ListMenuButton.Delegate { private final int mMargin; private final int mMarginSubsection; private final int mIconBackgroundColor; @@ -57,6 +60,7 @@ private View mLayoutCompleted; private TextView mFilenameCompletedView; private TextView mDescriptionCompletedView; + private ListMenuButton mMoreButton; // Controls for in-progress downloads. private View mLayoutInProgress; @@ -93,6 +97,22 @@ } } + // ListMenuButton.Delegate implementation. + @Override + public Item[] getItems() { + return new Item[] {new Item(getContext(), R.string.share, true), + new Item(getContext(), R.string.delete, true)}; + } + + @Override + public void onItemSelected(Item item) { + if (item.getTextId() == R.string.share) { + mItem.share(); + } else if (item.getTextId() == R.string.delete) { + mItem.startRemove(); + } + } + @Override protected void onFinishInflate() { super.onFinishInflate(); @@ -104,6 +124,7 @@ mFilenameCompletedView = (TextView) findViewById(R.id.filename_completed_view); mDescriptionCompletedView = (TextView) findViewById(R.id.description_view); + mMoreButton = (ListMenuButton) findViewById(R.id.more); mFilenameInProgressView = (TextView) findViewById(R.id.filename_progress_view); mDownloadStatusView = (TextView) findViewById(R.id.status_view); @@ -112,22 +133,15 @@ mPauseResumeButton = (TintedImageButton) findViewById(R.id.pause_button); mCancelButton = findViewById(R.id.cancel_button); - mPauseResumeButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (mItem.isPaused()) { - mItem.resume(); - } else if (!mItem.isComplete()) { - mItem.pause(); - } + mMoreButton.setDelegate(this); + mPauseResumeButton.setOnClickListener(view -> { + if (mItem.isPaused()) { + mItem.resume(); + } else if (!mItem.isComplete()) { + mItem.pause(); } }); - mCancelButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - mItem.cancel(); - } - }); + mCancelButton.setOnClickListener(view -> mItem.cancel()); } @Override @@ -199,6 +213,7 @@ if (item.isComplete()) { showLayout(mLayoutCompleted); + mMoreButton.setVisibility(View.VISIBLE); } else { showLayout(mLayoutInProgress); mDownloadStatusView.setText(item.getStatusString()); @@ -235,6 +250,7 @@ ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) mDownloadPercentageView.getLayoutParams(), mMargin); } + mMoreButton.setVisibility(View.GONE); } setLongClickable(item.isComplete()); @@ -249,6 +265,12 @@ } @Override + public void onSelectionStateChange(List<DownloadHistoryItemWrapper> selectedItems) { + super.onSelectionStateChange(selectedItems); + mMoreButton.setClickable(mItem.isInteractive()); + } + + @Override public void onClick() { if (mItem != null && mItem.isComplete()) mItem.open(); } @@ -310,6 +332,10 @@ new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); params.weight = 1; mLayoutContainer.addView(layoutToShow, params); + + // Move the menu button to the back of mLayoutContainer. + mLayoutContainer.removeView(mMoreButton); + mLayoutContainer.addView(mMoreButton); } } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java index 72819e4a..715106f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java
@@ -17,6 +17,7 @@ import android.view.ViewGroup; import android.widget.TextView; +import org.chromium.base.CollectionUtil; import org.chromium.base.DiscardableReferencePool; import org.chromium.base.FileUtils; import org.chromium.base.ObserverList; @@ -56,7 +57,8 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegate, - SelectableBottomSheetContentManager<DownloadHistoryItemWrapper> { + SelectableBottomSheetContentManager<DownloadHistoryItemWrapper>, + BackendProvider.UIDelegate { /** * Interface to observe the changes in the download manager ui. This should be implemented by * the ui components that is shown, in order to let them get proper notifications. @@ -74,14 +76,17 @@ } private static class DownloadBackendProvider implements BackendProvider { - private SelectionDelegate<DownloadHistoryItemWrapper> mSelectionDelegate; + private final SelectionDelegate<DownloadHistoryItemWrapper> mSelectionDelegate; + private final UIDelegate mUIDelegate; private ThumbnailProvider mThumbnailProvider; - DownloadBackendProvider(DiscardableReferencePool referencePool) { + DownloadBackendProvider(DiscardableReferencePool referencePool, UIDelegate uiDelegate) { mSelectionDelegate = new DownloadItemSelectionDelegate(); mThumbnailProvider = new ThumbnailProviderImpl(referencePool); + mUIDelegate = uiDelegate; } + // BackendProvider implementation. @Override public DownloadDelegate getDownloadDelegate() { return DownloadManagerService.getDownloadManagerService(); @@ -104,6 +109,11 @@ } @Override + public UIDelegate getUIDelegate() { + return mUIDelegate; + } + + @Override public void destroy() { mThumbnailProvider.destroy(); mThumbnailProvider = null; @@ -134,7 +144,7 @@ // is called. Determine which files are not deleted by the #remove() call. for (int i = 0; i < items.size(); i++) { DownloadHistoryItemWrapper wrappedItem = items.get(i); - if (!wrappedItem.remove()) filesToDelete.add(wrappedItem.getFile()); + if (!wrappedItem.removePermanently()) filesToDelete.add(wrappedItem.getFile()); } // Delete the files associated with the download items (if necessary) using a single @@ -190,7 +200,7 @@ mActivity = activity; ChromeApplication application = (ChromeApplication) activity.getApplication(); mBackendProvider = sProviderForTests == null - ? new DownloadBackendProvider(application.getReferencePool()) + ? new DownloadBackendProvider(application.getReferencePool(), this) : sProviderForTests; mSnackbarManager = snackbarManager; @@ -251,6 +261,17 @@ mNativePage = delegate; } + // BackendProvider.UIDelegate implementation. + @Override + public void deleteItem(DownloadHistoryItemWrapper item) { + deleteItems(CollectionUtil.newArrayList(item)); + } + + @Override + public void shareItem(DownloadHistoryItemWrapper item) { + startShareIntent(DownloadUtils.createShareIntent(CollectionUtil.newArrayList(item))); + } + /** * Called when the bottom sheet content/activity/native page is destroyed. */ @@ -315,10 +336,19 @@ mActivity.finish(); return true; } else if (item.getItemId() == R.id.selection_mode_delete_menu_id) { - deleteSelectedItems(); + List<DownloadHistoryItemWrapper> items = + mBackendProvider.getSelectionDelegate().getSelectedItems(); + mBackendProvider.getSelectionDelegate().clearSelection(); + deleteItems(items); return true; } else if (item.getItemId() == R.id.selection_mode_share_menu_id) { - shareSelectedItems(); + List<DownloadHistoryItemWrapper> items = + mBackendProvider.getSelectionDelegate().getSelectedItems(); + // TODO(twellington): ideally the intent chooser would be started with + // startActivityForResult() and the selection would only be cleared + // after receiving an OK response. See crbug.com/638916. + mBackendProvider.getSelectionDelegate().clearSelection(); + startShareIntent(DownloadUtils.createShareIntent(items)); return true; } else if (item.getItemId() == R.id.info_menu_id) { enableStorageInfoHeader(!mHistoryAdapter.shouldShowStorageInfoHeader()); @@ -392,20 +422,6 @@ mHistoryAdapter.onEndSearch(); } - private void shareSelectedItems() { - List<DownloadHistoryItemWrapper> selectedItems = - mBackendProvider.getSelectionDelegate().getSelectedItems(); - assert selectedItems.size() > 0; - - mActivity.startActivity(Intent.createChooser(createShareIntent(), - mActivity.getString(R.string.share_link_chooser_title))); - - // TODO(twellington): ideally the intent chooser would be started with - // startActivityForResult() and the selection would only be cleared after - // receiving an OK response. See crbug.com/638916. - mBackendProvider.getSelectionDelegate().clearSelection(); - } - private void enableStorageInfoHeader(boolean show) { // Finish any running or pending animations right away. if (mRecyclerView.getItemAnimator() != null) { @@ -416,30 +432,33 @@ mToolbar.updateInfoMenuItem(true, show); } - /** - * @return An Intent to share the selected items. - */ - @VisibleForTesting - public Intent createShareIntent() { - List<DownloadHistoryItemWrapper> selectedItems = - mBackendProvider.getSelectionDelegate().getSelectedItems(); - return DownloadUtils.createShareIntent(selectedItems); + private void startShareIntent(Intent intent) { + mActivity.startActivity(Intent.createChooser( + intent, mActivity.getString(R.string.share_link_chooser_title))); } - private void deleteSelectedItems() { - List<DownloadHistoryItemWrapper> selectedItems = - mBackendProvider.getSelectionDelegate().getSelectedItems(); - final List<DownloadHistoryItemWrapper> itemsToDelete = getItemsForDeletion(); + private void deleteItems(List<DownloadHistoryItemWrapper> items) { + // Build a full list of items to remove for the selected items. + List<DownloadHistoryItemWrapper> itemsToDelete = new ArrayList<>(); - mBackendProvider.getSelectionDelegate().clearSelection(); + Set<String> filePathsToRemove = new HashSet<>(); + CollectionUtil.forEach(items, item -> { + if (!filePathsToRemove.contains(item.getFilePath())) { + Set<DownloadHistoryItemWrapper> itemsForFilePath = + mHistoryAdapter.getItemsForFilePath(item.getFilePath()); + if (itemsForFilePath != null) itemsToDelete.addAll(itemsForFilePath); + filePathsToRemove.add(item.getFilePath()); + } + }); if (itemsToDelete.isEmpty()) return; mHistoryAdapter.markItemsForDeletion(itemsToDelete); - boolean singleItemDeleted = selectedItems.size() == 1; - String snackbarText = singleItemDeleted ? selectedItems.get(0).getDisplayFileName() : - String.format(Locale.getDefault(), "%d", selectedItems.size()); + boolean singleItemDeleted = items.size() == 1; + String snackbarText = singleItemDeleted + ? items.get(0).getDisplayFileName() + : String.format(Locale.getDefault(), "%d", items.size()); int snackbarTemplateId = singleItemDeleted ? R.string.undo_bar_delete_message : R.string.undo_bar_multiple_downloads_delete_message; @@ -451,26 +470,6 @@ mSnackbarManager.showSnackbar(snackbar); } - private List<DownloadHistoryItemWrapper> getItemsForDeletion() { - List<DownloadHistoryItemWrapper> selectedItems = - mBackendProvider.getSelectionDelegate().getSelectedItems(); - List<DownloadHistoryItemWrapper> itemsToRemove = new ArrayList<>(); - Set<String> filePathsToRemove = new HashSet<>(); - - for (DownloadHistoryItemWrapper item : selectedItems) { - if (!filePathsToRemove.contains(item.getFilePath())) { - Set<DownloadHistoryItemWrapper> itemsForFilePath = - mHistoryAdapter.getItemsForFilePath(item.getFilePath()); - if (itemsForFilePath != null) { - itemsToRemove.addAll(itemsForFilePath); - } - filePathsToRemove.add(item.getFilePath()); - } - } - - return itemsToRemove; - } - private void dismissUndoDeletionSnackbars() { mSnackbarManager.dismissSnackbars(mUndoDeletionSnackbarController); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionDataUseItem.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionDataUseItem.java index d0fee60..b46d5b7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionDataUseItem.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionDataUseItem.java
@@ -5,7 +5,8 @@ package org.chromium.chrome.browser.preferences.datareduction; import android.content.Context; -import android.text.format.Formatter; + +import org.chromium.chrome.browser.util.FileSizeUtil; /** * Stores the data used and saved by a hostname. @@ -61,8 +62,8 @@ * @param context An Android context. * @return A formatted string of the data used. */ - public String getFormattedDataUsed(Context context) { - return Formatter.formatFileSize(context, mDataUsed); + public CharSequence getFormattedDataUsed(Context context) { + return FileSizeUtil.formatFileSize(context, mDataUsed); } /** @@ -72,8 +73,7 @@ * @param context An Android context. * @return A formatted string of the data saved. */ - public String getFormattedDataSaved(Context context) { - if (mDataUsed > mOriginalSize) return Formatter.formatFileSize(context, 0); - return Formatter.formatFileSize(context, mOriginalSize - mDataUsed); + public CharSequence getFormattedDataSaved(Context context) { + return FileSizeUtil.formatFileSize(context, Math.max(0, mOriginalSize - mDataUsed)); } } \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java index 809d72fa..fbc2cac 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java
@@ -15,7 +15,6 @@ import android.preference.Preference; import android.support.v7.app.AlertDialog; import android.text.format.DateUtils; -import android.text.format.Formatter; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; @@ -29,6 +28,7 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; +import org.chromium.chrome.browser.util.FileSizeUtil; import org.chromium.third_party.android.datausagechart.ChartDataUsageView; import org.chromium.third_party.android.datausagechart.NetworkStats; import org.chromium.third_party.android.datausagechart.NetworkStatsHistory; @@ -64,9 +64,9 @@ private long mLeftPosition; private long mRightPosition; private Long mCurrentTime; - private String mOriginalTotalPhrase; - private String mSavingsTotalPhrase; - private String mReceivedTotalPhrase; + private CharSequence mOriginalTotalPhrase; + private CharSequence mSavingsTotalPhrase; + private CharSequence mReceivedTotalPhrase; private String mPercentReductionPhrase; private String mStartDatePhrase; private String mEndDatePhrase; @@ -292,12 +292,11 @@ final Context context = getContext(); final long compressedTotalBytes = mReceivedNetworkStatsHistory.getTotalBytes(); - mReceivedTotalPhrase = Formatter.formatFileSize(context, compressedTotalBytes); - + mReceivedTotalPhrase = FileSizeUtil.formatFileSize(context, compressedTotalBytes); final long originalTotalBytes = mOriginalNetworkStatsHistory.getTotalBytes(); - mOriginalTotalPhrase = Formatter.formatFileSize(context, originalTotalBytes); - mSavingsTotalPhrase = - Formatter.formatFileSize(context, originalTotalBytes - compressedTotalBytes); + mOriginalTotalPhrase = FileSizeUtil.formatFileSize(context, originalTotalBytes); + final long savingsTotalBytes = originalTotalBytes - compressedTotalBytes; + mSavingsTotalPhrase = FileSizeUtil.formatFileSize(context, savingsTotalBytes); float percentage = 0.0f; if (originalTotalBytes > 0L && originalTotalBytes > compressedTotalBytes) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/FileSizeUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/util/FileSizeUtil.java new file mode 100644 index 0000000..6009e6fe --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/util/FileSizeUtil.java
@@ -0,0 +1,41 @@ +// Copyright 2017 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. + +package org.chromium.chrome.browser.util; + +import android.annotation.TargetApi; +import android.content.Context; +import android.os.Build; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.format.Formatter; +import android.text.style.TtsSpan; + +/** + * Helper functions for file size info that is shown to the user. + */ +public class FileSizeUtil { + /** + * Formats the file size and also sets TtsSpans of type TYPE_MEASURE so that "B" is announced + * as "byte" by the TTS engine. + * @see Formatter.formatFileSize + */ + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + public static CharSequence formatFileSize(Context context, long bytes) { + String phrase = Formatter.formatFileSize(context, bytes); + // For some languages TTS does not speak "B" as "bytes", so the text is wrapped with a span. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + // Only add spans for numbers which will be displayed as bytes. KB, MB etc are spoken + // correctly by the TTS. + if (bytes / 1024 < 1) { + TtsSpan ttsSpan = + new TtsSpan.MeasureBuilder().setNumber(bytes).setUnit("byte").build(); + Spannable phraseSpannable = new SpannableString(phrase); + phraseSpannable.setSpan(ttsSpan, 0, phraseSpannable.length(), 0); + return phraseSpannable; + } + } + return phrase; + } +} \ No newline at end of file
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni index 64258db5..8792d5b 100644 --- a/chrome/android/java_sources.gni +++ b/chrome/android/java_sources.gni
@@ -1230,6 +1230,7 @@ "java/src/org/chromium/chrome/browser/util/ColorUtils.java", "java/src/org/chromium/chrome/browser/util/ConversionUtils.java", "java/src/org/chromium/chrome/browser/util/FeatureUtilities.java", + "java/src/org/chromium/chrome/browser/util/FileSizeUtil.java", "java/src/org/chromium/chrome/browser/util/HashUtil.java", "java/src/org/chromium/chrome/browser/util/IntentUtils.java", "java/src/org/chromium/chrome/browser/util/KeyNavigationUtil.java",
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadActivityTest.java index 9ae60bb..1402ad3 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadActivityTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadActivityTest.java
@@ -419,7 +419,8 @@ // Select an image, download item #6. toggleItemSelection(2); - Intent shareIntent = mUi.createShareIntent(); + Intent shareIntent = DownloadUtils.createShareIntent( + mUi.getBackendProvider().getSelectionDelegate().getSelectedItems()); Assert.assertEquals("Incorrect intent action", Intent.ACTION_SEND, shareIntent.getAction()); Assert.assertEquals("Incorrect intent mime type", "image/png", shareIntent.getType()); Assert.assertNotNull( @@ -433,7 +434,8 @@ // Select another image, download item #0. toggleItemSelection(9); - shareIntent = mUi.createShareIntent(); + shareIntent = DownloadUtils.createShareIntent( + mUi.getBackendProvider().getSelectionDelegate().getSelectedItems()); Assert.assertEquals( "Incorrect intent action", Intent.ACTION_SEND_MULTIPLE, shareIntent.getAction()); Assert.assertEquals("Incorrect intent mime type", "image/*", shareIntent.getType()); @@ -446,7 +448,8 @@ // Select non-image item, download item #4. toggleItemSelection(6); - shareIntent = mUi.createShareIntent(); + shareIntent = DownloadUtils.createShareIntent( + mUi.getBackendProvider().getSelectionDelegate().getSelectedItems()); Assert.assertEquals( "Incorrect intent action", Intent.ACTION_SEND_MULTIPLE, shareIntent.getAction()); Assert.assertEquals("Incorrect intent mime type", "*/*", shareIntent.getType()); @@ -459,7 +462,8 @@ // Select an offline page #3. toggleItemSelection(3); - shareIntent = mUi.createShareIntent(); + shareIntent = DownloadUtils.createShareIntent( + mUi.getBackendProvider().getSelectionDelegate().getSelectedItems()); Assert.assertEquals( "Incorrect intent action", Intent.ACTION_SEND_MULTIPLE, shareIntent.getAction()); Assert.assertEquals("Incorrect intent mime type", "*/*", shareIntent.getType());
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java index b6669c94..79e3da2d5 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java
@@ -188,6 +188,17 @@ public void cancelRetrieval(ThumbnailRequest request) {} } + /** Stubs out the UIDelegate. */ + public class StubbedUIDelegate implements UIDelegate { + @Override + public void deleteItem(DownloadHistoryItemWrapper item) { + mHandler.post(() -> item.removePermanently()); + } + + @Override + public void shareItem(DownloadHistoryItemWrapper item) {} + } + private static final long ONE_GIGABYTE = 1024L * 1024L * 1024L; private final Handler mHandler; @@ -195,6 +206,7 @@ private final StubbedOfflineContentProvider mOfflineContentProvider; private final SelectionDelegate<DownloadHistoryItemWrapper> mSelectionDelegate; private final StubbedThumbnailProvider mStubbedThumbnailProvider; + private final StubbedUIDelegate mStubbedUIDelegate; public StubbedProvider() { mHandler = new Handler(Looper.getMainLooper()); @@ -202,6 +214,7 @@ mOfflineContentProvider = new StubbedOfflineContentProvider(); mSelectionDelegate = new DownloadItemSelectionDelegate(); mStubbedThumbnailProvider = new StubbedThumbnailProvider(); + mStubbedUIDelegate = new StubbedUIDelegate(); } @Override @@ -225,6 +238,11 @@ } @Override + public UIDelegate getUIDelegate() { + return mStubbedUIDelegate; + } + + @Override public void destroy() {} /** See {@link #createDownloadItem(int, String, boolean, int, int)}. */
diff --git a/chrome/browser/android/vr_shell/mailbox_to_surface_bridge.cc b/chrome/browser/android/vr_shell/mailbox_to_surface_bridge.cc index 5a27caa..5cb7d97 100644 --- a/chrome/browser/android/vr_shell/mailbox_to_surface_bridge.cc +++ b/chrome/browser/android/vr_shell/mailbox_to_surface_bridge.cc
@@ -130,8 +130,7 @@ TRACE_EVENT0("gpu", "MailboxToSurfaceBridge::ConsumeTexture"); gl->WaitSyncTokenCHROMIUM(mailbox.sync_token.GetConstData()); - return gl->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, - mailbox.mailbox.name); + return gl->CreateAndConsumeTextureCHROMIUM(mailbox.mailbox.name); } } // namespace
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index d4f17310..1e9d6b7 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -3749,7 +3749,7 @@ } bool ChromeContentBrowserClient::AllowRenderingMhtmlOverHttp( - content::NavigationUIData* navigation_ui_data) const { + content::NavigationUIData* navigation_ui_data) { #if BUILDFLAG(ENABLE_OFFLINE_PAGES) // It is OK to load the saved offline copy, in MHTML format. ChromeNavigationUIData* chrome_navigation_ui_data = @@ -3764,6 +3764,17 @@ #endif } +bool ChromeContentBrowserClient::ShouldForceDownloadResource( + const GURL& url, + const std::string& mime_type) { +#if BUILDFLAG(ENABLE_EXTENSIONS) + // Special-case user scripts to get downloaded instead of viewed. + return extensions::UserScript::IsURLUserScript(url, mime_type); +#else + return false; +#endif +} + // Static; handles rewriting Web UI URLs. bool ChromeContentBrowserClient::HandleWebUI( GURL* url,
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 5968ca3..67406ee 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h
@@ -384,7 +384,9 @@ const GURL& frame_url, NonNetworkURLLoaderFactoryMap* factories) override; bool AllowRenderingMhtmlOverHttp( - content::NavigationUIData* navigation_ui_data) const override; + content::NavigationUIData* navigation_ui_data) override; + bool ShouldForceDownloadResource(const GURL& url, + const std::string& mime_type) override; protected: static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context);
diff --git a/chrome/browser/content_settings/sound_content_setting_observer.cc b/chrome/browser/content_settings/sound_content_setting_observer.cc index 35935da9..f882634 100644 --- a/chrome/browser/content_settings/sound_content_setting_observer.cc +++ b/chrome/browser/content_settings/sound_content_setting_observer.cc
@@ -9,6 +9,7 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/profiles/profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/ukm/content/source_url_recorder.h" #include "content/public/browser/navigation_handle.h" #include "content/public/common/url_constants.h" #include "services/metrics/public/cpp/ukm_builders.h" @@ -113,12 +114,10 @@ return; logged_site_muted_ukm_ = true; - ukm::UkmRecorder* recorder = ukm::UkmRecorder::Get(); - ukm::SourceId source_id = ukm::UkmRecorder::GetNewSourceID(); - recorder->UpdateSourceURL(source_id, web_contents()->GetLastCommittedURL()); - ukm::builders::Media_SiteMuted(source_id) + ukm::builders::Media_SiteMuted( + ukm::GetSourceIdForWebContentsDocument(web_contents())) .SetMuteReason(GetSiteMutedReason()) - .Record(recorder); + .Record(ukm::UkmRecorder::Get()); } SoundContentSettingObserver::MuteReason
diff --git a/chrome/browser/content_settings/sound_content_setting_observer_unittest.cc b/chrome/browser/content_settings/sound_content_setting_observer_unittest.cc index 0154c54..55739ab 100644 --- a/chrome/browser/content_settings/sound_content_setting_observer_unittest.cc +++ b/chrome/browser/content_settings/sound_content_setting_observer_unittest.cc
@@ -9,6 +9,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/ukm/content/source_url_recorder.h" #include "components/ukm/test_ukm_recorder.h" #include "content/public/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" @@ -39,6 +40,7 @@ ChromeRenderViewHostTestHarness::SetUp(); SoundContentSettingObserver::CreateForWebContents(web_contents()); + ukm::InitializeSourceUrlRecorderForWebContents(web_contents()); host_content_settings_map_ = HostContentSettingsMapFactory::GetForProfile( Profile::FromBrowserContext(web_contents()->GetBrowserContext())); test_ukm_recorder_ = base::MakeUnique<ukm::TestAutoSetUkmRecorder>();
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index 5e1a98de..0ee139f 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc
@@ -142,6 +142,20 @@ const char kDownloadTest1Path[] = "download-test1.lib"; +class DownloadTestContentBrowserClient : public content::ContentBrowserClient { + public: + explicit DownloadTestContentBrowserClient(bool must_download) + : must_download_(must_download) {} + + bool ShouldForceDownloadResource(const GURL& url, + const std::string& mime_type) override { + return must_download_; + } + + private: + const bool must_download_; +}; + class CreatedObserver : public content::DownloadManager::Observer { public: explicit CreatedObserver(content::DownloadManager* manager) @@ -266,6 +280,9 @@ const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; const char kLargeThemePath[] = "extensions/theme2.crx"; +// User script file used in tests. +const char kUserScriptPath[] = "extensions/user_script_basic.user.js"; + // Get History Information. class DownloadsHistoryDataCollector { public: @@ -2099,6 +2116,27 @@ EXPECT_TRUE(base::PathExists(downloaded_file)); } +// Test that navigating to a user script URL will result in a download. +IN_PROC_BROWSER_TEST_F(DownloadTest, UserScriptDownload) { + DownloadTestContentBrowserClient new_client(true); + content::ContentBrowserClient* old_client = + SetBrowserClientForTesting(&new_client); + embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url = embedded_test_server()->GetURL("/" + std::string(kUserScriptPath)); + + // Navigate to the user script URL and wait for the download to complete. + std::unique_ptr<content::DownloadTestObserver> observer( + DangerousDownloadWaiter( + browser(), 1, + content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); + ui_test_utils::NavigateToURL(browser(), url); + observer->WaitForFinished(); + EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); + CheckDownloadStates(1, DownloadItem::COMPLETE); + SetBrowserClientForTesting(old_client); +} + // Test to make sure auto-open works. IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) { base::FilePath file(FILE_PATH_LITERAL("download-autoopen.txt"));
diff --git a/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc b/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc index 0be10ba..ba4b014 100644 --- a/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc +++ b/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
@@ -896,149 +896,6 @@ } } -// Tests the "resourceTypes" and "excludedResourceTypes" fields of a declarative -// rule condition. -IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, - BlockRequests_ResourceTypes) { - // TODO(crbug.com/696822): Add tests for "object", "ping", "other", "font". - enum ResourceTypeMask { - kNone = 0, - kSubframe = 1 << 0, - kStylesheet = 1 << 1, - kScript = 1 << 2, - kImage = 1 << 3, - kXHR = 1 << 4, - kMedia = 1 << 5, - kWebSocket = 1 << 6, - kAll = (1 << 7) - 1 - }; - - struct { - std::string domain; - size_t id; - std::vector<std::string> resource_types; - std::vector<std::string> excluded_resource_types; - } rules_data[] = { - {"block_subframe.com", 1, {"sub_frame"}, {}}, - {"block_stylesheet.com", 2, {"stylesheet"}, {}}, - {"block_script.com", 3, {"script"}, {}}, - {"block_image.com", 4, {"image"}, {}}, - {"block_xhr.com", 5, {"xmlhttprequest"}, {}}, - {"block_media.com", 6, {"media"}, {}}, - {"block_websocket.com", 7, {"websocket"}, {}}, - {"block_image_and_stylesheet.com", 8, {"image", "stylesheet"}, {}}, - {"block_subframe_and_xhr.com", 11, {"sub_frame", "xmlhttprequest"}, {}}, - // With renderer side navigation, the main frame origin serves as the - // initiator for main frame page loads. Hence to ensure that the main - // frame page load is not blocked, also exclude the "other" resource type, - // which is used for main frame requests currently. - // TODO(crbug.com/696822): Change "other" to "main_frame" once it is - // implemented. - {"block_all.com", 9, {}, {"other"}}, - {"block_all_but_xhr_and_script.com", - 10, - {}, - {"xmlhttprequest", "script", "other"}}, - }; - - std::vector<TestRule> rules; - for (const auto& rule_data : rules_data) { - TestRule rule = CreateGenericRule(); - - // The "resourceTypes" property (i.e. |rule.condition->resource_types|) - // should not be an empty list. It should either be omitted or be a non- - // empty list. - if (rule_data.resource_types.empty()) - rule.condition->resource_types = base::nullopt; - else - rule.condition->resource_types = rule_data.resource_types; - - rule.condition->excluded_resource_types = rule_data.excluded_resource_types; - rule.id = rule_data.id; - rule.condition->domains = std::vector<std::string>({rule_data.domain}); - // Don't specify the urlFilter, which should behaves the same as "*". - rule.condition->url_filter = base::nullopt; - rules.push_back(rule); - } - ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules(rules)); - - struct { - std::string hostname; - int blocked_mask; - } test_cases[] = { - {"block_subframe.com", kSubframe}, - {"block_stylesheet.com", kStylesheet}, - {"block_script.com", kScript}, - {"block_image.com", kImage}, - {"block_xhr.com", kXHR}, - {"block_media.com", kMedia}, - {"block_websocket.com", kWebSocket}, - {"block_image_and_stylesheet.com", kImage | kStylesheet}, - {"block_subframe_and_xhr.com", kSubframe | kXHR}, - {"block_all.com", kAll}, - {"block_all_but_xhr_and_script.com", kAll & ~kXHR & ~kScript}, - {"block_none.com", kNone}}; - - // Start a web socket test server to test the websocket resource type. - net::SpawnedTestServer websocket_test_server( - net::SpawnedTestServer::TYPE_WS, net::GetWebSocketTestDataDirectory()); - ASSERT_TRUE(websocket_test_server.Start()); - - // The |websocket_url| will echo the message we send to it. - GURL websocket_url = websocket_test_server.GetURL("echo-with-no-extension"); - - auto execute_script = [](content::RenderFrameHost* frame, - const std::string& script) { - bool subresource_loaded = false; - EXPECT_TRUE(content::ExecuteScriptAndExtractBool(frame, script, - &subresource_loaded)); - return subresource_loaded; - }; - - for (const auto& test_case : test_cases) { - GURL url = embedded_test_server()->GetURL(test_case.hostname, - "/subresources.html"); - SCOPED_TRACE(base::StringPrintf("Testing %s", url.spec().c_str())); - - ui_test_utils::NavigateToURL(browser(), url); - ASSERT_EQ(content::PAGE_TYPE_NORMAL, GetPageType()); - - content::RenderFrameHost* frame = GetMainFrame(); - - // sub-frame. - EXPECT_EQ( - !(test_case.blocked_mask & kSubframe), - execute_script(frame, - "domAutomationController.send(!!window.frameLoaded);")); - - // stylesheet - EXPECT_EQ(!(test_case.blocked_mask & kStylesheet), - execute_script(frame, "testStylesheet();")); - - // script - EXPECT_EQ(!(test_case.blocked_mask & kScript), - execute_script(frame, "testScript();")); - - // image - EXPECT_EQ(!(test_case.blocked_mask & kImage), - execute_script(frame, "testImage();")); - - // xhr - EXPECT_EQ(!(test_case.blocked_mask & kXHR), - execute_script(frame, "testXHR();")); - - // media - EXPECT_EQ(!(test_case.blocked_mask & kMedia), - execute_script(frame, "testMedia();")); - - // websocket - EXPECT_EQ(!(test_case.blocked_mask & kWebSocket), - execute_script(frame, - base::StringPrintf("testWebSocket('%s');", - websocket_url.spec().c_str()))); - } -} - // Ensure extensions can't intercept chrome:// urls. IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, ChromeURLS) { // Have the extension block all chrome:// urls. @@ -1152,12 +1009,182 @@ content::RunAllTasksUntilIdle(); } +// Fixture to test the "resourceTypes" and "excludedResourceTypes" fields of a +// declarative rule condition. +class DeclarativeNetRequestResourceTypeBrowserTest + : public DeclarativeNetRequestBrowserTest { + public: + DeclarativeNetRequestResourceTypeBrowserTest() {} + + protected: + // TODO(crbug.com/696822): Add tests for "object", "ping", "other", "font". + enum ResourceTypeMask { + kNone = 0, + kSubframe = 1 << 0, + kStylesheet = 1 << 1, + kScript = 1 << 2, + kImage = 1 << 3, + kXHR = 1 << 4, + kMedia = 1 << 5, + kWebSocket = 1 << 6, + kAll = (1 << 7) - 1 + }; + + struct TestCase { + std::string hostname; + int blocked_mask; + }; + + void RunTests(const std::vector<TestCase>& test_cases) { + // Start a web socket test server to test the websocket resource type. + net::SpawnedTestServer websocket_test_server( + net::SpawnedTestServer::TYPE_WS, net::GetWebSocketTestDataDirectory()); + ASSERT_TRUE(websocket_test_server.Start()); + + // The |websocket_url| will echo the message we send to it. + GURL websocket_url = websocket_test_server.GetURL("echo-with-no-extension"); + + auto execute_script = [](content::RenderFrameHost* frame, + const std::string& script) { + bool subresource_loaded = false; + EXPECT_TRUE(content::ExecuteScriptAndExtractBool(frame, script, + &subresource_loaded)); + return subresource_loaded; + }; + + for (const auto& test_case : test_cases) { + GURL url = embedded_test_server()->GetURL(test_case.hostname, + "/subresources.html"); + SCOPED_TRACE(base::StringPrintf("Testing %s", url.spec().c_str())); + + ui_test_utils::NavigateToURL(browser(), url); + ASSERT_EQ(content::PAGE_TYPE_NORMAL, GetPageType()); + + content::RenderFrameHost* frame = GetMainFrame(); + + // sub-frame. + EXPECT_EQ( + !(test_case.blocked_mask & kSubframe), + execute_script( + frame, "domAutomationController.send(!!window.frameLoaded);")); + + // stylesheet + EXPECT_EQ(!(test_case.blocked_mask & kStylesheet), + execute_script(frame, "testStylesheet();")); + + // script + EXPECT_EQ(!(test_case.blocked_mask & kScript), + execute_script(frame, "testScript();")); + + // image + EXPECT_EQ(!(test_case.blocked_mask & kImage), + execute_script(frame, "testImage();")); + + // xhr + EXPECT_EQ(!(test_case.blocked_mask & kXHR), + execute_script(frame, "testXHR();")); + + // media + EXPECT_EQ(!(test_case.blocked_mask & kMedia), + execute_script(frame, "testMedia();")); + + // websocket + EXPECT_EQ(!(test_case.blocked_mask & kWebSocket), + execute_script( + frame, base::StringPrintf("testWebSocket('%s');", + websocket_url.spec().c_str()))); + } + } + + // Loads an extension to test blocking different resource types. + void LoadExtension() { + struct { + std::string domain; + size_t id; + std::vector<std::string> resource_types; + std::vector<std::string> excluded_resource_types; + } rules_data[] = { + {"block_subframe.com", 1, {"sub_frame"}, {}}, + {"block_stylesheet.com", 2, {"stylesheet"}, {}}, + {"block_script.com", 3, {"script"}, {}}, + {"block_image.com", 4, {"image"}, {}}, + {"block_xhr.com", 5, {"xmlhttprequest"}, {}}, + {"block_media.com", 6, {"media"}, {}}, + {"block_websocket.com", 7, {"websocket"}, {}}, + {"block_image_and_stylesheet.com", 8, {"image", "stylesheet"}, {}}, + {"block_subframe_and_xhr.com", 11, {"sub_frame", "xmlhttprequest"}, {}}, + // With renderer side navigation, the main frame origin serves as the + // initiator for main frame page loads. Hence to ensure that the main + // frame page load is not blocked, also exclude the "other" resource + // type, which is used for main frame requests currently. + // TODO(crbug.com/696822): Change "other" to "main_frame" once it is + // implemented. + {"block_all.com", 9, {}, {"other"}}, + {"block_all_but_xhr_and_script.com", + 10, + {}, + {"xmlhttprequest", "script", "other"}}, + }; + + std::vector<TestRule> rules; + for (const auto& rule_data : rules_data) { + TestRule rule = CreateGenericRule(); + + // The "resourceTypes" property (i.e. |rule.condition->resource_types|) + // should not be an empty list. It should either be omitted or be a non- + // empty list. + if (rule_data.resource_types.empty()) + rule.condition->resource_types = base::nullopt; + else + rule.condition->resource_types = rule_data.resource_types; + + rule.condition->excluded_resource_types = + rule_data.excluded_resource_types; + rule.id = rule_data.id; + rule.condition->domains = std::vector<std::string>({rule_data.domain}); + // Don't specify the urlFilter, which should behaves the same as "*". + rule.condition->url_filter = base::nullopt; + rules.push_back(rule); + } + LoadExtensionWithRules(rules); + } + + private: + DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestResourceTypeBrowserTest); +}; + +// These are split into two tests to prevent a timeout. See crbug.com/787957. +IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestResourceTypeBrowserTest, Test1) { + ASSERT_NO_FATAL_FAILURE(LoadExtension()); + RunTests({{"block_subframe.com", kSubframe}, + {"block_stylesheet.com", kStylesheet}, + {"block_script.com", kScript}, + {"block_image.com", kImage}, + {"block_xhr.com", kXHR}, + {"block_media.com", kMedia}}); +} + +IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestResourceTypeBrowserTest, Test2) { + ASSERT_NO_FATAL_FAILURE(LoadExtension()); + RunTests({{"block_websocket.com", kWebSocket}, + {"block_image_and_stylesheet.com", kImage | kStylesheet}, + {"block_subframe_and_xhr.com", kSubframe | kXHR}, + {"block_all.com", kAll}, + {"block_all_but_xhr_and_script.com", kAll & ~kXHR & ~kScript}, + {"block_none.com", kNone}}); +} + INSTANTIATE_TEST_CASE_P(, DeclarativeNetRequestBrowserTest, ::testing::Values(ExtensionLoadType::PACKED, ExtensionLoadType::UNPACKED)); INSTANTIATE_TEST_CASE_P(, + DeclarativeNetRequestResourceTypeBrowserTest, + ::testing::Values(ExtensionLoadType::PACKED, + ExtensionLoadType::UNPACKED)); + +INSTANTIATE_TEST_CASE_P(, DeclarativeNetRequestBrowserTest_Packed, ::testing::Values(ExtensionLoadType::PACKED));
diff --git a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc index 396e39c..783505f 100644 --- a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc +++ b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc
@@ -687,16 +687,6 @@ throttles->push_back(std::move(predictor_throttle)); } -bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( - const GURL& url, const std::string& mime_type) { -#if BUILDFLAG(ENABLE_EXTENSIONS) - // Special-case user scripts to get downloaded instead of viewed. - return extensions::UserScript::IsURLUserScript(url, mime_type); -#else - return false; -#endif -} - bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( net::URLRequest* request, const base::FilePath& plugin_path,
diff --git a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h index b1026c5..17c773b 100644 --- a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h +++ b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h
@@ -67,8 +67,6 @@ net::URLRequest* request) override; bool HandleExternalProtocol(const GURL& url, content::ResourceRequestInfo* info) override; - bool ShouldForceDownloadResource(const GURL& url, - const std::string& mime_type) override; bool ShouldInterceptResourceAsStream(net::URLRequest* request, const base::FilePath& plugin_path, const std::string& mime_type,
diff --git a/chrome/browser/printing/cloud_print/privet_http_impl.cc b/chrome/browser/printing/cloud_print/privet_http_impl.cc index 60087b71..5ab2c01 100644 --- a/chrome/browser/printing/cloud_print/privet_http_impl.cc +++ b/chrome/browser/printing/cloud_print/privet_http_impl.cc
@@ -118,7 +118,7 @@ callback_.Run(nullptr); } -void PrivetInfoOperationImpl::OnParsedJson(PrivetURLFetcher* fetcher, +void PrivetInfoOperationImpl::OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) { callback_.Run(&value); @@ -192,7 +192,7 @@ } void PrivetRegisterOperationImpl::OnParsedJson( - PrivetURLFetcher* fetcher, + int response_code, const base::DictionaryValue& value, bool has_error) { if (has_error) { @@ -200,11 +200,8 @@ value.GetString(kPrivetKeyError, &error); ongoing_ = false; - delegate_->OnPrivetRegisterError(this, - current_action_, - FAILURE_JSON_ERROR, - fetcher->response_code(), - &value); + delegate_->OnPrivetRegisterError(this, current_action_, FAILURE_JSON_ERROR, + response_code, &value); return; } @@ -318,10 +315,9 @@ PrivetURLFetcher::ErrorType error) {} void PrivetRegisterOperationImpl::Cancelation::OnParsedJson( - PrivetURLFetcher* fetcher, + int response_code, const base::DictionaryValue& value, - bool has_error) { -} + bool has_error) {} void PrivetRegisterOperationImpl::Cancelation::Cleanup() { // Nothing needs to be done, as base::Owned will delete this object, @@ -358,7 +354,7 @@ callback_.Run(nullptr); } -void PrivetJSONOperationImpl::OnParsedJson(PrivetURLFetcher* fetcher, +void PrivetJSONOperationImpl::OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) { callback_.Run(&value); @@ -609,7 +605,7 @@ } void PrivetLocalPrintOperationImpl::OnParsedJson( - PrivetURLFetcher* fetcher, + int response_code, const base::DictionaryValue& value, bool has_error) { DCHECK(!current_response_.is_null());
diff --git a/chrome/browser/printing/cloud_print/privet_http_impl.h b/chrome/browser/printing/cloud_print/privet_http_impl.h index fe6ed04..cdc7901 100644 --- a/chrome/browser/printing/cloud_print/privet_http_impl.h +++ b/chrome/browser/printing/cloud_print/privet_http_impl.h
@@ -35,7 +35,7 @@ PrivetHTTPClient* GetHTTPClient() override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override; @@ -61,7 +61,7 @@ void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override; @@ -77,7 +77,7 @@ void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override; @@ -127,7 +127,7 @@ PrivetHTTPClient* GetHTTPClient() override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override; void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override; @@ -165,7 +165,7 @@ // PrivetURLFetcher::Delegate: void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override; void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override;
diff --git a/chrome/browser/printing/cloud_print/privet_http_unittest.cc b/chrome/browser/printing/cloud_print/privet_http_unittest.cc index fb32bdfa..2ee1a40c 100644 --- a/chrome/browser/printing/cloud_print/privet_http_unittest.cc +++ b/chrome/browser/printing/cloud_print/privet_http_unittest.cc
@@ -261,7 +261,7 @@ class PrivetHTTPTest : public TestWithParam<const char*> { public: PrivetHTTPTest() { - PrivetURLFetcher::ResetTokenMapForTests(); + PrivetURLFetcher::ResetTokenMapForTest(); request_context_ = base::MakeRefCounted<net::TestURLRequestContextGetter>( base::ThreadTaskRunnerHandle::Get()); @@ -763,7 +763,7 @@ class PrivetLocalPrintTest : public PrivetHTTPTest { public: void SetUp() override { - PrivetURLFetcher::ResetTokenMapForTests(); + PrivetURLFetcher::ResetTokenMapForTest(); local_print_operation_ = privet_client_->CreateLocalPrintOperation( &local_print_delegate_); @@ -775,7 +775,7 @@ } scoped_refptr<base::RefCountedBytes> RefCountedBytesFromString( - std::string str) { + base::StringPiece str) { std::vector<unsigned char> str_vec; str_vec.insert(str_vec.begin(), str.begin(), str.end()); return base::RefCountedBytes::TakeVector(&str_vec); @@ -1068,11 +1068,10 @@ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_); } - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override { NOTREACHED(); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_); } bool OnRawData(bool response_is_file, @@ -1095,7 +1094,7 @@ std::unique_ptr<PrivetURLFetcher> fetcher = client_->CreateURLFetcher( server_->GetURL("/simple.html"), net::URLFetcher::GET, this); - fetcher->SetMaxRetries(1); + fetcher->SetMaxRetriesForTest(1); fetcher->Start(); run_loop.Run();
diff --git a/chrome/browser/printing/cloud_print/privet_url_fetcher.cc b/chrome/browser/printing/cloud_print/privet_url_fetcher.cc index 494dcde..d79d4c3 100644 --- a/chrome/browser/printing/cloud_print/privet_url_fetcher.cc +++ b/chrome/browser/printing/cloud_print/privet_url_fetcher.cc
@@ -13,8 +13,8 @@ #include "base/bind.h" #include "base/json/json_reader.h" +#include "base/lazy_instance.h" #include "base/location.h" -#include "base/memory/singleton.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" #include "base/task_scheduler/post_task.h" @@ -31,16 +31,9 @@ namespace { -typedef std::map<std::string, std::string> TokenMap; +using TokenMap = std::map<std::string, std::string>; -struct TokenMapHolder { - public: - static TokenMapHolder* GetInstance() { - return base::Singleton<TokenMapHolder>::get(); - } - - TokenMap map; -}; +base::LazyInstance<TokenMap>::Leaky g_tokens = LAZY_INSTANCE_INITIALIZER; const char kXPrivetTokenHeaderPrefix[] = "X-Privet-Token: "; const char kRangeHeaderFormat[] = "Range: bytes=%d-%d"; @@ -95,15 +88,15 @@ // static void PrivetURLFetcher::SetTokenForHost(const std::string& host, const std::string& token) { - TokenMapHolder::GetInstance()->map[host] = token; + g_tokens.Get()[host] = token; } // static -void PrivetURLFetcher::ResetTokenMapForTests() { - TokenMapHolder::GetInstance()->map.clear(); +void PrivetURLFetcher::ResetTokenMapForTest() { + g_tokens.Get().clear(); } -void PrivetURLFetcher::SetMaxRetries(int max_retries) { +void PrivetURLFetcher::SetMaxRetriesForTest(int max_retries) { DCHECK_EQ(tries_, 0); max_retries_ = max_retries; } @@ -119,13 +112,11 @@ } std::string PrivetURLFetcher::GetPrivetAccessToken() { - if (send_empty_privet_token_) { + if (send_empty_privet_token_) return std::string(); - } - TokenMapHolder* token_map_holder = TokenMapHolder::GetInstance(); - TokenMap::iterator found = token_map_holder->map.find(GetHostString()); - return found != token_map_holder->map.end() ? found->second : std::string(); + TokenMap::iterator it = g_tokens.Get().find(GetHostString()); + return it != g_tokens.Get().end() ? it->second : std::string(); } std::string PrivetURLFetcher::GetHostString() { @@ -337,7 +328,8 @@ is_error_response = true; } - delegate_->OnParsedJson(this, *dictionary_value, is_error_response); + delegate_->OnParsedJson(response_code(), *dictionary_value, + is_error_response); } void PrivetURLFetcher::ScheduleRetry(int timeout_seconds) {
diff --git a/chrome/browser/printing/cloud_print/privet_url_fetcher.h b/chrome/browser/printing/cloud_print/privet_url_fetcher.h index 7dbffc66..430c0812 100644 --- a/chrome/browser/printing/cloud_print/privet_url_fetcher.h +++ b/chrome/browser/printing/cloud_print/privet_url_fetcher.h
@@ -50,7 +50,7 @@ // |response_code| is only needed for RESPONSE_CODE_ERROR. virtual void OnError(int response_code, ErrorType error) = 0; - virtual void OnParsedJson(PrivetURLFetcher* fetcher, + virtual void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) = 0; @@ -77,9 +77,9 @@ static void SetTokenForHost(const std::string& host, const std::string& token); - static void ResetTokenMapForTests(); + static void ResetTokenMapForTest(); - void SetMaxRetries(int max_retries); + void SetMaxRetriesForTest(int max_retries); void DoNotRetryOnTransientError();
diff --git a/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc b/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc index fab7d9b..448f2930 100644 --- a/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc +++ b/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc
@@ -46,7 +46,7 @@ MOCK_METHOD1(OnErrorInternal, void(PrivetURLFetcher::ErrorType error)); - void OnParsedJson(PrivetURLFetcher* fetcher, + void OnParsedJson(int response_code, const base::DictionaryValue& value, bool has_error) override { saved_value_.reset(value.DeepCopy());
diff --git a/chrome/browser/resources/component_extension_resources.grd b/chrome/browser/resources/component_extension_resources.grd index 1a7f9514b..951b308 100644 --- a/chrome/browser/resources/component_extension_resources.grd +++ b/chrome/browser/resources/component_extension_resources.grd
@@ -155,6 +155,7 @@ <include name="IDR_CRYPTOTOKEN_GNUBBYFACTORY_JS" file="cryptotoken/gnubbyfactory.js" type="BINDATA" /> <include name="IDR_CRYPTOTOKEN_USBGNUBBYFACTORY_JS" file="cryptotoken/usbgnubbyfactory.js" type="BINDATA" /> <include name="IDR_CRYPTOTOKEN_DEVICESTATUSCODES_JS" file="cryptotoken/devicestatuscodes.js" type="BINDATA" /> + <include name="IDR_CRYPTOTOKEN_ASN1_JS" file="cryptotoken/asn1.js" type="BINDATA" /> <include name="IDR_CRYPTOTOKEN_ENROLLER_JS" file="cryptotoken/enroller.js" type="BINDATA" /> <include name="IDR_CRYPTOTOKEN_USBENROLLHANDLER_JS" file="cryptotoken/usbenrollhandler.js" type="BINDATA" /> <include name="IDR_CRYPTOTOKEN_REQUESTQUEUE_JS" file="cryptotoken/requestqueue.js" type="BINDATA" />
diff --git a/chrome/browser/resources/cryptotoken/.eslintrc.js b/chrome/browser/resources/cryptotoken/.eslintrc.js new file mode 100644 index 0000000..0dcb0cf9 --- /dev/null +++ b/chrome/browser/resources/cryptotoken/.eslintrc.js
@@ -0,0 +1,8 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This makes "async function" not an error. +module.exports = { + parserOptions: {ecmaVersion: 2017}, +};
diff --git a/chrome/browser/resources/cryptotoken/asn1.js b/chrome/browser/resources/cryptotoken/asn1.js new file mode 100644 index 0000000..efbd80be --- /dev/null +++ b/chrome/browser/resources/cryptotoken/asn1.js
@@ -0,0 +1,714 @@ +// Copyright 2017 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. + +/** + * ASN.1 parser, in the manner of BoringSSL's CBS (crypto byte string) lib. + * + * A |ByteString| is a buffer of DER-encoded bytes. To decode the buffer, you + * must know something about the expected sequence of tags, which allows you to + * call getASN1() and friends with the right arguments and in the right order. + * + * https://commondatastorage.googleapis.com/chromium-boringssl-docs/bytestring.h.html + * is the canonical API reference. + */ +const ByteString = class { + /** + * Creates a new ASN.1 parser. + * @param {!Uint8Array} buffer DER-encoded ASN.1 bytes. + */ + constructor(buffer) { + /** @private {!Uint8Array} */ + this.slice_ = buffer; + } + + /** + * @return {!Uint8Array} The DER-encoded bytes remaining in the buffer. + */ + get data() { + return this.slice_; + } + + /** + * @return {number} The number of DER-encoded bytes remaining in the buffer. + */ + get length() { + return this.slice_.length; + } + + /** + * @return {boolean} True if the buffer is empty. + */ + get empty() { + return this.slice_.length == 0; + } + + /** + * Pops a byte from the start of the buffer. + * @return {number} A byte. + * @throws {Error} if the buffer is empty. + * @private + */ + getU8_() { + if (this.empty) { + throw Error('getU8_: slice empty'); + } + const b = this.slice_[0]; + this.slice_ = this.slice_.subarray(1); + return b; + } + + /** + * Pops |n| bytes from the buffer. + * @param {number} n The number of bytes to pop. + * @throws {Error} + * @private + */ + skip_(n) { + if (this.slice_.length < n) { + throw Error('skip_: too few bytes in input'); + } + this.slice_ = this.slice_.subarray(n); + } + + /** + * @param {number} n The number of bytes to read from the buffer. + * @return {!Uint8Array} an array of |n| bytes. + * @throws {Error} + */ + getBytes(n) { + if (this.slice_.length < n) { + throw Error('getBytes: too few bytes in input'); + } + const prefix = this.slice_.subarray(0, n); + this.slice_ = this.slice_.subarray(n); + return prefix; + } + + /** + * Returns a value of the specified type. + * @param {number} expectedTag The expected tag, e.g. |SEQUENCE|, of the next + * value in the buffer. + * @param {boolean=} opt_includeHeader If true, include header bytes in the + * buffer. + * @return {!ByteString} The DER-encoded value bytes. + * @throws {Error} + * @private + */ + getASN1_(expectedTag, opt_includeHeader) { + if (this.empty) { + throw Error('getASN1: empty slice, expected tag ' + expectedTag); + } + const v = this.getAnyASN1(); + if (v.tag != expectedTag) { + throw Error('getASN1: got tag ' + v.tag + ', want ' + expectedTag); + } + if (!opt_includeHeader) { + v.val.skip_(v.headerLen); + } + return v.val; + } + + /** + * Returns a value of the specified type. + * @param {number} expectedTag The expected tag, e.g. |SEQUENCE|, of the next + * value in the buffer. + * @return {!ByteString} The DER-encoded value bytes. + * @throws {Error} + */ + getASN1(expectedTag) { + return this.getASN1_(expectedTag, false); + } + + /** + * Returns a base128-encoded integer. + * @return {number} an int32. + * @private + */ + getBase128Int_() { + var lookahead = this.slice_.length; + if (lookahead > 4) { + lookahead = 4; + } + var len = 0; + for (var i = 0; i < lookahead; i++) { + if (!(this.data[i] & 0x80)) { + len = i + 1; + break; + } + } + if (len == 0) { + throw Error('terminating byte not found'); + } + var n = 0; + var octets = this.getBytes(len); + for (var i = 0; i < len; i++) { + n |= (octets[i] & 0x7f) << 7 * (len - i - 1); + } + return n; + } + + /** + * Returns an OBJECT IDENTIFIER. + * @return {Array<number>} + */ + getASN1ObjectIdentifier() { + var b = this.getASN1(Tag.OBJECT); + var result = []; + var first = b.getBase128Int_(); + result[1] = first % 40; + result[0] = (first - result[1]) / 40; + var n = 2; + while (!b.empty) { + result[n++] = b.getBase128Int_(); + } + return result; + } + + /** + * Returns a value of the specified type, with its header. + * @param {number} expectedTag The expected tag, e.g. |SEQUENCE|, of the next + * value in the buffer. + * @return {!ByteString} The DER-encoded header and value bytes. + * @throws {Error} + */ + getASN1Element(expectedTag) { + return this.getASN1_(expectedTag, true); + } + + /** + * Returns an optional value of the specified type. + * @param {number} expectedTag The expected tag, e.g. |SEQUENCE|, of the next + * value in the buffer. + * @return {ByteString} + * */ + getOptionalASN1(expectedTag) { + if (this.slice_.length < 1 || this.slice_[0] != expectedTag) { + return null; + } + return this.getASN1(expectedTag); + } + + /** + * Matches and returns any ASN.1 type. + * @return {{tag: number, headerLen: number, val: !ByteString}} An ASN.1 + * value. The returned |ByteString| includes the DER header bytes. + * @throws {Error} + */ + getAnyASN1() { + const header = new ByteString(this.slice_); + const tag = header.getU8_(); + const lengthByte = header.getU8_(); + + if ((tag & 0x1f) == 0x1f) { + throw Error('getAnyASN1: long-form tag found'); + } + + var len = 0; + var headerLen = 0; + + if ((lengthByte & 0x80) == 0) { + // Short form length. + len = lengthByte + 2; + headerLen = 2; + } else { + // The high bit indicates that this is the long form, while the next 7 + // bits encode the number of subsequent octets used to encode the length + // (ITU-T X.690 clause 8.1.3.5.b). + const numBytes = lengthByte & 0x7f; + + // Bitwise operations are always on signed 32-bit two's complement + // numbers. This check ensures that we stay under this limit. We could + // do this in a better way, but there's no need to process very large + // objects. + if (numBytes == 0 || numBytes > 3) { + throw Error('getAnyASN1: bad ASN.1 long-form length'); + } + const lengthBytes = header.getBytes(numBytes); + for (var i = 0; i < numBytes; i++) { + len <<= 8; + len |= lengthBytes[i]; + } + + if (len < 128 || (len >> ((numBytes - 1) * 8)) == 0) { + throw Error('getAnyASN1: incorrectly encoded ASN.1 length'); + } + + headerLen = 2 + numBytes; + len += headerLen; + } + + if (this.slice_.length < len) { + throw Error('getAnyASN1: too few bytes in input'); + } + const prefix = this.slice_.subarray(0, len); + this.slice_ = this.slice_.subarray(len); + return {tag: tag, headerLen: headerLen, val: new ByteString(prefix)}; + } +}; + +/** + * Tag is a container for ASN.1 tag values, like |SEQUENCE|. These values + * are arguments to e.g. getASN1(). + */ +const Tag = class { + /** @return {number} */ + static get BOOLEAN() { + return 1; + } + + /** @return {number} */ + static get INTEGER() { + return 2; + } + + /** @return {number} */ + static get BITSTRING() { + return 3; + } + + /** @return {number} */ + static get OCTETSTRING() { + return 4; + } + + /** @return {number} */ + static get NULL() { + return 5; + } + + /** @return {number} */ + static get OBJECT() { + return 6; + } + + /** @return {number} */ + static get UTF8String() { + return 12; + } + + /** @return {number} */ + static get PrintableString() { + return 19; + } + + /** @return {number} */ + static get UTCTime() { + return 23; + } + + /** @return {number} */ + static get GeneralizedTime() { + return 24; + } + + /** @return {number} */ + static get CONSTRUCTED() { + return 0x20; + } + + /** @return {number} */ + static get SEQUENCE() { + return 0x30; + } + + /** @return {number} */ + static get SET() { + return 0x31; + } + + /** @return {number} */ + static get CONTEXT_SPECIFIC() { + return 0x80; + } +}; + +/** + * ASN.1 builder, in the manner of BoringSSL's CBB (crypto byte builder). + * + * A |ByteBuilder| maintains a |Uint8Array| slice and appends to it on demand. + * After appending all the necessary values, the |data| property returns a + * slice containing the result. Utility functions are provided for appending + * ASN.1 DER-formatted values. + * + * Several of the functions take a "continuation" parameter. This is a function + * that makes calls to its argument in order to lay down the contents of a + * value. Once the continuation returns, the length prefix will be serialised. + * It is illegal to call methods on a parent ByteBuilder while a continuation + * function is running. + */ +const ByteBuilder = class { + constructor() { + /** @private {?Uint8Array} */ + this.slice_ = null; + /** @private {number} */ + this.len_ = 0; + /** @private {?ByteBuilder} */ + this.child_ = null; + } + + /** + * @return {!Uint8Array} The constructed bytes + */ + get data() { + if (this.child_ != null) { + throw Error('data access while child is pending'); + } + if (this.slice_ === null) { + return new Uint8Array(0); + } + return this.slice_.subarray(0, this.len_); + } + + /** + * Reallocates the slice to at least a given size. + * @param {number} minNewSize The minimum resulting size of the slice. + * @private + */ + realloc_(minNewSize) { + var newSize = 0; + + if (minNewSize > Number.MAX_SAFE_INTEGER - minNewSize) { + // Cannot grow exponentially without overflow. + newSize = minNewSize; + } else { + newSize = minNewSize * 2; + } + + if (this.slice_ === null) { + if (newSize < 128) { + newSize = 128; + } + this.slice_ = new Uint8Array(newSize); + return; + } + + const newSlice = new Uint8Array(newSize); + for (var i = 0; i < this.len_; i++) { + newSlice[i] = this.slice_[i]; + } + + this.slice_ = newSlice; + } + + /** + * Extends the current slice by the given number of bytes. + * @param {number} n The number of extra bytes needed in the slice. + * @return {number} The offset of the new bytes. + * @throws {Error} + * @private + */ + extend_(n) { + if (this.child_ != null) { + throw Error('write while child pending'); + } + if (this.len_ > Number.MAX_SAFE_INTEGER - n) { + throw Error('length overflow'); + } + if (this.slice_ === null || this.len_ + n > this.slice_.length) { + this.realloc_(this.len_ + n); + } + + const offset = this.len_; + this.len_ += n; + return offset; + } + + /** + * Appends a uint8 to the slice. + * @param {number} b The byte to append. + * @throws {Error} + * @private + */ + addU8_(b) { + const offset = this.extend_(1); + this.slice_[offset] = b; + } + + /** + * Appends a length prefixed value to the slice. + * @param {number} lenLen The number of length-prefix bytes. + * @param {boolean} isASN1 True iff an ASN.1 length should be prefixed. + * @param {function(ByteBuilder)} k A function to construct the contents. + * @throws {Error} + * @private + */ + addLengthPrefixed_(lenLen, isASN1, k) { + var offset = this.extend_(lenLen); + var child = new ByteBuilder(); + child.slice_ = this.slice_; + child.len_ = this.len_; + this.child_ = child; + k(child); + + var length = child.len_ - lenLen - offset; + if (length > 0x7fffffff) { + // If a number larger than this is used with a shift operation in + // Javascript, the result is incorrect. + throw Error('length too large'); + } + + if (isASN1) { + // In the case of ASN.1 a single byte was reserved for + // the length. The contents of the array may need to be + // shifted along if the length needs more than that. + if (lenLen != 1) { + throw Error('internal error'); + } + + var lenByte = 0; + if (length > 0xffffff) { + lenLen = 5; + lenByte = 0x80 | 4; + } else if (length > 0xffff) { + lenLen = 4; + lenByte = 0x80 | 3; + } else if (length > 0xff) { + lenLen = 3; + lenByte = 0x80 | 2; + } else if (length > 0x7f) { + lenLen = 2; + lenByte = 0x80 | 1; + } else { + lenLen = 1; + lenByte = length; + length = 0; + } + + child.slice_[offset] = lenByte; + const extraBytesNeeded = lenLen - 1; + if (extraBytesNeeded > 0) { + child.extend_(extraBytesNeeded); + child.slice_.copyWithin(offset + lenLen, offset + 1, child.len_); + } + + offset++; + lenLen = extraBytesNeeded; + } + + var l = length; + for (var i = lenLen - 1; i >= 0; i--) { + child.slice_[offset + i] = l; + l >>= 8; + } + + if (l != 0) { + throw Error('pending child length exceeds reserved space'); + } + + this.slice_ = child.slice_; + this.len_ = child.len_; + this.child_ = null; + } + + /** + * Appends an ASN.1 element to the slice. + * @param {number} tag The ASN.1 tag value (must be < 31). + * @param {function(ByteBuilder)} k A function to construct the contents. + * @throws {Error} + */ + addASN1(tag, k) { + if (tag > 255) { + throw Error('high-tag values not supported'); + } + this.addU8_(tag); + this.addLengthPrefixed_(1, true, k); + } + + /** + * Appends an ASN.1 INTEGER to the slice. + * @param {number} n The value of the integer. Must be within the range of an + * int32. + * @throws {Error} + */ + addASN1Int(n) { + if (n < (0x80000000 << 0) || n > 0x7fffffff) { + // Numbers this large (or small) cannot be correctly shifted in + // Javascript. + throw Error('integer out of encodable range'); + } + + var length = 1; + for (var nn = n; nn >= 0x80 || nn <= -0x80; nn >>= 8) { + length++; + } + + this.addASN1(Tag.INTEGER, (b) => { + for (var i = length - 1; i >= 0; i--) { + b.addU8_((n >> (8 * i)) & 0xff); + } + }); + } + + /** + * Appends a non-negative ASN.1 INTEGER to the slice given its big-endian + * encoding. This can be useful when interacting with the WebCrypto API. + * @param {!Uint8Array} bytes The big-endian encoding of the integer. + * @throws {Error} + */ + addASN1BigInt(bytes) { + // Zero is representated as a single zero byte, rather than no bytes. + if (bytes.length == 0) { + bytes = new Uint8Array(1); + } + + // Leading zero bytes need to be removed, unless that would make the number + // negative. + while (bytes.length >= 2 && bytes[0] == 0 && (bytes[1] & 0x80) == 0) { + bytes = bytes.slice(1); + } + + // If the MSB is set, the number will be considered to be negative. Thus + // a zero prefix is needed in that case. + if (bytes.length > 0 && (bytes[0] & 0x80) == 0x80) { + if (bytes.length > Number.MAX_SAFE_INTEGER - 1) { + throw Error('bigint array too long'); + } + var newBytes = new Uint8Array(bytes.length + 1); + newBytes.set(bytes, 1); + bytes = newBytes; + } + + this.addASN1(Tag.INTEGER, (b) => b.addBytes(bytes)); + } + + /** + * Appends a base128-encoded integer to the slice. + * @param {number} n The value of the integer. Must be non-negative and within + * the range of an int32. + * @throws {Error} + * @private + */ + addBase128Int_(n) { + if (n < 0 || n > 0x7fffffff) { + // Cannot encode negative numbers and large numbers cannot be shifted in + // Javascript. + throw Error('integer out of encodable range'); + } + + var length = 0; + if (n == 0) { + length = 1; + } else { + for (var i = n; i > 0; i >>= 7) { + length++; + } + } + + for (var i = length - 1; i >= 0; i--) { + var octet = 0x7f & (n >> (7 * i)); + if (i != 0) { + octet |= 0x80; + } + this.addU8_(octet); + } + } + + /** + * Appends an OBJECT IDENTIFIER to the slice. + * @param {Array<number>} oid The OID as a list of integer elements. + * @throws {Error} + */ + addASN1ObjectIdentifier(oid) { + if (oid.length < 2 || oid[0] > 2 || (oid[0] <= 1 && oid[1] >= 40)) { + throw Error('invalid OID'); + } + + this.addASN1(Tag.OBJECT, (b) => { + b.addBase128Int_(oid[0] * 40 + oid[1]); + for (var i = 2; i < oid.length; i++) { + b.addBase128Int_(oid[i]); + } + }); + } + + /** + * Appends an ASN.1 NULL to the slice. + * @throws {Error} + */ + addASN1Null() { + const offset = this.extend_(2); + this.slice_[offset] = Tag.NULL; + this.slice_[offset + 1] = 0; + } + + /** + * Appends an ASN.1 PrintableString to the slice. + * @param {string} s The contents of the string. + * @throws {Error} + */ + addASN1PrintableString(s) { + var buf = new Uint8Array(s.length); + for (var i = 0; i < s.length; i++) { + const code = s.charCodeAt(i); + if ((code < 97 && code > 122) && // a-z + (code < 65 && code > 90) && // A-Z + ' \'()+,-/:=?'.indexOf(String.fromCharCode(code)) == -1) { + throw Error( + 'cannot encode \'' + String.fromCharCode(code) + '\' in' + + ' PrintableString'); + } + + buf[i] = code; + } + + this.addASN1(Tag.PrintableString, (b) => { + b.addBytes(buf); + }); + } + + /** + * Appends an ASN.1 UTF8String to the slice. + * @param {string} s The contents of the string. + * @throws {Error} + */ + addASN1UTF8String(s) { + this.addASN1(Tag.UTF8String, (b) => { + b.addBytes((new TextEncoder()).encode(s)); + }); + } + + /** + * Appends an ASN.1 BIT STRING to the slice. + * @param {!Uint8Array} bytes The contents, which must be a whole number of + * bytes. + * @throws {Error} + */ + addASN1BitString(bytes) { + this.addASN1(Tag.BITSTRING, (b) => { + b.addU8_(0); // no superfluous bits in encoding. + b.addBytes(bytes); + }); + } + + /** + * Appends raw data to the slice. + * @param {string} s The contents to append. All character values must + * be < 256. + * @throws {Error} + */ + addBytesFromString(s) { + const buf = new Uint8Array(s.length); + for (var i = 0; i < s.length; i++) { + const code = s.charCodeAt(i); + if (code > 255) { + throw Error('out-of-range character in string of bytes'); + } + buf[i] = code; + } + + this.addBytes(buf); + } + + /** + * Appends raw bytes to the slice. + * @param {!Array<number>|!Uint8Array} bytes Data to append. + * @throws {Error} + */ + addBytes(bytes) { + const offset = this.extend_(bytes.length); + for (var i = 0; i < bytes.length; i++) { + this.slice_[offset + i] = bytes[i]; + } + } +};
diff --git a/chrome/browser/resources/cryptotoken/enroller.js b/chrome/browser/resources/cryptotoken/enroller.js index 2ddd25c..2df919f 100644 --- a/chrome/browser/resources/cryptotoken/enroller.js +++ b/chrome/browser/resources/cryptotoken/enroller.js
@@ -9,6 +9,342 @@ 'use strict'; /** + * webSafeBase64ToNormal reencodes a base64-encoded string. + * + * @param {string} s A string encoded as web-safe base64. + * @return {string} A string encoded in normal base64. + */ +function webSafeBase64ToNormal(s) { + return s.replace(/-/g, '+').replace(/_/g, '/'); +} + +/** + * decodeWebSafeBase64ToArray decodes a base64-encoded string. + * + * @param {string} s A base64-encoded string. + * @return {!Uint8Array} + */ +function decodeWebSafeBase64ToArray(s) { + var bytes = atob(webSafeBase64ToNormal(s)); + var buffer = new ArrayBuffer(bytes.length); + var ret = new Uint8Array(buffer); + for (var i = 0; i < bytes.length; i++) { + ret[i] = bytes.charCodeAt(i); + } + return ret; +} + +// See "FIDO U2F Authenticator Transports Extension", §3.2.1. +const transportTypeOID = [1, 3, 6, 1, 4, 1, 45724, 2, 1, 1]; + +/** + * Returns the value of the transport-type X.509 extension from the supplied + * attestation certificate, or 0. + * + * @param {!Uint8Array} der The DER bytes of an attestation certificate. + * @returns {Uint8Array} the bytes of the transport-type extension, if present, + * or null. + * @throws {Error} + */ +function transportType(der) { + var topLevel = new ByteString(der); + const tbsCert = topLevel.getASN1(Tag.SEQUENCE).getASN1(Tag.SEQUENCE); + tbsCert.getOptionalASN1( + Tag.CONSTRUCTED | Tag.CONTEXT_SPECIFIC | 0); // version + tbsCert.getASN1(Tag.INTEGER); // serialNumber + tbsCert.getASN1(Tag.SEQUENCE); // signature algorithm + tbsCert.getASN1(Tag.SEQUENCE); // issuer + tbsCert.getASN1(Tag.SEQUENCE); // validity + tbsCert.getASN1(Tag.SEQUENCE); // subject + tbsCert.getASN1(Tag.SEQUENCE); // SPKI + tbsCert.getOptionalASN1( // issuerUniqueID + Tag.CONSTRUCTED | Tag.CONTEXT_SPECIFIC | 1); + tbsCert.getOptionalASN1( // subjectUniqueID + Tag.CONSTRUCTED | Tag.CONTEXT_SPECIFIC | 2); + const outerExtensions = + tbsCert.getOptionalASN1(Tag.CONSTRUCTED | Tag.CONTEXT_SPECIFIC | 3); + if (outerExtensions == null) { + return null; + } + const extensions = outerExtensions.getASN1(Tag.SEQUENCE); + if (extensions.empty) { + return null; + } + + while (!extensions.empty) { + const extension = extensions.getASN1(Tag.SEQUENCE); + const oid = extension.getASN1ObjectIdentifier(); + if (oid.length != transportTypeOID.length) { + continue; + } + var matches = true; + for (var i = 0; i < oid.length; i++) { + if (oid[i] != transportTypeOID[i]) { + matches = false; + break; + } + } + if (!matches) { + continue; + } + + extension.getOptionalASN1(Tag.BOOLEAN); // 'critical' flag + const contents = extension.getASN1(Tag.OCTETSTRING); + if (!extension.empty) { + throw Error('trailing garbage after extension'); + } + return contents.getASN1(Tag.BITSTRING).data; + } + return null; +} + +/** + * makeCertAndKey creates a new ECDSA keypair and returns the private key + * and a cert containing the public key. + * + * @param {!Uint8Array} original The certificate being replaced, as DER bytes. + * @return {Promise<{privateKey: !webCrypto.CryptoKey, certDER: !Uint8Array}>} + */ +async function makeCertAndKey(original) { + var transport = transportType(original); + if (transport !== null) { + if (transport.length != 2) { + throw Error('bad extension length'); + } + if (transport[0] < 3) { + throw Error('too many bits set'); // Only 5 bits are defined. + } + } + + const keyalg = {name: 'ECDSA', namedCurve: 'P-256'}; + const keypair = + await crypto.subtle.generateKey(keyalg, true, ['sign', 'verify']); + const publicKey = await crypto.subtle.exportKey('raw', keypair.publicKey); + var serialBuffer = new ArrayBuffer(10); + var serial = new Uint8Array(serialBuffer); + crypto.getRandomValues(serial); + + const ecdsaWithSHA256 = [1, 2, 840, 10045, 4, 3, 2]; + const ansiX962 = [1, 2, 840, 10045, 2, 1]; + const secp256R1 = [1, 2, 840, 10045, 3, 1, 7]; + const commonName = [2, 5, 4, 3]; + const x509V3 = 2; + + const certBuilder = new ByteBuilder(); + certBuilder.addASN1(Tag.SEQUENCE, (b) => { + b.addASN1(Tag.SEQUENCE, (b) => { // TBSCertificate + b.addASN1(Tag.CONTEXT_SPECIFIC | Tag.CONSTRUCTED | 0, (b) => { + b.addASN1Int(x509V3); // Version + }); + b.addASN1BigInt(serial); // Serial number + b.addASN1(Tag.SEQUENCE, (b) => { // Signature algorithm + b.addASN1ObjectIdentifier(ecdsaWithSHA256); + }); + b.addASN1(Tag.SEQUENCE, (b) => { // Issuer + b.addASN1(Tag.SET, (b) => { + b.addASN1(Tag.SEQUENCE, (b) => { + b.addASN1ObjectIdentifier(commonName); + b.addASN1PrintableString('U2F'); + }); + }); + }); + b.addASN1(Tag.SEQUENCE, (b) => { // Validity + b.addASN1(Tag.UTCTime, (b) => { + b.addBytesFromString('0001010000Z'); + }); + b.addASN1(Tag.UTCTime, (b) => { + b.addBytesFromString('0001010000Z'); + }); + }); + b.addASN1(Tag.SEQUENCE, (b) => { // Subject + b.addASN1(Tag.SET, (b) => { + b.addASN1(Tag.SEQUENCE, (b) => { + b.addASN1ObjectIdentifier(commonName); + b.addASN1PrintableString('U2F'); + }); + }); + }); + b.addASN1(Tag.SEQUENCE, (b) => { // Public key + b.addASN1(Tag.SEQUENCE, (b) => { // Algorithm identifier + b.addASN1ObjectIdentifier(ansiX962); + b.addASN1ObjectIdentifier(secp256R1); + }); + b.addASN1BitString(new Uint8Array(publicKey)); + }); + if (transport !== null) { + var t = transport; // This causes the compiler to see t cannot be null. + // Extensions + b.addASN1(Tag.CONTEXT_SPECIFIC | Tag.CONSTRUCTED | 3, (b) => { + b.addASN1(Tag.SEQUENCE, (b) => { + b.addASN1(Tag.SEQUENCE, (b) => { // Transport-type extension. + b.addASN1ObjectIdentifier(transportTypeOID); + b.addASN1(Tag.OCTETSTRING, (b) => { + b.addASN1(Tag.BITSTRING, (b) => { + b.addBytes(t); + }); + }); + }); + }); + }); + } + }); + b.addASN1(Tag.SEQUENCE, (b) => { // Algorithm identifier + b.addASN1ObjectIdentifier(ecdsaWithSHA256); + }); + b.addASN1(Tag.BITSTRING, (b) => { // Signature + b.addBytesFromString('\x00'); // (not valid, obviously.) + }); + }); + return {privateKey: keypair.privateKey, certDER: certBuilder.data}; +} + +/** + * Registration encodes a registration response success message. See "FIDO U2F + * Raw Message Formats" (§4.3). + */ +const Registration = class { + /** + * @param {string} registrationData the registration response message, + * base64-encoded. + * @param {string} appId the application identifier. + * @param {string=} opt_clientData the client data, base64-encoded. This + * field is not really optional; it is an error if it is empty or missing. + * @throws {Error} + */ + constructor(registrationData, appId, opt_clientData) { + var data = new ByteString(decodeWebSafeBase64ToArray(registrationData)); + var magic = data.getBytes(1); + if (magic[0] != 5) { + throw Error('bad magic number'); + } + /** @private {!Uint8Array} */ + this.publicKey_ = data.getBytes(65); + /** @private {!Uint8Array} */ + this.keyHandleLen_ = data.getBytes(1); + /** @private {!Uint8Array} */ + this.keyHandle_ = data.getBytes(this.keyHandleLen_[0]); + /** @private {!Uint8Array} */ + this.certificate_ = data.getASN1Element(Tag.SEQUENCE).data; + /** @private {!Uint8Array} */ + this.signature_ = data.getASN1Element(Tag.SEQUENCE).data; + if (!data.empty) { + throw Error('extra trailing bytes'); + } + + if (!opt_clientData) { + throw Error('missing client data'); + } + /** @private {string} */ + this.clientData_ = atob(webSafeBase64ToNormal(opt_clientData)); + JSON.parse(this.clientData_); // Just checking. + + /** @private {string} */ + this.appId_ = appId; + } + + /** @return {!Uint8Array} the attestation certificate, DER-encoded. */ + get certificate() { + return this.certificate_; + } + + /** @return {!Uint8Array} the attestation signature, DER-encoded. */ + get signature() { + return this.signature_; + } + + /** + * toBeSigned marshals the parts of a registration that are signed by the + * attestation key, however obtained. + * + * @return {!Uint8Array} data to be signed. + */ + toBeSigned() { + var tbs = new ByteBuilder(); + tbs.addBytesFromString('\0'); + tbs.addBytes(sha256HashOfString(this.appId_)); + tbs.addBytes(sha256HashOfString(this.clientData_)); + tbs.addBytes(this.keyHandle_); + tbs.addBytes(this.publicKey_); + return tbs.data; + } + + /** + * sign signs data from the registration (see toBeSigned()) using the supplied + * private key. This is used in |RANDOMIZE| mode. + * + * @param {!webCrypto.CryptoKey} key ECDSA P-256 signing key in WebCrypto + * format + * @return {Promise<!Uint8Array>} ASN.1 DER encoded ECDSA signature. + */ + async sign(key) { + const algo = {name: 'ECDSA', hash: {name: 'SHA-256'}}; + var signatureBuf = await crypto.subtle.sign(algo, key, this.toBeSigned()); + var signatureRaw = new ByteString(new Uint8Array(signatureBuf)); + var signatureASN1 = new ByteBuilder(); + signatureASN1.addASN1(Tag.SEQUENCE, (b) => { + // The P-256 signature from WebCrypto is a pair of 32-byte, big-endian + // values concatenated. + b.addASN1BigInt(signatureRaw.getBytes(32)); + b.addASN1BigInt(signatureRaw.getBytes(32)); + }); + return signatureASN1.data; + } + + /** + * withReplacement marshals the registration (to base64) with the certificate + * and signature replaced. + * + * @param {!Uint8Array} certificate new certificate, as DER. + * @param {!Uint8Array} signature new signature, as DER. + * @return {string} The supplied registration data with certificate and + * signature replaced, base64. + */ + withReplacement(certificate, signature) { + var result = new ByteBuilder(); + result.addBytesFromString('\x05'); + result.addBytes(this.publicKey_); + result.addBytes(this.keyHandleLen_); + result.addBytes(this.keyHandle_); + result.addBytes(certificate); + result.addBytes(signature); + return B64_encode(result.data); + } +}; + +/** + * ConveyancePreference describes how to alter (if at all) the attestation + * certificate in a registration response. + * @enum + */ +var ConveyancePreference = { + /** + * NONE means that the token's attestation certificate should be replaced with + * a randomly generated one, and that response should be re-signed using a + * corresponding key. + */ + NONE: 1, + /** + * DIRECT means that the token's attestation cert should be returned unchanged + * to the relying party. + */ + DIRECT: 0, +}; + +/** + * conveyancePreference returns the attestation certificate replacement mode. + * + * @param {EnrollChallenge} enrollChallenge + * @return {ConveyancePreference} + */ +function conveyancePreference(enrollChallenge) { + if (enrollChallenge.hasOwnProperty('attestation') && + enrollChallenge['attestation'] == 'none') { + return ConveyancePreference.NONE; + } + return ConveyancePreference.DIRECT; +} + +/** * Handles a U2F enroll request. * @param {MessageSender} messageSender The message sender. * @param {Object} request The web page's enroll request. @@ -26,18 +362,50 @@ sendResponseOnce(sentResponse, closeable, response, sendResponse); } - function sendSuccessResponse(u2fVersion, info, clientData) { + /** + * @param {string} u2fVersion + * @param {string} registrationData Registration data, base64 + * @param {string=} opt_clientData Base64. + */ + function sendSuccessResponse(u2fVersion, registrationData, opt_clientData) { var enrollChallenges = request['registerRequests']; - var enrollChallenge = + var enrollChallengeOrNull = findEnrollChallengeOfVersion(enrollChallenges, u2fVersion); - if (!enrollChallenge) { + if (!enrollChallengeOrNull) { sendErrorResponse({errorCode: ErrorCodes.OTHER_ERROR}); return; } - var responseData = - makeEnrollResponseData(enrollChallenge, u2fVersion, info, clientData); - var response = makeU2fSuccessResponse(request, responseData); - sendResponseOnce(sentResponse, closeable, response, sendResponse); + var enrollChallenge = enrollChallengeOrNull; // Avoids compiler warning. + var appId = request['appId']; + if (enrollChallenge.hasOwnProperty('appId')) { + appId = enrollChallenge['appId']; + } + + var promise = Promise.resolve(registrationData); + switch (conveyancePreference(enrollChallenge)) { + case ConveyancePreference.NONE: { + console.log('randomizing attestation certificate'); + promise = new Promise(async function(resolve, reject) { + const reg = new Registration(registrationData, appId, opt_clientData); + const keypair = await makeCertAndKey(reg.certificate); + const signature = await reg.sign(keypair.privateKey); + resolve(reg.withReplacement(keypair.certDER, signature)); + }); + break; + } + } + + promise.then( + (registrationData) => { + var responseData = makeEnrollResponseData( + enrollChallenge, u2fVersion, registrationData, opt_clientData); + var response = makeU2fSuccessResponse(request, responseData); + sendResponseOnce(sentResponse, closeable, response, sendResponse); + }, + (err) => { + console.warn('attestation certificate replacement failed: ' + err); + sendErrorResponse({errorCode: ErrorCodes.OTHER_ERROR}); + }); } function timeout() { @@ -69,6 +437,7 @@ new WatchdogRequestHandler(watchdogTimeoutValueSeconds, timeout); var wrappedErrorCb = watchdog.wrapCallback(sendErrorResponse); var wrappedSuccessCb = watchdog.wrapCallback(sendSuccessResponse); + // TODO: Fix unused; intended to pass wrapped callbacks to Enroller? var timer = createAttenuatedTimer( FACTORY_REGISTRY.getCountdownFactory(), timeoutValueSeconds); @@ -262,7 +631,7 @@ /** @private {boolean} */ this.allowHttp_ = this.sender_.origin ? this.sender_.origin.indexOf('http://') == 0 : false; - /** @private {Closeable} */ + /** @private {RequestHandler} */ this.handler_ = null; }
diff --git a/chrome/browser/resources/cryptotoken/gnubbies.js b/chrome/browser/resources/cryptotoken/gnubbies.js index 47ac315..16dfc09 100644 --- a/chrome/browser/resources/cryptotoken/gnubbies.js +++ b/chrome/browser/resources/cryptotoken/gnubbies.js
@@ -237,7 +237,7 @@ Gnubbies.SYS_TIMER_ = new WindowTimer(); /** - * @param {number|undefined} opt_timeoutMillis Timeout in milliseconds + * @param {number=} opt_timeoutMillis Timeout in milliseconds */ Gnubbies.prototype.resetInactivityTimer = function(opt_timeoutMillis) { var millis = opt_timeoutMillis ?
diff --git a/chrome/browser/resources/cryptotoken/hidgnubbydevice.js b/chrome/browser/resources/cryptotoken/hidgnubbydevice.js index 7fdca9e..e19af67 100644 --- a/chrome/browser/resources/cryptotoken/hidgnubbydevice.js +++ b/chrome/browser/resources/cryptotoken/hidgnubbydevice.js
@@ -399,7 +399,7 @@ var frame = this.txqueue[0]; var self = this; - function transferComplete() { + var transferComplete = function() { if (chrome.runtime.lastError) { console.log(UTIL_fmt('send got lastError:')); console.log(UTIL_fmt(chrome.runtime.lastError.message)); @@ -414,7 +414,7 @@ self.writePump_(); }, 0); } - } + }; var u8 = new Uint8Array(frame);
diff --git a/chrome/browser/resources/cryptotoken/manifest.json b/chrome/browser/resources/cryptotoken/manifest.json index 62614d2..9dd756d 100644 --- a/chrome/browser/resources/cryptotoken/manifest.json +++ b/chrome/browser/resources/cryptotoken/manifest.json
@@ -48,6 +48,7 @@ "factoryregistry.js", "closeable.js", "requesthelper.js", + "asn1.js", "enroller.js", "requestqueue.js", "signer.js",
diff --git a/chrome/browser/resources/cryptotoken/sha256.js b/chrome/browser/resources/cryptotoken/sha256.js index 9a0aded..17c9206 100644 --- a/chrome/browser/resources/cryptotoken/sha256.js +++ b/chrome/browser/resources/cryptotoken/sha256.js
@@ -55,9 +55,9 @@ var W = this._W; var k = this._k; - function _rotr(w, r) { + var _rotr = function(w, r) { return ((w << (32 - r)) | (w >>> r)); - } + }; // get 16 big endian words for (var i = 0; i < 64; i += 4) { @@ -147,7 +147,7 @@ * Optionally update the hash with additional arguments, and return the * resulting hash value. * @param {...*} var_args Data buffers to hash - * @return {Array<number>} the SHA256 hash value. + * @return {!Array<number>} the SHA256 hash value. */ SHA256.prototype.digest = function(var_args) { for (var i = 0; i < arguments.length; ++i)
diff --git a/chrome/browser/resources/cryptotoken/signer.js b/chrome/browser/resources/cryptotoken/signer.js index 8c8352f..e909bd79 100644 --- a/chrome/browser/resources/cryptotoken/signer.js +++ b/chrome/browser/resources/cryptotoken/signer.js
@@ -324,7 +324,7 @@ /** @private {boolean} */ this.allowHttp_ = this.sender_.origin ? this.sender_.origin.indexOf('http://') == 0 : false; - /** @private {Closeable} */ + /** @private {RequestHandler} */ this.handler_ = null; } @@ -542,10 +542,9 @@ 'helper reported ' + reply.code.toString(16) + ', returning ' + reportedError.errorCode)); // Log non-expected reply codes if we have an url to send them - if (reportedError.errorCode == ErrorCodes.OTHER_ERROR) { - var logMsg = 'log=u2fsign&rc=' + reply.code.toString(16); - if (this.logMsgUrl_) - logMessage(logMsg, this.logMsgUrl_); + if ((reportedError.errorCode == ErrorCodes.OTHER_ERROR) && + this.logMsgUrl_) { + logMessage('log=u2fsign&rc=' + reply.code.toString(16), this.logMsgUrl_); } this.notifyError_(reportedError); } else {
diff --git a/chrome/browser/resources/cryptotoken/usbgnubbydevice.js b/chrome/browser/resources/cryptotoken/usbgnubbydevice.js index ec100c2..0d58f3d0 100644 --- a/chrome/browser/resources/cryptotoken/usbgnubbydevice.js +++ b/chrome/browser/resources/cryptotoken/usbgnubbydevice.js
@@ -276,7 +276,7 @@ var frame = this.txqueue[0]; var self = this; - function OutTransferComplete(x) { + var OutTransferComplete = function(x) { self.outTransferPending = false; if (!self.readyToUse_()) @@ -294,7 +294,7 @@ window.setTimeout(function() { self.readOneReply_(); }, 0); - } + }; var u8 = new Uint8Array(frame);
diff --git a/chrome/browser/resources/cryptotoken/webrequest.js b/chrome/browser/resources/cryptotoken/webrequest.js index dc8f7a63..700b679 100644 --- a/chrome/browser/resources/cryptotoken/webrequest.js +++ b/chrome/browser/resources/cryptotoken/webrequest.js
@@ -243,7 +243,7 @@ /** * @param {!string} string Input string - * @return {Array<number>} SHA256 hash value of string. + * @return {!Array<number>} SHA256 hash value of string. */ function sha256HashOfString(string) { var s = new SHA256();
diff --git a/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.cc b/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.cc index 8052764..f82da996 100644 --- a/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.cc +++ b/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.cc
@@ -9,7 +9,6 @@ #include "components/variations/variations_associated_data.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/geometry/insets.h" -#include "ui/gfx/geometry/rect.h" #include "ui/gfx/text_utils.h" #include "ui/views/controls/label.h" #include "ui/views/event_monitor.h" @@ -54,7 +53,8 @@ views::BubbleBorder::Arrow arrow, int string_specifier, ActivationAction activation_action) - : BubbleDialogDelegateView(anchor_view, arrow) { + : BubbleDialogDelegateView(anchor_view, arrow), + activation_action_(activation_action) { UseCompactMargins(); if (!anchor_view) SetAnchorRect(anchor_rect); @@ -68,13 +68,14 @@ SetLayoutManager(box_layout.release()); AddChildView(new views::Label(l10n_util::GetStringUTF16(string_specifier))); - - if (activation_action == ActivationAction::DO_NOT_ACTIVATE) + if (activation_action == ActivationAction::DO_NOT_ACTIVATE) { set_can_activate(activation_action == ActivationAction::ACTIVATE); + set_shadow(views::BubbleBorder::NO_SHADOW); + } views::Widget* widget = views::BubbleDialogDelegateView::CreateBubble(this); if (activation_action == ActivationAction::DO_NOT_ACTIVATE) SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); - UseCompactMargins(); + widget->Show(); if (activation_action == ActivationAction::ACTIVATE) StartAutoCloseTimer(kDelayDefault); @@ -103,6 +104,17 @@ StartAutoCloseTimer(kDelayShort); } +gfx::Rect FeaturePromoBubbleView::GetBubbleBounds() { + gfx::Rect bounds = BubbleDialogDelegateView::GetBubbleBounds(); + if (activation_action_ == ActivationAction::DO_NOT_ACTIVATE) { + if (base::i18n::IsRTL()) + bounds.Offset(5, 0); + else + bounds.Offset(-5, 0); + } + return bounds; +} + void FeaturePromoBubbleView::StartAutoCloseTimer( base::TimeDelta auto_close_duration) { timer_.Start(FROM_HERE, auto_close_duration, this,
diff --git a/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h b/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h index 04e8c9aa..88e7f91 100644 --- a/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h +++ b/chrome/browser/ui/views/feature_promos/feature_promo_bubble_view.h
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "base/timer/timer.h" +#include "ui/gfx/geometry/rect.h" #include "ui/views/bubble/bubble_dialog_delegate.h" namespace gfx { @@ -62,12 +63,14 @@ bool OnMousePressed(const ui::MouseEvent& event) override; void OnMouseEntered(const ui::MouseEvent& event) override; void OnMouseExited(const ui::MouseEvent& event) override; + gfx::Rect GetBubbleBounds() override; // Starts a timer to close the promo bubble. void StartAutoCloseTimer(base::TimeDelta auto_close_duration); // Timer used to auto close the bubble. base::OneShotTimer timer_; + const ActivationAction activation_action_; DISALLOW_COPY_AND_ASSIGN(FeaturePromoBubbleView); };
diff --git a/components/cronet/url_request_context_config.cc b/components/cronet/url_request_context_config.cc index 79fc16d..88ad51b 100644 --- a/components/cronet/url_request_context_config.cc +++ b/components/cronet/url_request_context_config.cc
@@ -42,6 +42,7 @@ // TODO(xunjieli): Refactor constants in io_thread.cc. const char kQuicFieldTrialName[] = "QUIC"; const char kQuicConnectionOptions[] = "connection_options"; +const char kQuicClientConnectionOptions[] = "client_connection_options"; const char kQuicStoreServerConfigsInProperties[] = "store_server_configs_in_properties"; const char kQuicMaxServerConfigsStoredInProperties[] = @@ -227,6 +228,13 @@ net::ParseQuicConnectionOptions(quic_connection_options); } + std::string quic_client_connection_options; + if (quic_args->GetString(kQuicClientConnectionOptions, + &quic_client_connection_options)) { + session_params->quic_client_connection_options = + net::ParseQuicConnectionOptions(quic_client_connection_options); + } + // TODO(rtenneti): Delete this option after apps stop using it. // Added this for backward compatibility. bool quic_store_server_configs_in_properties = false;
diff --git a/components/cronet/url_request_context_config_unittest.cc b/components/cronet/url_request_context_config_unittest.cc index 605d103f..4dbf887 100644 --- a/components/cronet/url_request_context_config_unittest.cc +++ b/components/cronet/url_request_context_config_unittest.cc
@@ -318,6 +318,65 @@ EXPECT_EQ(11, params->quic_max_idle_time_before_crypto_handshake_seconds); } +TEST(URLURLRequestContextConfigTest, SetQuicConnectionOptions) { + base::test::ScopedTaskEnvironment scoped_task_environment_( + base::test::ScopedTaskEnvironment::MainThreadType::IO); + + URLRequestContextConfig config( + // Enable QUIC. + true, + // QUIC User Agent ID. + "Default QUIC User Agent ID", + // Enable SPDY. + true, + // Enable Brotli. + false, + // Type of http cache. + URLRequestContextConfig::HttpCacheType::DISK, + // Max size of http cache in bytes. + 1024000, + // Disable caching for HTTP responses. Other information may be stored in + // the cache. + false, + // Storage path for http cache and cookie storage. + "/data/data/org.chromium.net/app_cronet_test/test_storage", + // User-Agent request header field. + "fake agent", + // JSON encoded experimental options. + "{\"QUIC\":{\"connection_options\":\"TIME,TBBR,REJ\"," + "\"client_connection_options\":\"TBBR,1RTT\"}}", + // MockCertVerifier to use for testing purposes. + std::unique_ptr<net::CertVerifier>(), + // Enable network quality estimator. + false, + // Enable Public Key Pinning bypass for local trust anchors. + true, + // Certificate verifier cache data. + ""); + + net::URLRequestContextBuilder builder; + net::NetLog net_log; + config.ConfigureURLRequestContextBuilder(&builder, &net_log); + // Set a ProxyConfigService to avoid DCHECK failure when building. + builder.set_proxy_config_service( + base::MakeUnique<net::ProxyConfigServiceFixed>( + net::ProxyConfig::CreateDirect())); + std::unique_ptr<net::URLRequestContext> context(builder.Build()); + const net::HttpNetworkSession::Params* params = + context->GetNetworkSessionParams(); + + net::QuicTagVector connection_options; + connection_options.push_back(net::kTIME); + connection_options.push_back(net::kTBBR); + connection_options.push_back(net::kREJ); + EXPECT_EQ(connection_options, params->quic_connection_options); + + net::QuicTagVector client_connection_options; + client_connection_options.push_back(net::kTBBR); + client_connection_options.push_back(net::k1RTT); + EXPECT_EQ(client_connection_options, params->quic_client_connection_options); +} + // See stale_host_resolver_unittest.cc for test of StaleDNS options. } // namespace cronet
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc index af94574..522ef9e 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc
@@ -163,7 +163,11 @@ secure_proxy_checker_.reset( new SecureProxyChecker(basic_url_request_context_getter)); - warmup_url_fetcher_.reset(new WarmupURLFetcher(url_request_context_getter)); + warmup_url_fetcher_.reset(new WarmupURLFetcher( + url_request_context_getter, + base::BindRepeating( + &DataReductionProxyConfig::HandleWarmupFetcherResponse, + base::Unretained(this)))); if (ShouldAddDefaultProxyBypassRules()) AddDefaultProxyBypassRules(); @@ -178,6 +182,7 @@ void DataReductionProxyConfig::OnNewClientConfigFetched() { DCHECK(thread_checker_.CalledOnValidThread()); ReloadConfig(); + FetchWarmupURL(); } void DataReductionProxyConfig::ReloadConfig() { @@ -201,6 +206,26 @@ return IsDataReductionProxy(request->proxy_server(), proxy_info); } +bool DataReductionProxyConfig::IsDataReductionProxyServerCore( + const net::ProxyServer& proxy_server) const { + DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK(IsDataReductionProxy(proxy_server, nullptr /* proxy_info */)); + + const net::HostPortPair& host_port_pair = proxy_server.host_port_pair(); + + const std::vector<DataReductionProxyServer>& data_reduction_proxy_servers = + config_values_->proxies_for_http(); + + const auto proxy_it = std::find_if( + data_reduction_proxy_servers.begin(), data_reduction_proxy_servers.end(), + [&host_port_pair](const DataReductionProxyServer& proxy) { + return proxy.proxy_server().is_valid() && + proxy.proxy_server().host_port_pair().Equals(host_port_pair); + }); + + return proxy_it->IsCoreProxy(); +} + bool DataReductionProxyConfig::IsDataReductionProxy( const net::ProxyServer& proxy_server, DataReductionProxyTypeInfo* proxy_info) const { @@ -413,6 +438,56 @@ network_properties_manager_ = manager; } +void DataReductionProxyConfig::HandleWarmupFetcherResponse( + const net::ProxyServer& proxy_server, + bool success_response) { + DCHECK(thread_checker_.CalledOnValidThread()); + + // Check the proxy server used, or disable all data saver proxies? + if (!IsDataReductionProxy(proxy_server, nullptr)) { + // No need to do anything here. + return; + } + + bool is_secure_drp_proxy = proxy_server.is_https() || proxy_server.is_quic(); + bool is_core_proxy = IsDataReductionProxyServerCore(proxy_server); + if (is_secure_drp_proxy && is_core_proxy) { + UMA_HISTOGRAM_BOOLEAN( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.Core", + success_response); + } else if (is_secure_drp_proxy && !is_core_proxy) { + UMA_HISTOGRAM_BOOLEAN( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + success_response); + } else if (!is_secure_drp_proxy && is_core_proxy) { + UMA_HISTOGRAM_BOOLEAN( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "InsecureProxy.Core", + success_response); + } else { + UMA_HISTOGRAM_BOOLEAN( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "InsecureProxy.NonCore", + success_response); + } + + bool warmup_url_failed_past = + network_properties_manager_->HasWarmupURLProbeFailed(is_secure_drp_proxy, + is_core_proxy); + + network_properties_manager_->SetHasWarmupURLProbeFailed( + is_secure_drp_proxy, is_core_proxy, + !success_response /* warmup failed */); + + if (warmup_url_failed_past != + network_properties_manager_->HasWarmupURLProbeFailed(is_secure_drp_proxy, + is_core_proxy)) { + ReloadConfig(); + } +} + void DataReductionProxyConfig::HandleSecureProxyCheckResponse( const std::string& response, const net::URLRequestStatus& status,
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h index cdb4d03..3a06b6b 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h
@@ -223,6 +223,13 @@ // Returns the ID of the current network by calling the platform APIs. virtual std::string GetCurrentNetworkID() const; + // Callback that is executed when the warmup URL fetch is complete. + // |proxy_server| is the proxy server over which the warmup URL was fetched. + // |success_response| is true if the fetching of the URL was successful or + // not. + void HandleWarmupFetcherResponse(const net::ProxyServer& proxy_server, + bool success_response); + private: friend class MockDataReductionProxyConfig; friend class TestDataReductionProxyConfig; @@ -297,6 +304,12 @@ // Fetches the warmup URL. void FetchWarmupURL(); + // Returns true if |proxy_server| is a core data reduction proxy server. + // Should be called only if |proxy_server| is a valid data reduction proxy + // server. + bool IsDataReductionProxyServerCore( + const net::ProxyServer& proxy_server) const; + // URL fetcher used for performing the secure proxy check. std::unique_ptr<SecureProxyChecker> secure_proxy_checker_;
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc index f4329f7..0a2eaf02 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
@@ -159,6 +159,10 @@ context_->Init(); + // Disable fetching of warmup URL to avoid generating extra traffic which + // would need to be satisfied using mock sockets. + test_context_->DisableWarmupURLFetch(); + test_context_->InitSettings(); ResetBackoffEntryReleaseTime(); test_context_->test_config_client()->SetNow(base::Time::UnixEpoch());
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h index ed0acfe8..7855fe8 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h
@@ -108,6 +108,7 @@ using DataReductionProxyConfig::UpdateConfigForTesting; using DataReductionProxyConfig::OnInsecureProxyWarmupURLProbeStatusChange; + using DataReductionProxyConfig::HandleWarmupFetcherResponse; private: bool GetIsCaptivePortal() const override;
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc index d52e963..354e539 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
@@ -75,6 +75,8 @@ for (const net::ProxyServer& proxy : proxies_for_http) proxy_strings.push_back(proxy.ToURI()); + // Proxies specified via kDataReductionProxyHttpProxies command line switch + // have type ProxyServer::UNSPECIFIED_TYPE. base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( data_reduction_proxy::switches::kDataReductionProxyHttpProxies, base::JoinString(proxy_strings, ";")); @@ -1099,4 +1101,129 @@ *request.get(), *previews_decider.get())); } +TEST_F(DataReductionProxyConfigTest, HandleWarmupFetcherResponse) { + base::HistogramTester histogram_tester; + const net::URLRequestStatus kSuccess(net::URLRequestStatus::SUCCESS, net::OK); + const net::ProxyServer kHttpsProxy = net::ProxyServer::FromURI( + "https://origin.net:443", net::ProxyServer::SCHEME_HTTP); + const net::ProxyServer kHttpProxy = net::ProxyServer::FromURI( + "fallback.net:80", net::ProxyServer::SCHEME_HTTP); + const net::ProxyServer kNonDataSaverProxy = net::ProxyServer::FromURI( + "https://non-data-saver-proxy.net:443", net::ProxyServer::SCHEME_HTTP); + + SetProxiesForHttpOnCommandLine({kHttpsProxy, kHttpProxy}); + ResetSettings(); + + // The proxy is enabled. + test_config()->UpdateConfigForTesting(true, true, true); + test_config()->OnNewClientConfigFetched(); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); + + // Report failed warmup for a non-DataSaver proxy, and verify that it does not + // change the list of data saver proxies. + test_config()->HandleWarmupFetcherResponse(net::ProxyServer(), + false /* success_response */); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); + + // Report successful warmup of |kHttpsProxy|. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, true); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 1, 1); + + // Report failed warmup |kHttpsProxy| and verify it is removed from the list + // of proxies. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, false); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 0, 1); + + // Report failed warmup |kHttpsProxy| again, and verify it does not change the + // list of proxies. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, false); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 0, 2); + + // |kHttpsProxy| should now be added back to the list of proxies. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, true); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 1, 2); + + // Report successful warmup |kHttpsProxy| again, and verify that there is no + // change in the list of proxies.. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, true); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 1, 3); + + // |kHttpsProxy| should be removed again from the list of proxies. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, false); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 0, 3); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 1, 3); + + // Now report failed warmup for |kHttpProxy| and verify that it is also + // removed from the list of proxies. + test_config()->HandleWarmupFetcherResponse(kHttpProxy, false); + EXPECT_EQ(std::vector<net::ProxyServer>({}), GetConfiguredProxiesForHttp()); + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "InsecureProxy.NonCore", + 0, 1); + + // Both proxies should be added back. + test_config()->HandleWarmupFetcherResponse(kHttpsProxy, true); + test_config()->HandleWarmupFetcherResponse(kHttpProxy, true); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 0, 3); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "SecureProxy.NonCore", + 1, 4); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "InsecureProxy.NonCore", + 0, 1); + histogram_tester.ExpectBucketCount( + "DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch." + "InsecureProxy.NonCore", + 1, 1); + + // If the warmup URL is unsuccessfully fetched using a non-data saver proxy, + // then there is no change in the list of proxies. + test_config()->HandleWarmupFetcherResponse(kNonDataSaverProxy, false); + EXPECT_EQ(std::vector<net::ProxyServer>({kHttpsProxy, kHttpProxy}), + GetConfiguredProxiesForHttp()); +} + } // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/browser/warmup_url_fetcher.cc b/components/data_reduction_proxy/core/browser/warmup_url_fetcher.cc index 735738e..365de618 100644 --- a/components/data_reduction_proxy/core/browser/warmup_url_fetcher.cc +++ b/components/data_reduction_proxy/core/browser/warmup_url_fetcher.cc
@@ -4,6 +4,7 @@ #include "components/data_reduction_proxy/core/browser/warmup_url_fetcher.h" +#include "base/callback.h" #include "base/guid.h" #include "base/metrics/histogram_macros.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" @@ -11,6 +12,7 @@ #include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.h" #include "components/data_use_measurement/core/data_use_user_data.h" #include "net/base/load_flags.h" +#include "net/http/http_status_code.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_request_context_getter.h" @@ -20,8 +22,10 @@ WarmupURLFetcher::WarmupURLFetcher( const scoped_refptr<net::URLRequestContextGetter>& - url_request_context_getter) - : url_request_context_getter_(url_request_context_getter) { + url_request_context_getter, + WarmupURLFetcherCallback callback) + : url_request_context_getter_(url_request_context_getter), + callback_(callback) { DCHECK(url_request_context_getter_); } @@ -111,7 +115,23 @@ util::ConvertNetProxySchemeToProxyScheme( source->ProxyServerUsed().scheme()), PROXY_SCHEME_MAX); + + if (!source->GetStatus().is_success() && + source->GetStatus().error() == net::ERR_INTERNET_DISCONNECTED) { + // Fetching failed due to Internet unavailability, and not due to some + // error. Set the proxy server to unknown. + callback_.Run(net::ProxyServer(), true); + return; + } } + + bool success_response = + source->GetStatus().status() == net::URLRequestStatus::SUCCESS && + source->GetResponseCode() == net::HTTP_NO_CONTENT && + source->GetResponseHeaders() && + HasDataReductionProxyViaHeader(*(source->GetResponseHeaders()), + nullptr /* has_intermediary */); + callback_.Run(source->ProxyServerUsed(), success_response); } } // namespace data_reduction_proxy \ No newline at end of file
diff --git a/components/data_reduction_proxy/core/browser/warmup_url_fetcher.h b/components/data_reduction_proxy/core/browser/warmup_url_fetcher.h index 0e9b61cc..f470b32 100644 --- a/components/data_reduction_proxy/core/browser/warmup_url_fetcher.h +++ b/components/data_reduction_proxy/core/browser/warmup_url_fetcher.h
@@ -7,6 +7,7 @@ #include <utility> +#include "base/callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "net/url_request/url_fetcher_delegate.h" @@ -15,6 +16,7 @@ namespace net { +class ProxyServer; class URLFetcher; class URLRequestContextGetter; @@ -25,8 +27,14 @@ // URLFetcherDelegate for fetching the warmup URL. class WarmupURLFetcher : public net::URLFetcherDelegate { public: - explicit WarmupURLFetcher(const scoped_refptr<net::URLRequestContextGetter>& - url_request_context_getter); + // The proxy server that was used to fetch the request, and whether the fetch + // was successful. + typedef base::RepeatingCallback<void(const net::ProxyServer&, bool)> + WarmupURLFetcherCallback; + + WarmupURLFetcher(const scoped_refptr<net::URLRequestContextGetter>& + url_request_context_getter, + WarmupURLFetcherCallback callback); ~WarmupURLFetcher() override; @@ -46,6 +54,10 @@ // The URLFetcher being used for fetching the warmup URL. std::unique_ptr<net::URLFetcher> fetcher_; + // Callback that should be executed when the fetching of the warmup URL is + // completed. + WarmupURLFetcherCallback callback_; + DISALLOW_COPY_AND_ASSIGN(WarmupURLFetcher); };
diff --git a/components/data_reduction_proxy/core/browser/warmup_url_fetcher_unittest.cc b/components/data_reduction_proxy/core/browser/warmup_url_fetcher_unittest.cc index b8dad96..9821129 100644 --- a/components/data_reduction_proxy/core/browser/warmup_url_fetcher_unittest.cc +++ b/components/data_reduction_proxy/core/browser/warmup_url_fetcher_unittest.cc
@@ -6,6 +6,7 @@ #include <vector> +#include "base/bind_helpers.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -27,14 +28,33 @@ public: WarmupURLFetcherTest(const scoped_refptr<net::URLRequestContextGetter>& url_request_context_getter) - : WarmupURLFetcher(url_request_context_getter) {} + : WarmupURLFetcher(url_request_context_getter, + base::BindRepeating( + &WarmupURLFetcherTest::HandleWarmupFetcherResponse, + base::Unretained(this))) {} ~WarmupURLFetcherTest() override {} + size_t callback_received_count() const { return callback_received_count_; } + const net::ProxyServer& proxy_server_last() const { + return proxy_server_last_; + } + bool success_response_last() const { return success_response_last_; } + using WarmupURLFetcher::FetchWarmupURL; using WarmupURLFetcher::GetWarmupURLWithQueryParam; private: + void HandleWarmupFetcherResponse(const net::ProxyServer& proxy_server, + bool success_response) { + callback_received_count_++; + proxy_server_last_ = proxy_server; + success_response_last_ = success_response; + } + + size_t callback_received_count_ = 0; + net::ProxyServer proxy_server_last_; + bool success_response_last_ = false; DISALLOW_COPY_AND_ASSIGN(WarmupURLFetcherTest); }; @@ -70,7 +90,7 @@ EXPECT_TRUE(query_param_different); } -TEST(WarmupURLFetcherTest, TestSuccessfulFetchWarmupURL) { +TEST(WarmupURLFetcherTest, TestSuccessfulFetchWarmupURLNoViaHeader) { base::HistogramTester histogram_tester; base::MessageLoopForIO message_loop; const std::string config = "foobarbaz"; @@ -113,6 +133,66 @@ "DataReductionProxy.WarmupURL.ProxySchemeUsed", util::ConvertNetProxySchemeToProxyScheme(net::ProxyServer::SCHEME_DIRECT), 1); + + EXPECT_EQ(1u, warmup_url_fetcher.callback_received_count()); + EXPECT_EQ(net::ProxyServer::SCHEME_DIRECT, + warmup_url_fetcher.proxy_server_last().scheme()); + // success_response_last() should be false since the response does not contain + // the via header. + EXPECT_FALSE(warmup_url_fetcher.success_response_last()); +} + +TEST(WarmupURLFetcherTest, TestSuccessfulFetchWarmupURLWithViaHeader) { + base::HistogramTester histogram_tester; + base::MessageLoopForIO message_loop; + const std::string config = "foobarbaz"; + std::vector<std::unique_ptr<net::SocketDataProvider>> socket_data_providers; + net::MockClientSocketFactory mock_socket_factory; + net::MockRead success_reads[3]; + success_reads[0] = net::MockRead( + "HTTP/1.1 204 OK\r\nVia: 1.1 Chrome-Compression-Proxy\r\n\r\n"); + success_reads[1] = net::MockRead(net::ASYNC, config.c_str(), config.length()); + success_reads[2] = net::MockRead(net::SYNCHRONOUS, net::OK); + + socket_data_providers.push_back( + (base::MakeUnique<net::StaticSocketDataProvider>( + success_reads, arraysize(success_reads), nullptr, 0))); + mock_socket_factory.AddSocketDataProvider(socket_data_providers.back().get()); + + std::unique_ptr<net::TestURLRequestContext> test_request_context( + new net::TestURLRequestContext(true)); + + test_request_context->set_client_socket_factory(&mock_socket_factory); + test_request_context->Init(); + scoped_refptr<net::URLRequestContextGetter> request_context_getter = + new net::TestURLRequestContextGetter(message_loop.task_runner(), + std::move(test_request_context)); + + WarmupURLFetcherTest warmup_url_fetcher(request_context_getter); + warmup_url_fetcher.FetchWarmupURL(); + base::RunLoop().RunUntilIdle(); + + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURL.FetchInitiated", 1, 1); + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURL.FetchSuccessful", 1, 1); + histogram_tester.ExpectUniqueSample("DataReductionProxy.WarmupURL.NetError", + net::OK, 1); + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURL.HttpResponseCode", net::HTTP_NO_CONTENT, 1); + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURL.HasViaHeader", 1, 1); + histogram_tester.ExpectUniqueSample( + "DataReductionProxy.WarmupURL.ProxySchemeUsed", + util::ConvertNetProxySchemeToProxyScheme(net::ProxyServer::SCHEME_DIRECT), + 1); + + EXPECT_EQ(1u, warmup_url_fetcher.callback_received_count()); + EXPECT_EQ(net::ProxyServer::SCHEME_DIRECT, + warmup_url_fetcher.proxy_server_last().scheme()); + // success_response_last() should be true since the response contains the via + // header. + EXPECT_TRUE(warmup_url_fetcher.success_response_last()); } TEST(WarmupURLFetcherTest, TestConnectionResetFetchWarmupURL) { @@ -155,6 +235,10 @@ 0); histogram_tester.ExpectTotalCount( "DataReductionProxy.WarmupURL.ProxySchemeUsed", 0); + EXPECT_EQ(1u, warmup_url_fetcher.callback_received_count()); + EXPECT_EQ(net::ProxyServer::SCHEME_INVALID, + warmup_url_fetcher.proxy_server_last().scheme()); + EXPECT_FALSE(warmup_url_fetcher.success_response_last()); } } // namespace
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_server.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_server.cc index ddb01aa..eccf2bd 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_server.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_server.cc
@@ -50,6 +50,10 @@ return net_proxy_servers; } +bool DataReductionProxyServer::IsCoreProxy() const { + return proxy_type_ == ProxyServer_ProxyType_CORE; +} + ProxyServer_ProxyType DataReductionProxyServer::GetProxyTypeForTesting() const { return proxy_type_; }
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_server.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_server.h index 000267c7..24767124 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_server.h +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_server.h
@@ -35,6 +35,8 @@ const std::vector<DataReductionProxyServer>& data_reduction_proxy_servers); + bool IsCoreProxy() const; + // Returns |proxy_type_| for verification by tests. ProxyServer_ProxyType GetProxyTypeForTesting() const;
diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc index 92cc461..3844014 100644 --- a/components/exo/buffer.cc +++ b/components/exo/buffer.cc
@@ -86,10 +86,8 @@ unsigned texture_id, GLenum target, gpu::Mailbox* mailbox) { - gles2->ActiveTexture(GL_TEXTURE0); - gles2->BindTexture(target, texture_id); gles2->GenMailboxCHROMIUM(mailbox->name); - gles2->ProduceTextureCHROMIUM(target, mailbox->name); + gles2->ProduceTextureDirectCHROMIUM(texture_id, mailbox->name); } } // namespace
diff --git a/components/search_engines/keyword_table.cc b/components/search_engines/keyword_table.cc index bcd3fc0..8a67ac85 100644 --- a/components/search_engines/keyword_table.cc +++ b/components/search_engines/keyword_table.cc
@@ -8,6 +8,7 @@ #include <memory> #include <set> +#include <tuple> #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -102,7 +103,6 @@ return base::JoinString(columns, std::string(concatenated ? " || " : ", ")); } - // Inserts the data from |data| into |s|. |s| is assumed to have slots for all // the columns in the keyword table. |id_column| is the slot number to bind // |data|'s |id| to; |starting_column| is the slot number of the first of a @@ -132,14 +132,16 @@ s->BindString(starting_column + 5, data.originating_url.is_valid() ? history::URLDatabase::GURLToDatabaseURL(data.originating_url) : std::string()); - s->BindInt64(starting_column + 6, data.date_created.ToTimeT()); + s->BindInt64(starting_column + 6, + data.date_created.since_origin().InMicroseconds()); s->BindInt(starting_column + 7, data.usage_count); s->BindString(starting_column + 8, base::JoinString(data.input_encodings, ";")); s->BindString(starting_column + 9, data.suggestions_url); s->BindInt(starting_column + 10, data.prepopulate_id); s->BindBool(starting_column + 11, data.created_by_policy); - s->BindInt64(starting_column + 12, data.last_modified.ToTimeT()); + s->BindInt64(starting_column + 12, + data.last_modified.since_origin().InMicroseconds()); s->BindString(starting_column + 13, data.sync_guid); s->BindString(starting_column + 14, alternate_urls); s->BindString(starting_column + 15, data.image_url); @@ -147,7 +149,8 @@ s->BindString(starting_column + 17, data.suggestions_url_post_params); s->BindString(starting_column + 18, data.image_url_post_params); s->BindString(starting_column + 19, data.new_tab_url); - s->BindInt64(starting_column + 20, data.last_visited.ToTimeT()); + s->BindInt64(starting_column + 20, + data.last_visited.since_origin().InMicroseconds()); } WebDatabaseTable::TypeKey GetKey() { @@ -222,6 +225,9 @@ case 76: *update_compatible_version = true; return MigrateToVersion76RemoveInstantColumns(); + case 77: + *update_compatible_version = true; + return MigrateToVersion77IncreaseTimePrecision(); } return true; @@ -396,6 +402,42 @@ transaction.Commit(); } +bool KeywordTable::MigrateToVersion77IncreaseTimePrecision() { + sql::Transaction transaction(db_); + if (!transaction.Begin()) + return false; + + std::string query( + "SELECT id, date_created, last_modified, last_visited FROM keywords"); + sql::Statement s(db_->GetUniqueStatement(query.c_str())); + std::vector<std::tuple<TemplateURLID, Time, Time, Time>> updates; + while (s.Step()) { + updates.push_back(std::make_tuple( + s.ColumnInt64(0), Time::FromTimeT(s.ColumnInt64(1)), + Time::FromTimeT(s.ColumnInt64(2)), Time::FromTimeT(s.ColumnInt64(3)))); + } + if (!s.Succeeded()) + return false; + + for (auto tuple : updates) { + sql::Statement update_statement(db_->GetCachedStatement( + SQL_FROM_HERE, + "UPDATE keywords SET date_created = ?, last_modified = ?, last_visited " + "= ? WHERE id = ? ")); + update_statement.BindInt64( + 0, std::get<1>(tuple).since_origin().InMicroseconds()); + update_statement.BindInt64( + 1, std::get<2>(tuple).since_origin().InMicroseconds()); + update_statement.BindInt64( + 2, std::get<3>(tuple).since_origin().InMicroseconds()); + update_statement.BindInt64(3, std::get<0>(tuple)); + if (!update_statement.Run()) { + return false; + } + } + return transaction.Commit(); +} + // static bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, TemplateURLData* data) { @@ -422,8 +464,10 @@ data->input_encodings = base::SplitString( s.ColumnString(9), ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); data->id = s.ColumnInt64(0); - data->date_created = Time::FromTimeT(s.ColumnInt64(7)); - data->last_modified = Time::FromTimeT(s.ColumnInt64(13)); + data->date_created = + base::Time() + base::TimeDelta::FromMicroseconds(s.ColumnInt64(7)); + data->last_modified = + base::Time() + base::TimeDelta::FromMicroseconds(s.ColumnInt64(13)); data->created_by_policy = s.ColumnBool(12); data->usage_count = s.ColumnInt(8); data->prepopulate_id = s.ColumnInt(11); @@ -442,7 +486,8 @@ } } - data->last_visited = Time::FromTimeT(s.ColumnInt64(21)); + data->last_visited = + base::Time() + base::TimeDelta::FromMicroseconds(s.ColumnInt64(21)); return true; }
diff --git a/components/search_engines/keyword_table.h b/components/search_engines/keyword_table.h index 86059ab8..340d2da 100644 --- a/components/search_engines/keyword_table.h +++ b/components/search_engines/keyword_table.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <string> +#include <utility> #include <vector> #include "base/compiler_specific.h" @@ -126,6 +127,7 @@ bool MigrateToVersion68RemoveShowInDefaultListColumn(); bool MigrateToVersion69AddLastVisitedColumn(); bool MigrateToVersion76RemoveInstantColumns(); + bool MigrateToVersion77IncreaseTimePrecision(); private: friend class KeywordTableTest;
diff --git a/components/test/data/web_database/version_76.sql b/components/test/data/web_database/version_76.sql new file mode 100644 index 0000000..8cc6a351 --- /dev/null +++ b/components/test/data/web_database/version_76.sql
@@ -0,0 +1,26 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('mmap_status','-1'); +INSERT INTO "meta" VALUES('version','76'); +INSERT INTO "meta" VALUES('last_compatible_version','72'); +CREATE TABLE token_service (service VARCHAR PRIMARY KEY NOT NULL,encrypted_token BLOB); +CREATE TABLE keywords (id INTEGER PRIMARY KEY,short_name VARCHAR NOT NULL,keyword VARCHAR NOT NULL,favicon_url VARCHAR NOT NULL,url VARCHAR NOT NULL,safe_for_autoreplace INTEGER,originating_url VARCHAR,date_created INTEGER DEFAULT 0,usage_count INTEGER DEFAULT 0,input_encodings VARCHAR,suggest_url VARCHAR,prepopulate_id INTEGER DEFAULT 0,created_by_policy INTEGER DEFAULT 0,last_modified INTEGER DEFAULT 0,sync_guid VARCHAR,alternate_urls VARCHAR,image_url VARCHAR,search_url_post_params VARCHAR,suggest_url_post_params VARCHAR,image_url_post_params VARCHAR,new_tab_url VARCHAR,last_visited INTEGER DEFAULT 0); +INSERT INTO "keywords" VALUES(2,'Google','google.com','https://www.google.com/favicon.ico','{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:iOSSearchLanguage}{google:searchClient}{google:sourceId}{google:contextualSearchVersion}ie={inputEncoding}',1,'',123,0,'UTF-8','{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&gs_ri={google:suggestRid}&xssi=t&q={searchTerms}&{google:inputType}{google:cursorPosition}{google:currentPageUrl}{google:pageClassification}{google:searchVersion}{google:sessionToken}{google:prefetchQuery}sugkey={google:suggestAPIKeyParameter}',1,0,456,'1f2ebc45-c5bc-4c15-afc1-e215b3a0ac96','["{google:baseURL}#q={searchTerms}","{google:baseURL}search#q={searchTerms}","{google:baseURL}webhp#q={searchTerms}","{google:baseURL}s#q={searchTerms}","{google:baseURL}s?q={searchTerms}"]','{google:baseURL}searchbyimage/upload','','','encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}','{google:baseURL}_/chrome/newtab?{google:RLZ}ie={inputEncoding}',789); +CREATE TABLE autofill (name VARCHAR, value VARCHAR, value_lower VARCHAR, date_created INTEGER DEFAULT 0, date_last_used INTEGER DEFAULT 0, count INTEGER DEFAULT 1, PRIMARY KEY (name, value)); +CREATE TABLE credit_cards ( guid VARCHAR PRIMARY KEY, name_on_card VARCHAR, expiration_month INTEGER, expiration_year INTEGER, card_number_encrypted BLOB, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '', use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, billing_address_id VARCHAR); +CREATE TABLE autofill_profiles ( guid VARCHAR PRIMARY KEY, company_name VARCHAR, street_address VARCHAR, dependent_locality VARCHAR, city VARCHAR, state VARCHAR, zipcode VARCHAR, sorting_code VARCHAR, country_code VARCHAR, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '', language_code VARCHAR, use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, validity_bitfield UNSIGNED NOT NULL DEFAULT 0); +CREATE TABLE autofill_profile_names ( guid VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, full_name VARCHAR); +CREATE TABLE autofill_profile_emails ( guid VARCHAR, email VARCHAR); +CREATE TABLE autofill_profile_phones ( guid VARCHAR, number VARCHAR); +CREATE TABLE autofill_profiles_trash ( guid VARCHAR); +CREATE TABLE masked_credit_cards (id VARCHAR,status VARCHAR,name_on_card VARCHAR,network VARCHAR,last_four VARCHAR,exp_month INTEGER DEFAULT 0,exp_year INTEGER DEFAULT 0, bank_name VARCHAR, type INTEGER DEFAULT 0); +CREATE TABLE unmasked_credit_cards (id VARCHAR,card_number_encrypted VARCHAR, use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, unmask_date INTEGER NOT NULL DEFAULT 0); +CREATE TABLE server_card_metadata (id VARCHAR NOT NULL,use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, billing_address_id VARCHAR); +CREATE TABLE server_addresses (id VARCHAR,company_name VARCHAR,street_address VARCHAR,address_1 VARCHAR,address_2 VARCHAR,address_3 VARCHAR,address_4 VARCHAR,postal_code VARCHAR,sorting_code VARCHAR,country_code VARCHAR,language_code VARCHAR, recipient_name VARCHAR, phone_number VARCHAR); +CREATE TABLE server_address_metadata (id VARCHAR NOT NULL,use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, has_converted BOOL NOT NULL DEFAULT FALSE); +CREATE TABLE autofill_sync_metadata (storage_key VARCHAR PRIMARY KEY NOT NULL,value BLOB); +CREATE TABLE autofill_model_type_state (id INTEGER PRIMARY KEY, value BLOB); +CREATE INDEX autofill_name ON autofill (name); +CREATE INDEX autofill_name_value_lower ON autofill (name, value_lower); +COMMIT;
diff --git a/components/viz/common/gl_helper.cc b/components/viz/common/gl_helper.cc index 3dddb131..bc4d27d7 100644 --- a/components/viz/common/gl_helper.cc +++ b/components/viz/common/gl_helper.cc
@@ -883,7 +883,7 @@ GLuint texture_id) { gpu::Mailbox mailbox; gl_->GenMailboxCHROMIUM(mailbox.name); - gl_->ProduceTextureDirectCHROMIUM(texture_id, GL_TEXTURE_2D, mailbox.name); + gl_->ProduceTextureDirectCHROMIUM(texture_id, mailbox.name); gpu::SyncToken sync_token; GenerateSyncToken(&sync_token); @@ -897,8 +897,7 @@ return 0; if (sync_token.HasData()) WaitSyncToken(sync_token); - GLuint texture = - gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint texture = gl_->CreateAndConsumeTextureCHROMIUM(mailbox.name); return texture; }
diff --git a/components/viz/common/yuv_readback_unittest.cc b/components/viz/common/yuv_readback_unittest.cc index ff5b30e5..05753086 100644 --- a/components/viz/common/yuv_readback_unittest.cc +++ b/components/viz/common/yuv_readback_unittest.cc
@@ -357,7 +357,7 @@ gpu::Mailbox mailbox; gl_->GenMailboxCHROMIUM(mailbox.name); EXPECT_FALSE(mailbox.IsZero()); - gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + gl_->ProduceTextureDirectCHROMIUM(src_texture, mailbox.name); const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); gl_->ShallowFlushCHROMIUM();
diff --git a/components/viz/service/display/gl_renderer_copier.cc b/components/viz/service/display/gl_renderer_copier.cc index d0dbab21..a5d9bc2 100644 --- a/components/viz/service/display/gl_renderer_copier.cc +++ b/components/viz/service/display/gl_renderer_copier.cc
@@ -232,8 +232,8 @@ if (!request.mailbox().IsZero()) { if (request.sync_token().HasData()) gl->WaitSyncTokenCHROMIUM(request.sync_token().GetConstData()); - result_texture = gl->CreateAndConsumeTextureCHROMIUM( - GL_TEXTURE_2D, request.mailbox().name); + result_texture = + gl->CreateAndConsumeTextureCHROMIUM(request.mailbox().name); } } if (result_texture == 0) { @@ -436,8 +436,7 @@ mailbox = request->mailbox(); } else { gl->GenMailboxCHROMIUM(mailbox.name); - gl->ProduceTextureDirectCHROMIUM(result_texture, GL_TEXTURE_2D, - mailbox.name); + gl->ProduceTextureDirectCHROMIUM(result_texture, mailbox.name); } const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); gl->ShallowFlushCHROMIUM();
diff --git a/components/viz/service/display/gl_renderer_copier_pixeltest.cc b/components/viz/service/display/gl_renderer_copier_pixeltest.cc index e6c8247..72599223 100644 --- a/components/viz/service/display/gl_renderer_copier_pixeltest.cc +++ b/components/viz/service/display/gl_renderer_copier_pixeltest.cc
@@ -198,8 +198,7 @@ // Bind the texture to a framebuffer from which to read the pixels. if (sync_token.HasData()) gl_->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); - GLuint texture = - gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint texture = gl_->CreateAndConsumeTextureCHROMIUM(mailbox.name); GLuint framebuffer = 0; gl_->GenFramebuffers(1, &framebuffer); gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer);
diff --git a/components/webdata/common/BUILD.gn b/components/webdata/common/BUILD.gn index 188da12..00b2973 100644 --- a/components/webdata/common/BUILD.gn +++ b/components/webdata/common/BUILD.gn
@@ -63,6 +63,7 @@ "//components/test/data/web_database/version_73_with_type_column.sql", "//components/test/data/web_database/version_74.sql", "//components/test/data/web_database/version_75.sql", + "//components/test/data/web_database/version_76.sql", ] outputs = [ "{{bundle_resources_dir}}/" +
diff --git a/components/webdata/common/web_database.cc b/components/webdata/common/web_database.cc index 2058577..1b7f63cf 100644 --- a/components/webdata/common/web_database.cc +++ b/components/webdata/common/web_database.cc
@@ -13,13 +13,13 @@ // corresponding changes must happen in the unit tests, and new migration test // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. // static -const int WebDatabase::kCurrentVersionNumber = 76; +const int WebDatabase::kCurrentVersionNumber = 77; const int WebDatabase::kDeprecatedVersionNumber = 51; namespace { -const int kCompatibleVersionNumber = 72; +const int kCompatibleVersionNumber = 77; // Change the version number and possibly the compatibility version of // |meta_table_|.
diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc index e4ba6d9..f2d34a4 100644 --- a/components/webdata/common/web_database_migration_unittest.cc +++ b/components/webdata/common/web_database_migration_unittest.cc
@@ -130,7 +130,7 @@ DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); }; -const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 76; +const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 77; void WebDatabaseMigrationTest::LoadDatabase( const base::FilePath::StringType& file) { @@ -1505,3 +1505,46 @@ connection.DoesColumnExist("keywords", "search_terms_replacement_key")); } } + +// Tests changing format of three timestamp columns inside keywords. +TEST_F(WebDatabaseMigrationTest, MigrateVersion76ToCurrent) { + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_76.sql"))); + + // Verify pre-conditions. + { + sql::Connection connection; + ASSERT_TRUE(connection.Open(GetDatabasePath())); + ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); + + sql::MetaTable meta_table; + ASSERT_TRUE(meta_table.Init(&connection, 76, 76)); + + sql::Statement s(connection.GetUniqueStatement( + "SELECT id, date_created, last_modified, last_visited FROM keywords")); + ASSERT_TRUE(s.Step()); + EXPECT_EQ(2, s.ColumnInt64(0)); + EXPECT_EQ(123, s.ColumnInt64(1)); + EXPECT_EQ(456, s.ColumnInt64(2)); + EXPECT_EQ(789, s.ColumnInt64(3)); + } + + DoMigration(); + + // Verify post-conditions. + { + sql::Connection connection; + ASSERT_TRUE(connection.Open(GetDatabasePath())); + ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); + + // Check version. + EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); + + sql::Statement s(connection.GetUniqueStatement( + "SELECT id, date_created, last_modified, last_visited FROM keywords")); + ASSERT_TRUE(s.Step()); + EXPECT_EQ(2, s.ColumnInt64(0)); + EXPECT_EQ(11644473723000000, s.ColumnInt64(1)); + EXPECT_EQ(11644474056000000, s.ColumnInt64(2)); + EXPECT_EQ(11644474389000000, s.ColumnInt64(3)); + } +}
diff --git a/content/browser/DEPS b/content/browser/DEPS index f28416fa..fba3c0e 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS
@@ -149,14 +149,6 @@ "+third_party/WebKit/public/platform/modules/permissions/permission.mojom.h", "+third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h", "+third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/navigation_preload_state.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom.h", "+third_party/WebKit/public/platform/modules/webauth/authenticator.mojom.h", "+third_party/WebKit/public/platform/modules/webdatabase/web_database.mojom.h", "+third_party/WebKit/public/platform/modules/websockets/websocket.mojom.h",
diff --git a/content/browser/background_fetch/background_fetch_embedded_worker_test_helper.cc b/content/browser/background_fetch/background_fetch_embedded_worker_test_helper.cc index 2dc26553..3369a28 100644 --- a/content/browser/background_fetch/background_fetch_embedded_worker_test_helper.cc +++ b/content/browser/background_fetch/background_fetch_embedded_worker_test_helper.cc
@@ -8,7 +8,7 @@ #include "base/time/time.h" #include "content/common/background_fetch/background_fetch_types.h" #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" namespace content {
diff --git a/content/browser/background_fetch/background_fetch_registration_id.cc b/content/browser/background_fetch/background_fetch_registration_id.cc index 19eb43d0..f0d6abc5 100644 --- a/content/browser/background_fetch/background_fetch_registration_id.cc +++ b/content/browser/background_fetch/background_fetch_registration_id.cc
@@ -7,7 +7,7 @@ #include <tuple> #include "content/common/service_worker/service_worker_types.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc index c5fd8e3..3825b62 100644 --- a/content/browser/background_sync/background_sync_manager.cc +++ b/content/browser/background_sync/background_sync_manager.cc
@@ -30,7 +30,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/permission_manager.h" #include "content/public/browser/permission_type.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" #if defined(OS_ANDROID) #include "content/browser/android/background_sync_network_observer_android.h" @@ -636,7 +636,7 @@ void BackgroundSyncManager::StoreRegistrations( int64_t sw_registration_id, - const ServiceWorkerStorage::StatusCallback& callback) { + ServiceWorkerStorage::StatusCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); // Serialize the data. @@ -664,7 +664,8 @@ DCHECK(success); StoreDataInBackend(sw_registration_id, registrations.origin, - kBackgroundSyncUserDataKey, serialized, callback); + kBackgroundSyncUserDataKey, serialized, + std::move(callback)); } void BackgroundSyncManager::RegisterDidStore( @@ -740,21 +741,21 @@ const GURL& origin, const std::string& backend_key, const std::string& data, - const ServiceWorkerStorage::StatusCallback& callback) { + ServiceWorkerStorage::StatusCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); service_worker_context_->StoreRegistrationUserData( - sw_registration_id, origin, {{backend_key, data}}, callback); + sw_registration_id, origin, {{backend_key, data}}, + base::AdaptCallbackForRepeating(std::move(callback))); } void BackgroundSyncManager::GetDataFromBackend( const std::string& backend_key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback) { + ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); service_worker_context_->GetUserDataForAllRegistrations(backend_key, - callback); + std::move(callback)); } void BackgroundSyncManager::DispatchSyncEvent( @@ -967,11 +968,11 @@ service_worker_context_->FindReadyRegistrationForId( service_worker_id, active_registrations_[service_worker_id].origin, - base::AdaptCallbackForRepeating(base::BindOnce( + base::BindOnce( &BackgroundSyncManager::FireReadyEventsDidFindRegistration, weak_ptr_factory_.GetWeakPtr(), sw_id_and_tag.second, registration->id(), events_fired_barrier_closure, - events_completed_barrier_closure))); + events_completed_barrier_closure)); } }
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h index c5b144e..f4f71f3 100644 --- a/content/browser/background_sync/background_sync_manager.h +++ b/content/browser/background_sync/background_sync_manager.h
@@ -120,11 +120,10 @@ const GURL& origin, const std::string& backend_key, const std::string& data, - const ServiceWorkerStorage::StatusCallback& callback); + ServiceWorkerStorage::StatusCallback callback); virtual void GetDataFromBackend( const std::string& backend_key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback); + ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback callback); virtual void DispatchSyncEvent( const std::string& tag, scoped_refptr<ServiceWorkerVersion> active_version, @@ -176,7 +175,7 @@ // Write all registrations for a given |sw_registration_id| to persistent // storage. void StoreRegistrations(int64_t sw_registration_id, - const ServiceWorkerStorage::StatusCallback& callback); + ServiceWorkerStorage::StatusCallback callback); // Removes the active registration if it is in the map. void RemoveActiveRegistration(int64_t sw_registration_id,
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc index 779a384..1a2bbb21 100644 --- a/content/browser/background_sync/background_sync_manager_unittest.cc +++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -43,8 +43,8 @@ #include "net/base/network_change_notifier.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/background_sync/background_sync_service_impl_unittest.cc b/content/browser/background_sync/background_sync_service_impl_unittest.cc index 90c08f36..ce47be8 100644 --- a/content/browser/background_sync/background_sync_service_impl_unittest.cc +++ b/content/browser/background_sync/background_sync_service_impl_unittest.cc
@@ -27,7 +27,7 @@ #include "mojo/public/cpp/bindings/interface_ptr.h" #include "net/base/network_change_notifier.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/devtools/devtools_io_context.cc b/content/browser/devtools/devtools_io_context.cc index 9848805..9963700 100644 --- a/content/browser/devtools/devtools_io_context.cc +++ b/content/browser/devtools/devtools_io_context.cc
@@ -48,7 +48,7 @@ class TempFileStream : public DevToolsIOContext::RWStream { public: - TempFileStream(); + explicit TempFileStream(bool binary); void Read(off_t position, size_t max_size, ReadCallback callback) override; void Close(bool invoke_pending_callbacks) override {} @@ -67,16 +67,18 @@ scoped_refptr<base::SequencedTaskRunner> task_runner_; bool had_errors_; off_t last_read_pos_; + bool binary_; DISALLOW_COPY_AND_ASSIGN(TempFileStream); }; -TempFileStream::TempFileStream() +TempFileStream::TempFileStream(bool binary) : DevToolsIOContext::RWStream(impl_task_runner()), handle_(base::UintToString(++s_last_stream_handle)), task_runner_(impl_task_runner()), had_errors_(false), - last_read_pos_(0) {} + last_read_pos_(0), + binary_(binary) {} TempFileStream::~TempFileStream() { DCHECK(task_runner_->RunsTasksInCurrentSequence()); @@ -129,6 +131,7 @@ DCHECK(task_runner_->RunsTasksInCurrentSequence()); Status status = StatusFailure; std::unique_ptr<std::string> data; + bool base64_encoded = false; if (file_.IsValid()) { std::string buffer; @@ -154,9 +157,14 @@ last_read_pos_ = position + size_got; } } - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::BindOnce(std::move(callback), std::move(data), false, status)); + if (binary_) { + std::string raw_data(std::move(*data)); + base::Base64Encode(raw_data, data.get()); + base64_encoded = true; + } + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::BindOnce(std::move(callback), std::move(data), + base64_encoded, status)); } void TempFileStream::AppendOnFileSequence(std::unique_ptr<std::string> data) { @@ -472,8 +480,8 @@ } scoped_refptr<DevToolsIOContext::RWStream> -DevToolsIOContext::CreateTempFileBackedStream() { - scoped_refptr<TempFileStream> result = new TempFileStream(); +DevToolsIOContext::CreateTempFileBackedStream(bool binary) { + scoped_refptr<TempFileStream> result = new TempFileStream(binary); bool inserted = streams_.insert(std::make_pair(result->handle(), result)).second; DCHECK(inserted);
diff --git a/content/browser/devtools/devtools_io_context.h b/content/browser/devtools/devtools_io_context.h index 11665be..74677600 100644 --- a/content/browser/devtools/devtools_io_context.h +++ b/content/browser/devtools/devtools_io_context.h
@@ -67,7 +67,7 @@ DevToolsIOContext(); ~DevToolsIOContext(); - scoped_refptr<RWStream> CreateTempFileBackedStream(); + scoped_refptr<RWStream> CreateTempFileBackedStream(bool binary); scoped_refptr<ROStream> GetByHandle(const std::string& handle); scoped_refptr<ROStream> OpenBlob(ChromeBlobStorageContext*, StoragePartition*,
diff --git a/content/browser/devtools/protocol/service_worker_handler.cc b/content/browser/devtools/protocol/service_worker_handler.cc index d2478ae3..3e7c32f8 100644 --- a/content/browser/devtools/protocol/service_worker_handler.cc +++ b/content/browser/devtools/protocol/service_worker_handler.cc
@@ -29,8 +29,8 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/push_event_payload.h" #include "content/public/common/push_messaging_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/devtools/protocol/tracing_handler.cc b/content/browser/devtools/protocol/tracing_handler.cc index b1a10b8..22f6765 100644 --- a/content/browser/devtools/protocol/tracing_handler.cc +++ b/content/browser/devtools/protocol/tracing_handler.cc
@@ -27,6 +27,7 @@ #include "content/browser/devtools/devtools_io_context.h" #include "content/browser/devtools/devtools_session.h" #include "content/browser/tracing/tracing_controller_impl.h" +#include "content/public/browser/browser_thread.h" #include "services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.h" #include "services/resource_coordinator/public/interfaces/tracing/tracing_constants.mojom.h" @@ -107,11 +108,26 @@ : stream_(stream), tracing_handler_(handler) {} void ReceiveTraceChunk(std::unique_ptr<std::string> chunk) override { + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::BindOnce(&DevToolsStreamEndpoint::ReceiveTraceChunk, this, + std::move(chunk))); + return; + } + stream_->Append(std::move(chunk)); } void ReceiveTraceFinalContents( std::unique_ptr<const base::DictionaryValue> metadata) override { + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::BindOnce(&DevToolsStreamEndpoint::ReceiveTraceFinalContents, + this, std::move(metadata))); + return; + } if (TracingHandler* h = tracing_handler_.get()) h->OnTraceToStreamComplete(stream_->handle()); } @@ -134,6 +150,7 @@ frame_tree_node_id_(frame_tree_node_id), did_initiate_recording_(false), return_as_stream_(false), + gzip_compression_(false), weak_factory_(this) {} TracingHandler::~TracingHandler() { @@ -249,23 +266,30 @@ } void TracingHandler::OnTraceToStreamComplete(const std::string& stream_handle) { - frontend_->TracingComplete(stream_handle); + std::string stream_compression = + (gzip_compression_ ? Tracing::StreamCompressionEnum::Gzip + : Tracing::StreamCompressionEnum::None); + frontend_->TracingComplete(stream_handle, stream_compression); } void TracingHandler::Start(Maybe<std::string> categories, Maybe<std::string> options, Maybe<double> buffer_usage_reporting_interval, Maybe<std::string> transfer_mode, + Maybe<std::string> transfer_compression, Maybe<Tracing::TraceConfig> config, std::unique_ptr<StartCallback> callback) { bool return_as_stream = transfer_mode.fromMaybe("") == Tracing::Start::TransferModeEnum::ReturnAsStream; + bool gzip_compression = transfer_compression.fromMaybe("") == + Tracing::StreamCompressionEnum::Gzip; if (IsTracing()) { if (!did_initiate_recording_ && IsStartupTracingActive()) { // If tracing is already running because it was initiated by startup // tracing, honor the transfer mode update, as that's the only way // for the client to communicate it. return_as_stream_ = return_as_stream; + gzip_compression_ = gzip_compression; } callback->sendFailure(Response::Error("Tracing is already started")); return; @@ -280,6 +304,7 @@ did_initiate_recording_ = true; return_as_stream_ = return_as_stream; + gzip_compression_ = gzip_compression; if (buffer_usage_reporting_interval.isJust()) SetupTimer(buffer_usage_reporting_interval.fromJust()); @@ -320,7 +345,12 @@ scoped_refptr<TracingController::TraceDataEndpoint> endpoint; if (return_as_stream_) { endpoint = new DevToolsStreamEndpoint( - weak_factory_.GetWeakPtr(), io_context_->CreateTempFileBackedStream()); + weak_factory_.GetWeakPtr(), io_context_->CreateTempFileBackedStream( + gzip_compression_ /* binary */)); + if (gzip_compression_) { + endpoint = TracingControllerImpl::CreateCompressedStringEndpoint( + endpoint, true /* compress_with_background_priority */); + } StopTracing(endpoint, ""); } else { // Reset the trace data buffer state.
diff --git a/content/browser/devtools/protocol/tracing_handler.h b/content/browser/devtools/protocol/tracing_handler.h index 19603b0..e5a9232 100644 --- a/content/browser/devtools/protocol/tracing_handler.h +++ b/content/browser/devtools/protocol/tracing_handler.h
@@ -55,6 +55,7 @@ Maybe<std::string> options, Maybe<double> buffer_usage_reporting_interval, Maybe<std::string> transfer_mode, + Maybe<std::string> transfer_compression, Maybe<Tracing::TraceConfig> config, std::unique_ptr<StartCallback> callback) override; void End(std::unique_ptr<EndCallback> callback) override; @@ -110,6 +111,7 @@ int frame_tree_node_id_; bool did_initiate_recording_; bool return_as_stream_; + bool gzip_compression_; TraceDataBufferState trace_data_buffer_state_; base::WeakPtrFactory<TracingHandler> weak_factory_;
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc index 2a2fad9..0bc679a 100644 --- a/content/browser/download/download_browsertest.cc +++ b/content/browser/download/download_browsertest.cc
@@ -103,8 +103,7 @@ public: DownloadTestContentBrowserClient() = default; - bool AllowRenderingMhtmlOverHttp( - NavigationUIData* navigation_data) const override { + bool AllowRenderingMhtmlOverHttp(NavigationUIData* navigation_data) override { return allowed_rendering_mhtml_over_http_; }
diff --git a/content/browser/loader/mime_sniffing_resource_handler.cc b/content/browser/loader/mime_sniffing_resource_handler.cc index e04648f..39b0314 100644 --- a/content/browser/loader/mime_sniffing_resource_handler.cc +++ b/content/browser/loader/mime_sniffing_resource_handler.cc
@@ -520,8 +520,7 @@ if (!disposition.empty() && net::HttpContentDisposition(disposition, std::string()).is_attachment()) { must_download_ = true; - } else if (host_->delegate() && - host_->delegate()->ShouldForceDownloadResource( + } else if (GetContentClient()->browser()->ShouldForceDownloadResource( request()->url(), response_->head.mime_type)) { must_download_ = true; } else if (request()->url().SchemeIsHTTPOrHTTPS() &&
diff --git a/content/browser/loader/mime_sniffing_resource_handler_unittest.cc b/content/browser/loader/mime_sniffing_resource_handler_unittest.cc index 30ce49f4..dd46c604a 100644 --- a/content/browser/loader/mime_sniffing_resource_handler_unittest.cc +++ b/content/browser/loader/mime_sniffing_resource_handler_unittest.cc
@@ -21,6 +21,7 @@ #include "content/browser/loader/mock_resource_loader.h" #include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/browser/loader/test_resource_handler.h" +#include "content/public/browser/content_browser_client.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/browser/resource_request_info.h" #include "content/public/common/previews_state.h" @@ -40,10 +41,9 @@ namespace { -class TestResourceDispatcherHostDelegate - : public ResourceDispatcherHostDelegate { +class TestContentBrowserClient : public ContentBrowserClient { public: - explicit TestResourceDispatcherHostDelegate(bool must_download) + explicit TestContentBrowserClient(bool must_download) : must_download_(must_download) {} bool ShouldForceDownloadResource(const GURL& url, @@ -278,8 +278,8 @@ nullptr); // navigation_ui_data TestResourceDispatcherHost host(stream_has_handler_); - TestResourceDispatcherHostDelegate host_delegate(must_download); - host.SetDelegate(&host_delegate); + TestContentBrowserClient new_client(must_download); + ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client); TestFakePluginService plugin_service(plugin_available_, plugin_stale_); @@ -312,6 +312,7 @@ EXPECT_LT(host.intercepted_as_stream_count(), 2); if (allow_download) EXPECT_TRUE(intercepting_handler->new_handler_for_testing()); + SetBrowserClientForTesting(old_client); return host.intercepted_as_stream(); } @@ -339,8 +340,6 @@ nullptr); // navigation_ui_data TestResourceDispatcherHost host(false); - TestResourceDispatcherHostDelegate host_delegate(false); - host.SetDelegate(&host_delegate); TestFakePluginService plugin_service(plugin_available_, plugin_stale_); std::unique_ptr<InterceptingResourceHandler> intercepting_handler( @@ -502,8 +501,6 @@ nullptr); // navigation_ui_data TestResourceDispatcherHost host(false); - TestResourceDispatcherHostDelegate host_delegate(false); - host.SetDelegate(&host_delegate); TestFakePluginService plugin_service(plugin_available_, plugin_stale_); std::unique_ptr<InterceptingResourceHandler> intercepting_handler( @@ -883,8 +880,6 @@ nullptr); // navigation_ui_data TestResourceDispatcherHost host(false); - TestResourceDispatcherHostDelegate host_delegate(false); - host.SetDelegate(&host_delegate); TestFakePluginService plugin_service(false, false); std::unique_ptr<ResourceHandler> intercepting_handler(
diff --git a/content/browser/loader/mojo_async_resource_handler_unittest.cc b/content/browser/loader/mojo_async_resource_handler_unittest.cc index 4557913..2b922dc 100644 --- a/content/browser/loader/mojo_async_resource_handler_unittest.cc +++ b/content/browser/loader/mojo_async_resource_handler_unittest.cc
@@ -144,12 +144,6 @@ return false; } - bool ShouldForceDownloadResource(const GURL& url, - const std::string& mime_type) override { - ADD_FAILURE() << "ShouldForceDownloadResource should not be called."; - return false; - } - bool ShouldInterceptResourceAsStream(net::URLRequest* request, const base::FilePath& plugin_path, const std::string& mime_type,
diff --git a/content/browser/loader/navigation_url_loader_network_service.cc b/content/browser/loader/navigation_url_loader_network_service.cc index d7ace9b4..48a7b97 100644 --- a/content/browser/loader/navigation_url_loader_network_service.cc +++ b/content/browser/loader/navigation_url_loader_network_service.cc
@@ -551,6 +551,7 @@ std::vector<std::unique_ptr<URLLoaderRequestHandler>> initial_handlers) : delegate_(delegate), allow_download_(request_info->common_params.allow_download), + url_(request_info->common_params.url), weak_factory_(this) { DCHECK_CURRENTLY_ON(BrowserThread::UI); int frame_tree_node_id = request_info->frame_tree_node_id; @@ -694,6 +695,7 @@ const net::RedirectInfo& redirect_info, scoped_refptr<ResourceResponse> response) { DCHECK_CURRENTLY_ON(BrowserThread::UI); + url_ = redirect_info.new_url; delegate_->OnRequestRedirected(redirect_info, std::move(response)); } @@ -745,6 +747,9 @@ net::HttpContentDisposition(disposition, std::string()) .is_attachment()) { return true; + } else if (GetContentClient()->browser()->ShouldForceDownloadResource( + url_, response_->head.mime_type)) { + return true; } else if (response_->head.mime_type == "multipart/related") { // TODO(https://crbug.com/790734): retrieve the new NavigationUIData from // the request and and pass it to AllowRenderingMhtmlOverHttp().
diff --git a/content/browser/loader/navigation_url_loader_network_service.h b/content/browser/loader/navigation_url_loader_network_service.h index 9306d9f..893e5e3 100644 --- a/content/browser/loader/navigation_url_loader_network_service.h +++ b/content/browser/loader/navigation_url_loader_network_service.h
@@ -74,6 +74,9 @@ bool allow_download_; + // Current URL that is being navigated, updated after redirection. + GURL url_; + // Factories to handle navigation requests for non-network resources. ContentBrowserClient::NonNetworkURLLoaderFactoryMap non_network_url_loader_factories_;
diff --git a/content/browser/notifications/notification_database.cc b/content/browser/notifications/notification_database.cc index 0b1e9e99..e51a8e4 100644 --- a/content/browser/notifications/notification_database.cc +++ b/content/browser/notifications/notification_database.cc
@@ -14,7 +14,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_database_data.h" #include "storage/common/database/database_identifier.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/leveldatabase/env_chromium.h" #include "third_party/leveldatabase/leveldb_chrome.h" #include "third_party/leveldatabase/src/include/leveldb/db.h"
diff --git a/content/browser/notifications/platform_notification_context_unittest.cc b/content/browser/notifications/platform_notification_context_unittest.cc index 576747a..3f93218 100644 --- a/content/browser/notifications/platform_notification_context_unittest.cc +++ b/content/browser/notifications/platform_notification_context_unittest.cc
@@ -21,7 +21,7 @@ #include "content/test/mock_platform_notification_service.h" #include "content/test/test_content_browser_client.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/payments/payment_app_browsertest.cc b/content/browser/payments/payment_app_browsertest.cc index 7e90d45c..df0c884a 100644 --- a/content/browser/payments/payment_app_browsertest.cc +++ b/content/browser/payments/payment_app_browsertest.cc
@@ -17,8 +17,8 @@ #include "content/shell/browser/shell.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/payments/payment_app.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" namespace content { namespace {
diff --git a/content/browser/payments/payment_app_content_unittest_base.cc b/content/browser/payments/payment_app_content_unittest_base.cc index 9b4aec7..4200f42 100644 --- a/content/browser/payments/payment_app_content_unittest_base.cc +++ b/content/browser/payments/payment_app_content_unittest_base.cc
@@ -21,7 +21,7 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "mojo/public/cpp/bindings/associated_interface_ptr.h" #include "mojo/public/cpp/bindings/interface_request.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc index a2162a0c..1924b88 100644 --- a/content/browser/service_worker/embedded_worker_instance.cc +++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -31,7 +31,7 @@ #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "ipc/ipc_message.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/web/WebConsoleMessage.h" #include "url/gurl.h"
diff --git a/content/browser/service_worker/embedded_worker_instance.h b/content/browser/service_worker/embedded_worker_instance.h index 908f6eb..71ee8df 100644 --- a/content/browser/service_worker/embedded_worker_instance.h +++ b/content/browser/service_worker/embedded_worker_instance.h
@@ -29,7 +29,7 @@ #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" #include "content/common/service_worker/service_worker_status_code.h" #include "mojo/public/cpp/bindings/associated_binding.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" #include "url/gurl.h" namespace IPC {
diff --git a/content/browser/service_worker/embedded_worker_instance_unittest.cc b/content/browser/service_worker/embedded_worker_instance_unittest.cc index ded61f0..07bb84b 100644 --- a/content/browser/service_worker/embedded_worker_instance_unittest.cc +++ b/content/browser/service_worker/embedded_worker_instance_unittest.cc
@@ -32,8 +32,8 @@ #include "mojo/public/cpp/bindings/strong_binding.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc index 9bebc03..10574bdf 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.cc +++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -40,7 +40,7 @@ #include "services/network/public/interfaces/fetch_api.mojom.h" #include "storage/common/blob_storage/blob_handle.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" namespace content {
diff --git a/content/browser/service_worker/embedded_worker_test_helper.h b/content/browser/service_worker/embedded_worker_test_helper.h index a54fddf..d3fa607 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.h +++ b/content/browser/service_worker/embedded_worker_test_helper.h
@@ -27,7 +27,7 @@ #include "ipc/ipc_test_sink.h" #include "mojo/public/cpp/bindings/associated_binding.h" #include "net/http/http_response_info.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" #include "url/gurl.h" class GURL;
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc index 9b66961..7fd7c33 100644 --- a/content/browser/service_worker/service_worker_browsertest.cc +++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -87,9 +87,9 @@ #include "storage/browser/blob/blob_data_snapshot.h" #include "storage/browser/blob/blob_reader.h" #include "storage/browser/blob/blob_storage_context.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" using blink::mojom::CacheStorageError; @@ -152,21 +152,21 @@ void ReceiveFindRegistrationStatus( BrowserThread::ID run_quit_thread, - const base::Closure& quit, + base::OnceClosure quit, ServiceWorkerStatusCode* out_status, ServiceWorkerStatusCode status, scoped_refptr<ServiceWorkerRegistration> registration) { *out_status = status; if (!quit.is_null()) - BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); + BrowserThread::PostTask(run_quit_thread, FROM_HERE, std::move(quit)); } ServiceWorkerStorage::FindRegistrationCallback CreateFindRegistrationReceiver( BrowserThread::ID run_quit_thread, - const base::Closure& quit, + base::OnceClosure quit, ServiceWorkerStatusCode* status) { - return base::Bind(&ReceiveFindRegistrationStatus, run_quit_thread, quit, - status); + return base::BindOnce(&ReceiveFindRegistrationStatus, run_quit_thread, + std::move(quit), status); } void ReadResponseBody(std::string* body, @@ -762,14 +762,15 @@ ASSERT_EQ(expected_status, status); } - void FindRegistrationForIdOnIOThread(const base::Closure& done, + void FindRegistrationForIdOnIOThread(base::OnceClosure done, ServiceWorkerStatusCode* result, int64_t id, const GURL& origin) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); wrapper()->context()->storage()->FindRegistrationForId( id, origin, - CreateFindRegistrationReceiver(BrowserThread::UI, done, result)); + CreateFindRegistrationReceiver(BrowserThread::UI, std::move(done), + result)); } void NotifyDoneInstallingRegistrationOnIOThread(
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc index c717e64b..7046ddf 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -40,7 +40,7 @@ #include "net/http/http_response_info.h" #include "storage/browser/quota/quota_manager_proxy.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_context_core.h b/content/browser/service_worker/service_worker_context_core.h index 6d2db80f..5bc4aee 100644 --- a/content/browser/service_worker/service_worker_context_core.h +++ b/content/browser/service_worker/service_worker_context_core.h
@@ -25,7 +25,7 @@ #include "content/browser/service_worker/service_worker_storage.h" #include "content/common/content_export.h" #include "content/public/browser/service_worker_context.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" class GURL;
diff --git a/content/browser/service_worker/service_worker_context_request_handler_unittest.cc b/content/browser/service_worker/service_worker_context_request_handler_unittest.cc index ef6f123..4f2bc4d 100644 --- a/content/browser/service_worker/service_worker_context_request_handler_unittest.cc +++ b/content/browser/service_worker/service_worker_context_request_handler_unittest.cc
@@ -29,7 +29,7 @@ #include "net/url_request/url_request_test_util.h" #include "storage/browser/blob/blob_storage_context.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc index da378d6..c0b7219d 100644 --- a/content/browser/service_worker/service_worker_context_unittest.cc +++ b/content/browser/service_worker/service_worker_context_unittest.cc
@@ -28,8 +28,8 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_context_watcher.cc b/content/browser/service_worker/service_worker_context_watcher.cc index e2210fa..f018d425 100644 --- a/content/browser/service_worker/service_worker_context_watcher.cc +++ b/content/browser/service_worker/service_worker_context_watcher.cc
@@ -13,8 +13,8 @@ #include "content/browser/service_worker/service_worker_version.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/console_message_level.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_context_watcher_unittest.cc b/content/browser/service_worker/service_worker_context_watcher_unittest.cc index b580c064..58ad5571 100644 --- a/content/browser/service_worker/service_worker_context_watcher_unittest.cc +++ b/content/browser/service_worker/service_worker_context_watcher_unittest.cc
@@ -11,7 +11,7 @@ #include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc index d469dd7..8f771b9 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.cc +++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -33,7 +33,7 @@ #include "net/base/url_util.h" #include "storage/browser/quota/quota_manager_proxy.h" #include "storage/browser/quota/special_storage_policy.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content { @@ -346,9 +346,9 @@ std::vector<ServiceWorkerUsageInfo>())); return; } - context()->storage()->GetAllRegistrationsInfos(base::Bind( + context()->storage()->GetAllRegistrationsInfos(base::BindOnce( &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins, - this, base::Passed(std::move(callback)))); + this, std::move(callback))); } void ServiceWorkerContextWrapper::DeleteForOrigin(const GURL& origin, @@ -417,9 +417,9 @@ base::OnceClosure failure_callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); FindReadyRegistrationForPattern( - pattern, base::Bind(&FoundReadyRegistrationForStartActiveWorker, - base::Passed(std::move(info_callback)), - base::Passed(&failure_callback))); + pattern, + base::BindOnce(&FoundReadyRegistrationForStartActiveWorker, + std::move(info_callback), std::move(failure_callback))); } void ServiceWorkerContextWrapper::StartServiceWorkerForNavigationHint( @@ -538,122 +538,129 @@ void ServiceWorkerContextWrapper::FindReadyRegistrationForDocument( const GURL& document_url, - const FindRegistrationCallback& callback) { + FindRegistrationCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { // FindRegistrationForDocument() can run the callback synchronously. - callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr); + std::move(callback).Run(SERVICE_WORKER_ERROR_ABORT, nullptr); return; } context_core_->storage()->FindRegistrationForDocument( net::SimplifyUrlForRequest(document_url), - base::Bind(&ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, - this, callback)); + base::BindOnce( + &ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, this, + std::move(callback))); } void ServiceWorkerContextWrapper::FindReadyRegistrationForPattern( const GURL& scope, - const FindRegistrationCallback& callback) { + FindRegistrationCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::BindOnce(callback, SERVICE_WORKER_ERROR_ABORT, nullptr)); + FROM_HERE, base::BindOnce(std::move(callback), + SERVICE_WORKER_ERROR_ABORT, nullptr)); return; } context_core_->storage()->FindRegistrationForPattern( net::SimplifyUrlForRequest(scope), - base::Bind(&ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, - this, callback)); + base::BindOnce( + &ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, this, + std::move(callback))); } void ServiceWorkerContextWrapper::FindReadyRegistrationForId( int64_t registration_id, const GURL& origin, - const FindRegistrationCallback& callback) { + FindRegistrationCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { // FindRegistrationForId() can run the callback synchronously. - callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr); + std::move(callback).Run(SERVICE_WORKER_ERROR_ABORT, nullptr); return; } context_core_->storage()->FindRegistrationForId( registration_id, origin.GetOrigin(), - base::Bind(&ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, - this, callback)); + base::BindOnce( + &ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, this, + std::move(callback))); } void ServiceWorkerContextWrapper::FindReadyRegistrationForIdOnly( int64_t registration_id, - const FindRegistrationCallback& callback) { + FindRegistrationCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { // FindRegistrationForIdOnly() can run the callback synchronously. - callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr); + std::move(callback).Run(SERVICE_WORKER_ERROR_ABORT, nullptr); return; } context_core_->storage()->FindRegistrationForIdOnly( registration_id, - base::Bind(&ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, - this, callback)); + base::BindOnce( + &ServiceWorkerContextWrapper::DidFindRegistrationForFindReady, this, + std::move(callback))); } void ServiceWorkerContextWrapper::GetAllRegistrations( - const GetRegistrationsInfosCallback& callback) { + GetRegistrationsInfosCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::BindOnce(callback, SERVICE_WORKER_ERROR_ABORT, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT, std::vector<ServiceWorkerRegistrationInfo>())); return; } - context_core_->storage()->GetAllRegistrationsInfos(callback); + context_core_->storage()->GetAllRegistrationsInfos(std::move(callback)); } void ServiceWorkerContextWrapper::GetRegistrationUserData( int64_t registration_id, const std::vector<std::string>& keys, - const GetUserDataCallback& callback) { + GetUserDataCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_ABORT)); + FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_ABORT)); return; } - context_core_->storage()->GetUserData(registration_id, keys, callback); + context_core_->storage()->GetUserData(registration_id, keys, + std::move(callback)); } void ServiceWorkerContextWrapper::GetRegistrationUserDataByKeyPrefix( int64_t registration_id, const std::string& key_prefix, - const GetUserDataCallback& callback) { + GetUserDataCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_ABORT)); + FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_ABORT)); return; } context_core_->storage()->GetUserDataByKeyPrefix(registration_id, key_prefix, - callback); + std::move(callback)); } void ServiceWorkerContextWrapper::GetRegistrationUserKeysAndDataByKeyPrefix( int64_t registration_id, const std::string& key_prefix, - const GetUserKeysAndDataCallback& callback) { + GetUserKeysAndDataCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::BindOnce(callback, base::flat_map<std::string, std::string>(), - SERVICE_WORKER_ERROR_ABORT)); + FROM_HERE, base::BindOnce(std::move(callback), + base::flat_map<std::string, std::string>(), + SERVICE_WORKER_ERROR_ABORT)); return; } - context_core_->storage()->GetUserKeysAndDataByKeyPrefix(registration_id, - key_prefix, callback); + context_core_->storage()->GetUserKeysAndDataByKeyPrefix( + registration_id, key_prefix, std::move(callback)); } void ServiceWorkerContextWrapper::StoreRegistrationUserData( @@ -700,31 +707,34 @@ void ServiceWorkerContextWrapper::GetUserDataForAllRegistrations( const std::string& key, - const GetUserDataForAllRegistrationsCallback& callback) { + GetUserDataForAllRegistrationsCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::BindOnce(callback, std::vector<std::pair<int64_t, std::string>>(), + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), SERVICE_WORKER_ERROR_ABORT)); return; } - context_core_->storage()->GetUserDataForAllRegistrations(key, callback); + context_core_->storage()->GetUserDataForAllRegistrations(key, + std::move(callback)); } void ServiceWorkerContextWrapper::GetUserDataForAllRegistrationsByKeyPrefix( const std::string& key_prefix, - const GetUserDataForAllRegistrationsCallback& callback) { + GetUserDataForAllRegistrationsCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!context_core_) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::BindOnce(callback, std::vector<std::pair<int64_t, std::string>>(), + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), SERVICE_WORKER_ERROR_ABORT)); return; } context_core_->storage()->GetUserDataForAllRegistrationsByKeyPrefix( - key_prefix, callback); + key_prefix, std::move(callback)); } void ServiceWorkerContextWrapper::StartServiceWorker( @@ -745,7 +755,7 @@ } context_core_->storage()->FindRegistrationForPattern( net::SimplifyUrlForRequest(pattern), - base::Bind(&StartActiveWorkerOnIO, callback)); + base::BindOnce(&StartActiveWorkerOnIO, callback)); } void ServiceWorkerContextWrapper::SkipWaitingWorker(const GURL& pattern) { @@ -759,7 +769,8 @@ if (!context_core_) return; context_core_->storage()->FindRegistrationForPattern( - net::SimplifyUrlForRequest(pattern), base::Bind(&SkipWaitingWorkerOnIO)); + net::SimplifyUrlForRequest(pattern), + base::BindOnce(&SkipWaitingWorkerOnIO)); } void ServiceWorkerContextWrapper::UpdateRegistration(const GURL& pattern) { @@ -774,8 +785,8 @@ return; context_core_->storage()->FindRegistrationForPattern( net::SimplifyUrlForRequest(pattern), - base::Bind(&ServiceWorkerContextWrapper::DidFindRegistrationForUpdate, - this)); + base::BindOnce(&ServiceWorkerContextWrapper::DidFindRegistrationForUpdate, + this)); } void ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad( @@ -846,12 +857,12 @@ } void ServiceWorkerContextWrapper::DidFindRegistrationForFindReady( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, ServiceWorkerStatusCode status, scoped_refptr<ServiceWorkerRegistration> registration) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (status != SERVICE_WORKER_OK) { - callback.Run(status, nullptr); + std::move(callback).Run(status, nullptr); return; } @@ -863,7 +874,7 @@ scoped_refptr<ServiceWorkerVersion> active_version = registration->active_version(); if (!active_version) { - callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); + std::move(callback).Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); return; } @@ -871,26 +882,26 @@ // Wait until the version is activated. active_version->RegisterStatusChangeCallback(base::BindOnce( &ServiceWorkerContextWrapper::OnStatusChangedForFindReadyRegistration, - this, callback, std::move(registration))); + this, std::move(callback), std::move(registration))); return; } DCHECK_EQ(ServiceWorkerVersion::ACTIVATED, active_version->status()); - callback.Run(SERVICE_WORKER_OK, std::move(registration)); + std::move(callback).Run(SERVICE_WORKER_OK, std::move(registration)); } void ServiceWorkerContextWrapper::OnStatusChangedForFindReadyRegistration( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, scoped_refptr<ServiceWorkerRegistration> registration) { DCHECK_CURRENTLY_ON(BrowserThread::IO); scoped_refptr<ServiceWorkerVersion> active_version = registration->active_version(); if (!active_version || active_version->status() != ServiceWorkerVersion::ACTIVATED) { - callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); + std::move(callback).Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); return; } - callback.Run(SERVICE_WORKER_OK, registration); + std::move(callback).Run(SERVICE_WORKER_OK, registration); } void ServiceWorkerContextWrapper::DidDeleteAndStartOver( @@ -991,9 +1002,9 @@ } context_core_->storage()->FindRegistrationForDocument( net::SimplifyUrlForRequest(document_url), - base::Bind( + base::BindOnce( &ServiceWorkerContextWrapper::DidFindRegistrationForNavigationHint, - this, base::Passed(std::move(callback)))); + this, std::move(callback))); } void ServiceWorkerContextWrapper::DidFindRegistrationForNavigationHint(
diff --git a/content/browser/service_worker/service_worker_context_wrapper.h b/content/browser/service_worker/service_worker_context_wrapper.h index bb82179..63e2244 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.h +++ b/content/browser/service_worker/service_worker_context_wrapper.h
@@ -158,9 +158,8 @@ // activated. // // Must be called from the IO thread. - void FindReadyRegistrationForDocument( - const GURL& document_url, - const FindRegistrationCallback& callback); + void FindReadyRegistrationForDocument(const GURL& document_url, + FindRegistrationCallback callback); // Returns the registration for |scope|. It is guaranteed that the returned // registration has the activated worker. @@ -173,9 +172,8 @@ // activated. // // Must be called from the IO thread. - void FindReadyRegistrationForPattern( - const GURL& scope, - const FindRegistrationCallback& callback); + void FindReadyRegistrationForPattern(const GURL& scope, + FindRegistrationCallback callback); // Returns the registration for |registration_id|. It is guaranteed that the // returned registration has the activated worker. @@ -190,7 +188,7 @@ // Must be called from the IO thread. void FindReadyRegistrationForId(int64_t registration_id, const GURL& origin, - const FindRegistrationCallback& callback); + FindRegistrationCallback callback); // Returns the registration for |registration_id|. It is guaranteed that the // returned registration has the activated worker. @@ -208,20 +206,20 @@ // // Must be called from the IO thread. void FindReadyRegistrationForIdOnly(int64_t registration_id, - const FindRegistrationCallback& callback); + FindRegistrationCallback callback); // All these methods must be called from the IO thread. - void GetAllRegistrations(const GetRegistrationsInfosCallback& callback); + void GetAllRegistrations(GetRegistrationsInfosCallback callback); void GetRegistrationUserData(int64_t registration_id, const std::vector<std::string>& keys, - const GetUserDataCallback& callback); + GetUserDataCallback callback); void GetRegistrationUserDataByKeyPrefix(int64_t registration_id, const std::string& key_prefix, - const GetUserDataCallback& callback); + GetUserDataCallback callback); void GetRegistrationUserKeysAndDataByKeyPrefix( int64_t registration_id, const std::string& key_prefix, - const GetUserKeysAndDataCallback& callback); + GetUserKeysAndDataCallback callback); void StoreRegistrationUserData( int64_t registration_id, const GURL& origin, @@ -236,10 +234,10 @@ const StatusCallback& callback); void GetUserDataForAllRegistrations( const std::string& key, - const GetUserDataForAllRegistrationsCallback& callback); + GetUserDataForAllRegistrationsCallback callback); void GetUserDataForAllRegistrationsByKeyPrefix( const std::string& key_prefix, - const GetUserDataForAllRegistrationsCallback& callback); + GetUserDataForAllRegistrationsCallback callback); // This function can be called from any thread, but the callback will always // be called on the UI thread. @@ -281,11 +279,11 @@ void ShutdownOnIO(); void DidFindRegistrationForFindReady( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, ServiceWorkerStatusCode status, scoped_refptr<ServiceWorkerRegistration> registration); void OnStatusChangedForFindReadyRegistration( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, scoped_refptr<ServiceWorkerRegistration> registration); void DidDeleteAndStartOver(ServiceWorkerStatusCode status);
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc b/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc index 3889aaf5..629fd2e 100644 --- a/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc +++ b/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc
@@ -35,7 +35,7 @@ #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_data_pipe_reader.h b/content/browser/service_worker/service_worker_data_pipe_reader.h index 2d7ad29..0908049 100644 --- a/content/browser/service_worker/service_worker_data_pipe_reader.h +++ b/content/browser/service_worker/service_worker_data_pipe_reader.h
@@ -10,7 +10,7 @@ #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/system/data_pipe.h" #include "mojo/public/cpp/system/simple_watcher.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_stream_handle.mojom.h" namespace net { class IOBuffer;
diff --git a/content/browser/service_worker/service_worker_data_pipe_reader_unittest.cc b/content/browser/service_worker/service_worker_data_pipe_reader_unittest.cc index 5fcf80c..12303e6 100644 --- a/content/browser/service_worker/service_worker_data_pipe_reader_unittest.cc +++ b/content/browser/service_worker/service_worker_data_pipe_reader_unittest.cc
@@ -15,7 +15,7 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "net/base/io_buffer.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc index 5fe2983..a4cfe0bb 100644 --- a/content/browser/service_worker/service_worker_database.cc +++ b/content/browser/service_worker/service_worker_database.cc
@@ -17,8 +17,8 @@ #include "content/browser/service_worker/service_worker_database.pb.h" #include "content/browser/service_worker/service_worker_metrics.h" #include "content/common/service_worker/service_worker_utils.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/leveldatabase/env_chromium.h" #include "third_party/leveldatabase/leveldb_chrome.h" #include "third_party/leveldatabase/src/include/leveldb/db.h"
diff --git a/content/browser/service_worker/service_worker_database_unittest.cc b/content/browser/service_worker/service_worker_database_unittest.cc index 4fd4cb6..41cb775 100644 --- a/content/browser/service_worker/service_worker_database_unittest.cc +++ b/content/browser/service_worker/service_worker_database_unittest.cc
@@ -18,8 +18,8 @@ #include "content/common/service_worker/service_worker_types.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" #include "url/origin.h"
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc index a4e5b723..f4843cb 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -34,10 +34,10 @@ #include "content/public/common/content_client.h" #include "content/public/common/origin_util.h" #include "ipc/ipc_message_macros.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" #include "third_party/WebKit/public/platform/web_feature.mojom.h" #include "url/gurl.h"
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.h b/content/browser/service_worker/service_worker_dispatcher_host.h index ce3d794..f0630943 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.h +++ b/content/browser/service_worker/service_worker_dispatcher_host.h
@@ -21,7 +21,7 @@ #include "content/public/browser/browser_associated_interface.h" #include "content/public/browser/browser_message_filter.h" #include "mojo/public/cpp/bindings/strong_associated_binding_set.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace blink { class MessagePortChannel;
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc index 89f230de..3784a818 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -32,9 +32,9 @@ #include "content/public/test/mock_resource_context.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" using blink::MessagePortChannel;
diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.h b/content/browser/service_worker/service_worker_fetch_dispatcher.h index 0cd984b..974e69d 100644 --- a/content/browser/service_worker/service_worker_fetch_dispatcher.h +++ b/content/browser/service_worker/service_worker_fetch_dispatcher.h
@@ -24,7 +24,7 @@ #include "mojo/public/cpp/system/data_pipe.h" #include "net/log/net_log_with_source.h" #include "third_party/WebKit/common/blob/blob.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" namespace net { class URLRequest;
diff --git a/content/browser/service_worker/service_worker_handle_unittest.cc b/content/browser/service_worker/service_worker_handle_unittest.cc index d0e0ff87..bfcfd10d 100644 --- a/content/browser/service_worker/service_worker_handle_unittest.cc +++ b/content/browser/service_worker/service_worker_handle_unittest.cc
@@ -23,8 +23,8 @@ #include "ipc/ipc_message.h" #include "ipc/ipc_test_sink.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_state.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_info.cc b/content/browser/service_worker/service_worker_info.cc index 0bf9e35..ed23340 100644 --- a/content/browser/service_worker/service_worker_info.cc +++ b/content/browser/service_worker/service_worker_info.cc
@@ -9,8 +9,8 @@ #include "content/public/common/browser_side_navigation_policy.h" #include "content/public/common/child_process_host.h" #include "ipc/ipc_message.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_installed_scripts_sender_unittest.cc b/content/browser/service_worker/service_worker_installed_scripts_sender_unittest.cc index eaa67839..f54a0e66 100644 --- a/content/browser/service_worker/service_worker_installed_scripts_sender_unittest.cc +++ b/content/browser/service_worker/service_worker_installed_scripts_sender_unittest.cc
@@ -17,7 +17,7 @@ #include "net/base/io_buffer.h" #include "net/base/test_completion_callback.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_internals_ui.cc b/content/browser/service_worker/service_worker_internals_ui.cc index f20e5b91..66acefaa 100644 --- a/content/browser/service_worker/service_worker_internals_ui.cc +++ b/content/browser/service_worker/service_worker_internals_ui.cc
@@ -33,7 +33,7 @@ #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/child_process_host.h" #include "content/public/common/url_constants.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" using base::DictionaryValue; using base::ListValue;
diff --git a/content/browser/service_worker/service_worker_job_coordinator.cc b/content/browser/service_worker/service_worker_job_coordinator.cc index 8ff8cab..8a777c8 100644 --- a/content/browser/service_worker/service_worker_job_coordinator.cc +++ b/content/browser/service_worker/service_worker_job_coordinator.cc
@@ -11,7 +11,7 @@ #include "base/memory/ptr_util.h" #include "content/browser/service_worker/service_worker_register_job_base.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_job_coordinator.h b/content/browser/service_worker/service_worker_job_coordinator.h index 0923e20..3964b1b 100644 --- a/content/browser/service_worker/service_worker_job_coordinator.h +++ b/content/browser/service_worker/service_worker_job_coordinator.h
@@ -13,7 +13,7 @@ #include "content/browser/service_worker/service_worker_register_job.h" #include "content/browser/service_worker/service_worker_unregister_job.h" #include "content/common/content_export.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc index 52ee2465..6922cb77 100644 --- a/content/browser/service_worker/service_worker_job_unittest.cc +++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -38,10 +38,10 @@ #include "net/base/test_completion_callback.h" #include "net/http/http_response_headers.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" using net::IOBuffer; using net::TestCompletionCallback; @@ -120,10 +120,8 @@ bool* called, scoped_refptr<ServiceWorkerRegistration>* registration) { *called = false; - return base::Bind(&SaveFoundRegistrationCallback, - expected_status, - called, - registration); + return base::BindOnce(&SaveFoundRegistrationCallback, expected_status, called, + registration); } void SaveUnregistrationCallback(ServiceWorkerStatusCode expected_status,
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc index ca80f936..427c124 100644 --- a/content/browser/service_worker/service_worker_provider_host.cc +++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -44,8 +44,8 @@ #include "storage/browser/blob/blob_storage_context.h" #include "third_party/WebKit/common/message_port/message_port_channel.h" #include "third_party/WebKit/common/service_worker/service_worker_client.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h index f4c69d0..325db32 100644 --- a/content/browser/service_worker/service_worker_provider_host.h +++ b/content/browser/service_worker/service_worker_provider_host.h
@@ -33,7 +33,7 @@ #include "mojo/public/cpp/bindings/binding_set.h" #include "services/network/public/interfaces/fetch_api.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace blink { class MessagePortChannel;
diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc index 30ae6eb0..d58c983 100644 --- a/content/browser/service_worker/service_worker_provider_host_unittest.cc +++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc
@@ -30,8 +30,8 @@ #include "content/test/test_content_client.h" #include "mojo/edk/embedder/embedder.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc index 61b254a..ad682b2 100644 --- a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
@@ -26,7 +26,7 @@ #include "net/url_request/url_request_status.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc index 3e24525..c5b078821 100644 --- a/content/browser/service_worker/service_worker_register_job.cc +++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -25,7 +25,7 @@ #include "content/public/browser/browser_thread.h" #include "mojo/public/cpp/bindings/associated_binding.h" #include "net/base/net_errors.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" namespace content { @@ -100,22 +100,23 @@ SetPhase(START); ServiceWorkerStorage::FindRegistrationCallback next_step; if (job_type_ == REGISTRATION_JOB) { - next_step = base::Bind( - &ServiceWorkerRegisterJob::ContinueWithRegistration, - weak_factory_.GetWeakPtr()); + next_step = + base::BindOnce(&ServiceWorkerRegisterJob::ContinueWithRegistration, + weak_factory_.GetWeakPtr()); } else { - next_step = base::Bind( - &ServiceWorkerRegisterJob::ContinueWithUpdate, - weak_factory_.GetWeakPtr()); + next_step = base::BindOnce(&ServiceWorkerRegisterJob::ContinueWithUpdate, + weak_factory_.GetWeakPtr()); } scoped_refptr<ServiceWorkerRegistration> registration = context_->storage()->GetUninstallingRegistration(pattern_); if (registration.get()) base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(next_step, SERVICE_WORKER_OK, registration)); + FROM_HERE, + base::BindOnce(std::move(next_step), SERVICE_WORKER_OK, registration)); else - context_->storage()->FindRegistrationForPattern(pattern_, next_step); + context_->storage()->FindRegistrationForPattern(pattern_, + std::move(next_step)); } void ServiceWorkerRegisterJob::Abort() {
diff --git a/content/browser/service_worker/service_worker_register_job.h b/content/browser/service_worker/service_worker_register_job.h index 22b4939..edd8303 100644 --- a/content/browser/service_worker/service_worker_register_job.h +++ b/content/browser/service_worker/service_worker_register_job.h
@@ -15,8 +15,8 @@ #include "content/browser/service_worker/service_worker_register_job_base.h" #include "content/browser/service_worker/service_worker_registration.h" #include "content/common/service_worker/service_worker_status_code.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_registration.cc b/content/browser/service_worker/service_worker_registration.cc index 80eb7c76..19b7c87 100644 --- a/content/browser/service_worker/service_worker_registration.cc +++ b/content/browser/service_worker/service_worker_registration.cc
@@ -16,7 +16,7 @@ #include "content/common/service_worker/service_worker_messages.h" #include "content/common/service_worker/service_worker_utils.h" #include "content/public/browser/browser_thread.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_registration.h b/content/browser/service_worker/service_worker_registration.h index fea1bf1..97a77551 100644 --- a/content/browser/service_worker/service_worker_registration.h +++ b/content/browser/service_worker/service_worker_registration.h
@@ -18,7 +18,7 @@ #include "content/browser/service_worker/service_worker_version.h" #include "content/common/content_export.h" #include "content/common/service_worker/service_worker_types.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_registration_object_host.cc b/content/browser/service_worker/service_worker_registration_object_host.cc index 1e9e67a8..f72c39e 100644 --- a/content/browser/service_worker/service_worker_registration_object_host.cc +++ b/content/browser/service_worker/service_worker_registration_object_host.cc
@@ -12,7 +12,7 @@ #include "content/common/service_worker/service_worker_utils.h" #include "content/public/common/service_worker_modes.h" #include "net/http/http_util.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_registration_object_host.h b/content/browser/service_worker/service_worker_registration_object_host.h index be87d38c..4c5e9d4 100644 --- a/content/browser/service_worker/service_worker_registration_object_host.h +++ b/content/browser/service_worker/service_worker_registration_object_host.h
@@ -14,7 +14,7 @@ #include "content/common/content_export.h" #include "content/common/service_worker/service_worker_types.h" #include "mojo/public/cpp/bindings/associated_binding_set.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_registration_status.cc b/content/browser/service_worker/service_worker_registration_status.cc index e0472e91..caa586d 100644 --- a/content/browser/service_worker/service_worker_registration_status.cc +++ b/content/browser/service_worker/service_worker_registration_status.cc
@@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_registration_unittest.cc b/content/browser/service_worker/service_worker_registration_unittest.cc index ccde25d..81b238f7 100644 --- a/content/browser/service_worker/service_worker_registration_unittest.cc +++ b/content/browser/service_worker/service_worker_registration_unittest.cc
@@ -28,8 +28,8 @@ #include "content/test/test_content_browser_client.h" #include "mojo/edk/embedder/embedder.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_script_url_loader_unittest.cc b/content/browser/service_worker/service_worker_script_url_loader_unittest.cc index 36a3f03..71eff79 100644 --- a/content/browser/service_worker/service_worker_script_url_loader_unittest.cc +++ b/content/browser/service_worker/service_worker_script_url_loader_unittest.cc
@@ -23,7 +23,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/redirect_info.h" #include "services/network/public/cpp/url_loader_completion_status.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc index ddd354c..38072ab 100644 --- a/content/browser/service_worker/service_worker_storage.cc +++ b/content/browser/service_worker/service_worker_storage.cc
@@ -28,8 +28,8 @@ #include "net/base/net_errors.h" #include "storage/browser/quota/quota_manager_proxy.h" #include "storage/browser/quota/special_storage_policy.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/web_feature.mojom.h" using std::swap; @@ -38,33 +38,27 @@ namespace { -void RunSoon(const base::Location& from_here, const base::Closure& closure) { - base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, closure); -} - void RunSoon(const base::Location& from_here, base::OnceClosure closure) { base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, std::move(closure)); } -void CompleteFindNow( - scoped_refptr<ServiceWorkerRegistration> registration, - ServiceWorkerStatusCode status, - const ServiceWorkerStorage::FindRegistrationCallback& callback) { +void CompleteFindNow(scoped_refptr<ServiceWorkerRegistration> registration, + ServiceWorkerStatusCode status, + ServiceWorkerStorage::FindRegistrationCallback callback) { if (registration && registration->is_deleted()) { // It's past the point of no return and no longer findable. - callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); + std::move(callback).Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); return; } - callback.Run(status, std::move(registration)); + std::move(callback).Run(status, std::move(registration)); } -void CompleteFindSoon( - const base::Location& from_here, - scoped_refptr<ServiceWorkerRegistration> registration, - ServiceWorkerStatusCode status, - const ServiceWorkerStorage::FindRegistrationCallback& callback) { - RunSoon(from_here, base::Bind(&CompleteFindNow, std::move(registration), - status, callback)); +void CompleteFindSoon(const base::Location& from_here, + scoped_refptr<ServiceWorkerRegistration> registration, + ServiceWorkerStatusCode status, + ServiceWorkerStorage::FindRegistrationCallback callback) { + RunSoon(from_here, base::BindOnce(&CompleteFindNow, std::move(registration), + status, std::move(callback))); } const base::FilePath::CharType kDatabaseName[] = @@ -90,9 +84,9 @@ } void DidUpdateNavigationPreloadState( - const ServiceWorkerStorage::StatusCallback& callback, + ServiceWorkerStorage::StatusCallback callback, ServiceWorkerDatabase::Status status) { - callback.Run(DatabaseStatusToStatusCode(status)); + std::move(callback).Run(DatabaseStatusToStatusCode(status)); } } // namespace @@ -105,15 +99,16 @@ ServiceWorkerStorage::InitialData::~InitialData() { } -ServiceWorkerStorage::DidDeleteRegistrationParams::DidDeleteRegistrationParams() - : registration_id(blink::mojom::kInvalidServiceWorkerRegistrationId) {} - ServiceWorkerStorage::DidDeleteRegistrationParams::DidDeleteRegistrationParams( - const DidDeleteRegistrationParams& other) = default; + int64_t registration_id, + GURL origin, + StatusCallback callback) + : registration_id(registration_id), + origin(origin), + callback(std::move(callback)) {} -ServiceWorkerStorage:: -DidDeleteRegistrationParams::~DidDeleteRegistrationParams() { -} +ServiceWorkerStorage::DidDeleteRegistrationParams:: + ~DidDeleteRegistrationParams() {} ServiceWorkerStorage::~ServiceWorkerStorage() { ClearSessionOnlyOrigins(); @@ -145,23 +140,26 @@ void ServiceWorkerStorage::FindRegistrationForDocument( const GURL& document_url, - const FindRegistrationCallback& callback) { + FindRegistrationCallback callback) { DCHECK(!document_url.has_ref()); - if (!LazyInitialize(base::Bind( - &ServiceWorkerStorage::FindRegistrationForDocument, - weak_factory_.GetWeakPtr(), document_url, callback))) { - if (state_ != INITIALIZING) { + switch (state_) { + case DISABLED: CompleteFindNow(scoped_refptr<ServiceWorkerRegistration>(), - SERVICE_WORKER_ERROR_ABORT, callback); - } - TRACE_EVENT_INSTANT1( - "ServiceWorker", - "ServiceWorkerStorage::FindRegistrationForDocument:LazyInitialize", - TRACE_EVENT_SCOPE_THREAD, - "URL", document_url.spec()); - return; + SERVICE_WORKER_ERROR_ABORT, std::move(callback)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce( + &ServiceWorkerStorage::FindRegistrationForDocument, + weak_factory_.GetWeakPtr(), document_url, std::move(callback))); + TRACE_EVENT_INSTANT1( + "ServiceWorker", + "ServiceWorkerStorage::FindRegistrationForDocument:LazyInitialize", + TRACE_EVENT_SCOPE_THREAD, "URL", document_url.spec()); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); // See if there are any stored registrations for the origin. if (!base::ContainsKey(registered_origins_, document_url.GetOrigin())) { @@ -177,7 +175,8 @@ TRACE_EVENT_SCOPE_THREAD, "URL", document_url.spec(), "Status", ServiceWorkerStatusToString(status)); - CompleteFindNow(std::move(installing_registration), status, callback); + CompleteFindNow(std::move(installing_registration), status, + std::move(callback)); return; } @@ -192,24 +191,28 @@ base::BindOnce( &FindForDocumentInDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), document_url, - base::Bind(&ServiceWorkerStorage::DidFindRegistrationForDocument, - weak_factory_.GetWeakPtr(), document_url, callback, - callback_id))); + base::BindOnce(&ServiceWorkerStorage::DidFindRegistrationForDocument, + weak_factory_.GetWeakPtr(), document_url, + std::move(callback), callback_id))); } void ServiceWorkerStorage::FindRegistrationForPattern( const GURL& scope, - const FindRegistrationCallback& callback) { - if (!LazyInitialize(base::Bind( - &ServiceWorkerStorage::FindRegistrationForPattern, - weak_factory_.GetWeakPtr(), scope, callback))) { - if (state_ != INITIALIZING) { + FindRegistrationCallback callback) { + switch (state_) { + case DISABLED: CompleteFindSoon(FROM_HERE, scoped_refptr<ServiceWorkerRegistration>(), - SERVICE_WORKER_ERROR_ABORT, callback); - } - return; + SERVICE_WORKER_ERROR_ABORT, std::move(callback)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce( + &ServiceWorkerStorage::FindRegistrationForPattern, + weak_factory_.GetWeakPtr(), scope, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); // See if there are any stored registrations for the origin. if (!base::ContainsKey(registered_origins_, scope.GetOrigin())) { @@ -220,7 +223,7 @@ installing_registration ? SERVICE_WORKER_OK : SERVICE_WORKER_ERROR_NOT_FOUND; CompleteFindSoon(FROM_HERE, std::move(installing_registration), - installing_status, callback); + installing_status, std::move(callback)); return; } @@ -229,8 +232,9 @@ base::BindOnce( &FindForPatternInDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), scope, - base::Bind(&ServiceWorkerStorage::DidFindRegistrationForPattern, - weak_factory_.GetWeakPtr(), scope, callback))); + base::BindOnce(&ServiceWorkerStorage::DidFindRegistrationForPattern, + weak_factory_.GetWeakPtr(), scope, + std::move(callback)))); } ServiceWorkerRegistration* ServiceWorkerStorage::GetUninstallingRegistration( @@ -249,17 +253,22 @@ void ServiceWorkerStorage::FindRegistrationForId( int64_t registration_id, const GURL& origin, - const FindRegistrationCallback& callback) { - if (!LazyInitialize(base::Bind( - &ServiceWorkerStorage::FindRegistrationForId, - weak_factory_.GetWeakPtr(), registration_id, origin, callback))) { - if (state_ != INITIALIZING) { + FindRegistrationCallback callback) { + switch (state_) { + case DISABLED: CompleteFindNow(scoped_refptr<ServiceWorkerRegistration>(), - SERVICE_WORKER_ERROR_ABORT, callback); - } - return; + SERVICE_WORKER_ERROR_ABORT, std::move(callback)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize( + base::BindOnce(&ServiceWorkerStorage::FindRegistrationForId, + weak_factory_.GetWeakPtr(), registration_id, origin, + std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); // See if there are any stored registrations for the origin. if (!base::ContainsKey(registered_origins_, origin)) { @@ -269,38 +278,43 @@ CompleteFindNow(installing_registration, installing_registration ? SERVICE_WORKER_OK : SERVICE_WORKER_ERROR_NOT_FOUND, - callback); + std::move(callback)); return; } scoped_refptr<ServiceWorkerRegistration> registration = context_->GetLiveRegistration(registration_id); if (registration) { - CompleteFindNow(std::move(registration), SERVICE_WORKER_OK, callback); + CompleteFindNow(std::move(registration), SERVICE_WORKER_OK, + std::move(callback)); return; } database_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&FindForIdInDB, database_.get(), - base::ThreadTaskRunnerHandle::Get(), registration_id, - origin, - base::Bind(&ServiceWorkerStorage::DidFindRegistrationForId, - weak_factory_.GetWeakPtr(), callback))); + base::BindOnce( + &FindForIdInDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), + registration_id, origin, + base::BindOnce(&ServiceWorkerStorage::DidFindRegistrationForId, + weak_factory_.GetWeakPtr(), std::move(callback)))); } void ServiceWorkerStorage::FindRegistrationForIdOnly( int64_t registration_id, - const FindRegistrationCallback& callback) { - if (!LazyInitialize( - base::Bind(&ServiceWorkerStorage::FindRegistrationForIdOnly, - weak_factory_.GetWeakPtr(), registration_id, callback))) { - if (state_ != INITIALIZING) { - CompleteFindNow(nullptr, SERVICE_WORKER_ERROR_ABORT, callback); - } - return; + FindRegistrationCallback callback) { + switch (state_) { + case DISABLED: + CompleteFindNow(nullptr, SERVICE_WORKER_ERROR_ABORT, std::move(callback)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce( + &ServiceWorkerStorage::FindRegistrationForIdOnly, + weak_factory_.GetWeakPtr(), registration_id, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); scoped_refptr<ServiceWorkerRegistration> registration = context_->GetLiveRegistration(registration_id); @@ -310,81 +324,91 @@ // TODO(mek): CompleteFindNow should really do all the required checks, so // calling that directly here should be enough. FindRegistrationForId(registration_id, registration->pattern().GetOrigin(), - callback); + std::move(callback)); return; } database_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&FindForIdOnlyInDB, database_.get(), - base::ThreadTaskRunnerHandle::Get(), registration_id, - base::Bind(&ServiceWorkerStorage::DidFindRegistrationForId, - weak_factory_.GetWeakPtr(), callback))); + base::BindOnce( + &FindForIdOnlyInDB, database_.get(), + base::ThreadTaskRunnerHandle::Get(), registration_id, + base::BindOnce(&ServiceWorkerStorage::DidFindRegistrationForId, + weak_factory_.GetWeakPtr(), std::move(callback)))); } void ServiceWorkerStorage::GetRegistrationsForOrigin( const GURL& origin, - const GetRegistrationsCallback& callback) { - if (!LazyInitialize(base::Bind( + GetRegistrationsCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce( + std::move(callback), SERVICE_WORKER_ERROR_ABORT, + std::vector<scoped_refptr<ServiceWorkerRegistration>>())); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce( &ServiceWorkerStorage::GetRegistrationsForOrigin, - weak_factory_.GetWeakPtr(), origin, callback))) { - if (state_ != INITIALIZING) { - RunSoon( - FROM_HERE, - base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, - std::vector<scoped_refptr<ServiceWorkerRegistration>>())); - } - return; + weak_factory_.GetWeakPtr(), origin, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); RegistrationList* registrations = new RegistrationList; std::vector<ResourceList>* resource_lists = new std::vector<ResourceList>; base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::GetRegistrationsForOrigin, - base::Unretained(database_.get()), origin, registrations, - resource_lists), - base::Bind(&ServiceWorkerStorage::DidGetRegistrationsForOrigin, - weak_factory_.GetWeakPtr(), callback, - base::Owned(registrations), base::Owned(resource_lists), - origin)); + base::BindOnce(&ServiceWorkerDatabase::GetRegistrationsForOrigin, + base::Unretained(database_.get()), origin, registrations, + resource_lists), + base::BindOnce(&ServiceWorkerStorage::DidGetRegistrationsForOrigin, + weak_factory_.GetWeakPtr(), std::move(callback), + base::Owned(registrations), base::Owned(resource_lists), + origin)); } void ServiceWorkerStorage::GetAllRegistrationsInfos( - const GetRegistrationsInfosCallback& callback) { - if (!LazyInitialize( - base::Bind(&ServiceWorkerStorage::GetAllRegistrationsInfos, - weak_factory_.GetWeakPtr(), callback))) { - if (state_ != INITIALIZING) { + GetRegistrationsInfosCallback callback) { + switch (state_) { + case DISABLED: RunSoon(FROM_HERE, - base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, - std::vector<ServiceWorkerRegistrationInfo>())); - } - return; + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT, + std::vector<ServiceWorkerRegistrationInfo>())); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize( + base::BindOnce(&ServiceWorkerStorage::GetAllRegistrationsInfos, + weak_factory_.GetWeakPtr(), std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); RegistrationList* registrations = new RegistrationList; base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::GetAllRegistrations, - base::Unretained(database_.get()), registrations), - base::Bind(&ServiceWorkerStorage::DidGetAllRegistrationsInfos, - weak_factory_.GetWeakPtr(), callback, - base::Owned(registrations))); + base::BindOnce(&ServiceWorkerDatabase::GetAllRegistrations, + base::Unretained(database_.get()), registrations), + base::BindOnce(&ServiceWorkerStorage::DidGetAllRegistrationsInfos, + weak_factory_.GetWeakPtr(), std::move(callback), + base::Owned(registrations))); } void ServiceWorkerStorage::StoreRegistration( ServiceWorkerRegistration* registration, ServiceWorkerVersion* version, - const StatusCallback& callback) { + StatusCallback callback) { DCHECK(registration); DCHECK(version); DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT)); return; } @@ -409,7 +433,8 @@ version->script_cache_map()->GetResources(&resources); if (resources.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } @@ -426,30 +451,32 @@ FROM_HERE, base::BindOnce(&WriteRegistrationInDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), data, resources, - base::Bind(&ServiceWorkerStorage::DidStoreRegistration, - weak_factory_.GetWeakPtr(), callback, data))); + base::BindOnce(&ServiceWorkerStorage::DidStoreRegistration, + weak_factory_.GetWeakPtr(), + std::move(callback), data))); registration->set_is_deleted(false); } void ServiceWorkerStorage::UpdateToActiveState( ServiceWorkerRegistration* registration, - const StatusCallback& callback) { + StatusCallback callback) { DCHECK(registration); DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT)); return; } base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::UpdateVersionToActive, - base::Unretained(database_.get()), registration->id(), - registration->pattern().GetOrigin()), - base::Bind(&ServiceWorkerStorage::DidUpdateToActiveState, - weak_factory_.GetWeakPtr(), callback)); + base::BindOnce(&ServiceWorkerDatabase::UpdateVersionToActive, + base::Unretained(database_.get()), registration->id(), + registration->pattern().GetOrigin()), + base::BindOnce(&ServiceWorkerStorage::DidUpdateToActiveState, + weak_factory_.GetWeakPtr(), std::move(callback))); } void ServiceWorkerStorage::UpdateLastUpdateCheckTime( @@ -472,64 +499,63 @@ int64_t registration_id, const GURL& origin, bool enable, - const StatusCallback& callback) { + StatusCallback callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { - callback.Run(SERVICE_WORKER_ERROR_ABORT); + std::move(callback).Run(SERVICE_WORKER_ERROR_ABORT); return; } base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::UpdateNavigationPreloadEnabled, - base::Unretained(database_.get()), registration_id, origin, - enable), - base::Bind(&DidUpdateNavigationPreloadState, callback)); + base::BindOnce(&ServiceWorkerDatabase::UpdateNavigationPreloadEnabled, + base::Unretained(database_.get()), registration_id, origin, + enable), + base::BindOnce(&DidUpdateNavigationPreloadState, std::move(callback))); } void ServiceWorkerStorage::UpdateNavigationPreloadHeader( int64_t registration_id, const GURL& origin, const std::string& value, - const StatusCallback& callback) { + StatusCallback callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { - callback.Run(SERVICE_WORKER_ERROR_ABORT); + std::move(callback).Run(SERVICE_WORKER_ERROR_ABORT); return; } base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::UpdateNavigationPreloadHeader, - base::Unretained(database_.get()), registration_id, origin, - value), - base::Bind(&DidUpdateNavigationPreloadState, callback)); + base::BindOnce(&ServiceWorkerDatabase::UpdateNavigationPreloadHeader, + base::Unretained(database_.get()), registration_id, origin, + value), + base::BindOnce(&DidUpdateNavigationPreloadState, std::move(callback))); } void ServiceWorkerStorage::DeleteRegistration(int64_t registration_id, const GURL& origin, - const StatusCallback& callback) { + StatusCallback callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT)); return; } if (!has_checked_for_stale_resources_) DeleteStaleResources(); - DidDeleteRegistrationParams params; - params.registration_id = registration_id; - params.origin = origin; - params.callback = callback; + auto params = base::MakeUnique<DidDeleteRegistrationParams>( + registration_id, origin, std::move(callback)); database_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&DeleteRegistrationFromDB, database_.get(), - base::ThreadTaskRunnerHandle::Get(), registration_id, - origin, - base::Bind(&ServiceWorkerStorage::DidDeleteRegistration, - weak_factory_.GetWeakPtr(), params))); + base::BindOnce( + &DeleteRegistrationFromDB, database_.get(), + base::ThreadTaskRunnerHandle::Get(), registration_id, origin, + base::BindOnce(&ServiceWorkerStorage::DidDeleteRegistration, + weak_factory_.GetWeakPtr(), std::move(params)))); // The registration should no longer be findable. pending_deletions_.insert(registration_id); @@ -568,11 +594,11 @@ base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::WriteUncommittedResourceIds, - base::Unretained(database_.get()), - std::set<int64_t>(&resource_id, &resource_id + 1)), - base::Bind(&ServiceWorkerStorage::DidWriteUncommittedResourceIds, - weak_factory_.GetWeakPtr())); + base::BindOnce(&ServiceWorkerDatabase::WriteUncommittedResourceIds, + base::Unretained(database_.get()), + std::set<int64_t>(&resource_id, &resource_id + 1)), + base::BindOnce(&ServiceWorkerStorage::DidWriteUncommittedResourceIds, + weak_factory_.GetWeakPtr())); } void ServiceWorkerStorage::DoomUncommittedResource(int64_t resource_id) { @@ -591,216 +617,253 @@ base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::PurgeUncommittedResourceIds, - base::Unretained(database_.get()), resource_ids), - base::Bind(&ServiceWorkerStorage::DidPurgeUncommittedResourceIds, - weak_factory_.GetWeakPtr(), resource_ids)); + base::BindOnce(&ServiceWorkerDatabase::PurgeUncommittedResourceIds, + base::Unretained(database_.get()), resource_ids), + base::BindOnce(&ServiceWorkerStorage::DidPurgeUncommittedResourceIds, + weak_factory_.GetWeakPtr(), resource_ids)); } void ServiceWorkerStorage::StoreUserData( int64_t registration_id, const GURL& origin, const std::vector<std::pair<std::string, std::string>>& key_value_pairs, - const StatusCallback& callback) { - if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::StoreUserData, - weak_factory_.GetWeakPtr(), registration_id, - origin, key_value_pairs, callback))) { - if (state_ != INITIALIZING) - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); - return; + StatusCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce( + &ServiceWorkerStorage::StoreUserData, weak_factory_.GetWeakPtr(), + registration_id, origin, key_value_pairs, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId || key_value_pairs.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } for (const auto& kv : key_value_pairs) { if (kv.first.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } } base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::WriteUserData, - base::Unretained(database_.get()), registration_id, origin, - key_value_pairs), - base::Bind(&ServiceWorkerStorage::DidStoreUserData, - weak_factory_.GetWeakPtr(), callback)); + base::BindOnce(&ServiceWorkerDatabase::WriteUserData, + base::Unretained(database_.get()), registration_id, origin, + key_value_pairs), + base::BindOnce(&ServiceWorkerStorage::DidStoreUserData, + weak_factory_.GetWeakPtr(), std::move(callback))); } void ServiceWorkerStorage::GetUserData(int64_t registration_id, const std::vector<std::string>& keys, - const GetUserDataCallback& callback) { - if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::GetUserData, - weak_factory_.GetWeakPtr(), registration_id, - keys, callback))) { - if (state_ != INITIALIZING) { - RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_ABORT)); - } - return; + GetUserDataCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce(&ServiceWorkerStorage::GetUserData, + weak_factory_.GetWeakPtr(), registration_id, + keys, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId || keys.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_FAILED)); return; } for (const std::string& key : keys) { if (key.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_FAILED)); return; } } database_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&ServiceWorkerStorage::GetUserDataInDB, database_.get(), - base::ThreadTaskRunnerHandle::Get(), registration_id, keys, - base::Bind(&ServiceWorkerStorage::DidGetUserData, - weak_factory_.GetWeakPtr(), callback))); + base::BindOnce( + &ServiceWorkerStorage::GetUserDataInDB, database_.get(), + base::ThreadTaskRunnerHandle::Get(), registration_id, keys, + base::BindOnce(&ServiceWorkerStorage::DidGetUserData, + weak_factory_.GetWeakPtr(), std::move(callback)))); } void ServiceWorkerStorage::GetUserDataByKeyPrefix( int64_t registration_id, const std::string& key_prefix, - const GetUserDataCallback& callback) { - if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::GetUserDataByKeyPrefix, - weak_factory_.GetWeakPtr(), registration_id, - key_prefix, callback))) { - if (state_ != INITIALIZING) { - RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_ABORT)); - } - return; + GetUserDataCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize( + base::BindOnce(&ServiceWorkerStorage::GetUserDataByKeyPrefix, + weak_factory_.GetWeakPtr(), registration_id, + key_prefix, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId) { - RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), std::vector<std::string>(), + SERVICE_WORKER_ERROR_FAILED)); return; } if (key_prefix.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(), - SERVICE_WORKER_ERROR_FAILED)); - return; - } - - database_task_runner_->PostTask( - FROM_HERE, - base::BindOnce(&ServiceWorkerStorage::GetUserDataByKeyPrefixInDB, - database_.get(), base::ThreadTaskRunnerHandle::Get(), - registration_id, key_prefix, - base::Bind(&ServiceWorkerStorage::DidGetUserData, - weak_factory_.GetWeakPtr(), callback))); -} - -void ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefix( - int64_t registration_id, - const std::string& key_prefix, - const GetUserKeysAndDataCallback& callback) { - if (!LazyInitialize(base::BindOnce( - &ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefix, - weak_factory_.GetWeakPtr(), registration_id, key_prefix, callback))) { - if (state_ != INITIALIZING) { - RunSoon( - FROM_HERE, - base::BindOnce(callback, base::flat_map<std::string, std::string>(), - SERVICE_WORKER_ERROR_ABORT)); - } - return; - } - DCHECK_EQ(INITIALIZED, state_); - - if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId || - key_prefix.empty()) { RunSoon(FROM_HERE, - base::BindOnce(callback, base::flat_map<std::string, std::string>(), + base::BindOnce(std::move(callback), std::vector<std::string>(), SERVICE_WORKER_ERROR_FAILED)); return; } database_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefixInDB, - database_.get(), base::ThreadTaskRunnerHandle::Get(), - registration_id, key_prefix, - base::Bind(&ServiceWorkerStorage::DidGetUserKeysAndData, - weak_factory_.GetWeakPtr(), callback))); + base::BindOnce( + &ServiceWorkerStorage::GetUserDataByKeyPrefixInDB, database_.get(), + base::ThreadTaskRunnerHandle::Get(), registration_id, key_prefix, + base::BindOnce(&ServiceWorkerStorage::DidGetUserData, + weak_factory_.GetWeakPtr(), std::move(callback)))); +} + +void ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefix( + int64_t registration_id, + const std::string& key_prefix, + GetUserKeysAndDataCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), + base::flat_map<std::string, std::string>(), + SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize( + base::BindOnce(&ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefix, + weak_factory_.GetWeakPtr(), registration_id, + key_prefix, std::move(callback))); + return; + case INITIALIZED: + break; + } + + if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId || + key_prefix.empty()) { + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), + base::flat_map<std::string, std::string>(), + SERVICE_WORKER_ERROR_FAILED)); + return; + } + + database_task_runner_->PostTask( + FROM_HERE, + base::BindOnce( + &ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefixInDB, + database_.get(), base::ThreadTaskRunnerHandle::Get(), registration_id, + key_prefix, + base::BindOnce(&ServiceWorkerStorage::DidGetUserKeysAndData, + weak_factory_.GetWeakPtr(), std::move(callback)))); } void ServiceWorkerStorage::ClearUserData(int64_t registration_id, const std::vector<std::string>& keys, - const StatusCallback& callback) { - if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::ClearUserData, - weak_factory_.GetWeakPtr(), registration_id, - keys, callback))) { - if (state_ != INITIALIZING) - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); - return; - } - DCHECK_EQ(INITIALIZED, state_); - - if (IsDisabled()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); - return; + StatusCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce(&ServiceWorkerStorage::ClearUserData, + weak_factory_.GetWeakPtr(), registration_id, + keys, std::move(callback))); + return; + case INITIALIZED: + break; } if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId || keys.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } for (const std::string& key : keys) { if (key.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } } base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::DeleteUserData, - base::Unretained(database_.get()), registration_id, keys), - base::Bind(&ServiceWorkerStorage::DidDeleteUserData, - weak_factory_.GetWeakPtr(), callback)); + base::BindOnce(&ServiceWorkerDatabase::DeleteUserData, + base::Unretained(database_.get()), registration_id, keys), + base::BindOnce(&ServiceWorkerStorage::DidDeleteUserData, + weak_factory_.GetWeakPtr(), std::move(callback))); } void ServiceWorkerStorage::ClearUserDataByKeyPrefixes( int64_t registration_id, const std::vector<std::string>& key_prefixes, - const StatusCallback& callback) { - if (!LazyInitialize( - base::Bind(&ServiceWorkerStorage::ClearUserDataByKeyPrefixes, - weak_factory_.GetWeakPtr(), registration_id, key_prefixes, - callback))) { - if (state_ != INITIALIZING) - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); - return; - } - DCHECK_EQ(INITIALIZED, state_); - - if (IsDisabled()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); - return; + StatusCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize( + base::BindOnce(&ServiceWorkerStorage::ClearUserDataByKeyPrefixes, + weak_factory_.GetWeakPtr(), registration_id, + key_prefixes, std::move(callback))); + return; + case INITIALIZED: + break; } if (registration_id == blink::mojom::kInvalidServiceWorkerRegistrationId || key_prefixes.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } for (const std::string& key_prefix : key_prefixes) { if (key_prefix.empty()) { - RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } } @@ -811,30 +874,34 @@ base::Unretained(database_.get()), registration_id, key_prefixes), base::BindOnce(&ServiceWorkerStorage::DidDeleteUserData, - weak_factory_.GetWeakPtr(), callback)); + weak_factory_.GetWeakPtr(), std::move(callback))); } void ServiceWorkerStorage::GetUserDataForAllRegistrations( const std::string& key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback) { - if (!LazyInitialize( - base::Bind(&ServiceWorkerStorage::GetUserDataForAllRegistrations, - weak_factory_.GetWeakPtr(), key, callback))) { - if (state_ != INITIALIZING) { - RunSoon( - FROM_HERE, - base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), - SERVICE_WORKER_ERROR_ABORT)); - } - return; + GetUserDataForAllRegistrationsCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), + SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize( + base::BindOnce(&ServiceWorkerStorage::GetUserDataForAllRegistrations, + weak_factory_.GetWeakPtr(), key, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); if (key.empty()) { RunSoon(FROM_HERE, - base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), - SERVICE_WORKER_ERROR_FAILED)); + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), + SERVICE_WORKER_ERROR_FAILED)); return; } @@ -843,31 +910,36 @@ base::BindOnce( &ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), key, - base::Bind(&ServiceWorkerStorage::DidGetUserDataForAllRegistrations, - weak_factory_.GetWeakPtr(), callback))); + base::BindOnce( + &ServiceWorkerStorage::DidGetUserDataForAllRegistrations, + weak_factory_.GetWeakPtr(), std::move(callback)))); } void ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefix( const std::string& key_prefix, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback) { - if (!LazyInitialize(base::Bind( + GetUserDataForAllRegistrationsCallback callback) { + switch (state_) { + case DISABLED: + RunSoon(FROM_HERE, + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), + SERVICE_WORKER_ERROR_ABORT)); + return; + case INITIALIZING: // Fall-through. + case UNINITIALIZED: + LazyInitialize(base::BindOnce( &ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefix, - weak_factory_.GetWeakPtr(), key_prefix, callback))) { - if (state_ != INITIALIZING) { - RunSoon( - FROM_HERE, - base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), - SERVICE_WORKER_ERROR_ABORT)); - } - return; + weak_factory_.GetWeakPtr(), key_prefix, std::move(callback))); + return; + case INITIALIZED: + break; } - DCHECK_EQ(INITIALIZED, state_); if (key_prefix.empty()) { RunSoon(FROM_HERE, - base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), - SERVICE_WORKER_ERROR_FAILED)); + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), + SERVICE_WORKER_ERROR_FAILED)); return; } @@ -876,15 +948,16 @@ base::BindOnce( &ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefixInDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), key_prefix, - base::Bind(&ServiceWorkerStorage::DidGetUserDataForAllRegistrations, - weak_factory_.GetWeakPtr(), callback))); + base::BindOnce( + &ServiceWorkerStorage::DidGetUserDataForAllRegistrations, + weak_factory_.GetWeakPtr(), std::move(callback)))); } -void ServiceWorkerStorage::DeleteAndStartOver(const StatusCallback& callback) { +void ServiceWorkerStorage::DeleteAndStartOver(StatusCallback callback) { Disable(); // Will be used in DiskCacheImplDoneWithDisk() - delete_and_start_over_callback_ = callback; + delete_and_start_over_callback_ = std::move(callback); // Won't get a callback about cleanup being done, so call it ourselves. if (!expecting_done_with_disk_on_disable_) @@ -894,15 +967,14 @@ void ServiceWorkerStorage::DiskCacheImplDoneWithDisk() { expecting_done_with_disk_on_disable_ = false; if (!delete_and_start_over_callback_.is_null()) { - StatusCallback callback; - swap(callback, delete_and_start_over_callback_); // Delete the database on the database thread. - PostTaskAndReplyWithResult( + base::PostTaskAndReplyWithResult( database_task_runner_.get(), FROM_HERE, - base::Bind(&ServiceWorkerDatabase::DestroyDatabase, - base::Unretained(database_.get())), - base::Bind(&ServiceWorkerStorage::DidDeleteDatabase, - weak_factory_.GetWeakPtr(), callback)); + base::BindOnce(&ServiceWorkerDatabase::DestroyDatabase, + base::Unretained(database_.get())), + base::BindOnce(&ServiceWorkerStorage::DidDeleteDatabase, + weak_factory_.GetWeakPtr(), + std::move(delete_and_start_over_callback_))); } } @@ -974,10 +1046,6 @@ StartPurgingResources(resources); } -bool ServiceWorkerStorage::LazyInitializeForTest(base::OnceClosure callback) { - return LazyInitialize(std::move(callback)); -} - ServiceWorkerStorage::ServiceWorkerStorage( const base::FilePath& path, base::WeakPtr<ServiceWorkerContextCore> context, @@ -1015,18 +1083,19 @@ .Append(kDiskCacheName); } -bool ServiceWorkerStorage::LazyInitialize(base::OnceClosure callback) { - switch (state_) { - case INITIALIZED: - return true; - case DISABLED: - return false; - case INITIALIZING: - pending_tasks_.push_back(std::move(callback)); - return false; - case UNINITIALIZED: - pending_tasks_.push_back(std::move(callback)); - // Fall-through. +bool ServiceWorkerStorage::LazyInitializeForTest(base::OnceClosure callback) { + if (state_ == UNINITIALIZED || state_ == INITIALIZING) { + LazyInitialize(std::move(callback)); + return false; + } + return !IsDisabled(); +} + +void ServiceWorkerStorage::LazyInitialize(base::OnceClosure callback) { + DCHECK(state_ == UNINITIALIZED || state_ == INITIALIZING) << state_; + pending_tasks_.push_back(std::move(callback)); + if (state_ == INITIALIZING) { + return; } state_ = INITIALIZING; @@ -1034,9 +1103,8 @@ FROM_HERE, base::BindOnce(&ReadInitialDataFromDB, database_.get(), base::ThreadTaskRunnerHandle::Get(), - base::Bind(&ServiceWorkerStorage::DidReadInitialData, - weak_factory_.GetWeakPtr()))); - return false; + base::BindOnce(&ServiceWorkerStorage::DidReadInitialData, + weak_factory_.GetWeakPtr()))); } void ServiceWorkerStorage::DidReadInitialData( @@ -1066,13 +1134,13 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument( const GURL& document_url, - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, int64_t callback_id, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status) { if (status == ServiceWorkerDatabase::STATUS_OK) { - ReturnFoundRegistration(callback, data, resources); + ReturnFoundRegistration(std::move(callback), data, resources); TRACE_EVENT_ASYNC_END1( "ServiceWorker", "ServiceWorkerStorage::FindRegistrationForDocument", @@ -1088,7 +1156,8 @@ ServiceWorkerStatusCode installing_status = installing_registration ? SERVICE_WORKER_OK : SERVICE_WORKER_ERROR_NOT_FOUND; - callback.Run(installing_status, std::move(installing_registration)); + std::move(callback).Run(installing_status, + std::move(installing_registration)); TRACE_EVENT_ASYNC_END2( "ServiceWorker", "ServiceWorkerStorage::FindRegistrationForDocument", @@ -1102,8 +1171,8 @@ } ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status), - scoped_refptr<ServiceWorkerRegistration>()); + std::move(callback).Run(DatabaseStatusToStatusCode(status), + scoped_refptr<ServiceWorkerRegistration>()); TRACE_EVENT_ASYNC_END1( "ServiceWorker", "ServiceWorkerStorage::FindRegistrationForDocument", @@ -1113,12 +1182,12 @@ void ServiceWorkerStorage::DidFindRegistrationForPattern( const GURL& scope, - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status) { if (status == ServiceWorkerDatabase::STATUS_OK) { - ReturnFoundRegistration(callback, data, resources); + ReturnFoundRegistration(std::move(callback), data, resources); return; } @@ -1128,49 +1197,51 @@ ServiceWorkerStatusCode installing_status = installing_registration ? SERVICE_WORKER_OK : SERVICE_WORKER_ERROR_NOT_FOUND; - callback.Run(installing_status, std::move(installing_registration)); + std::move(callback).Run(installing_status, + std::move(installing_registration)); return; } ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status), - scoped_refptr<ServiceWorkerRegistration>()); + std::move(callback).Run(DatabaseStatusToStatusCode(status), + scoped_refptr<ServiceWorkerRegistration>()); } void ServiceWorkerStorage::DidFindRegistrationForId( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status) { if (status == ServiceWorkerDatabase::STATUS_OK) { - ReturnFoundRegistration(callback, data, resources); + ReturnFoundRegistration(std::move(callback), data, resources); return; } if (status == ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { // TODO(nhiroki): Find a registration in |installing_registrations_|. - callback.Run(DatabaseStatusToStatusCode(status), - scoped_refptr<ServiceWorkerRegistration>()); + std::move(callback).Run(DatabaseStatusToStatusCode(status), + scoped_refptr<ServiceWorkerRegistration>()); return; } ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status), - scoped_refptr<ServiceWorkerRegistration>()); + std::move(callback).Run(DatabaseStatusToStatusCode(status), + scoped_refptr<ServiceWorkerRegistration>()); } void ServiceWorkerStorage::ReturnFoundRegistration( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources) { DCHECK(!resources.empty()); scoped_refptr<ServiceWorkerRegistration> registration = GetOrCreateRegistration(data, resources); - CompleteFindNow(std::move(registration), SERVICE_WORKER_OK, callback); + CompleteFindNow(std::move(registration), SERVICE_WORKER_OK, + std::move(callback)); } void ServiceWorkerStorage::DidGetRegistrationsForOrigin( - const GetRegistrationsCallback& callback, + GetRegistrationsCallback callback, RegistrationList* registration_data_list, std::vector<ResourceList>* resources_list, const GURL& origin_filter, @@ -1182,8 +1253,9 @@ if (status != ServiceWorkerDatabase::STATUS_OK && status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status), - std::vector<scoped_refptr<ServiceWorkerRegistration>>()); + std::move(callback).Run( + DatabaseStatusToStatusCode(status), + std::vector<scoped_refptr<ServiceWorkerRegistration>>()); return; } @@ -1205,19 +1277,19 @@ registrations.push_back(registration.second); } - callback.Run(SERVICE_WORKER_OK, std::move(registrations)); + std::move(callback).Run(SERVICE_WORKER_OK, std::move(registrations)); } void ServiceWorkerStorage::DidGetAllRegistrationsInfos( - const GetRegistrationsInfosCallback& callback, + GetRegistrationsInfosCallback callback, RegistrationList* registration_data_list, ServiceWorkerDatabase::Status status) { DCHECK(registration_data_list); if (status != ServiceWorkerDatabase::STATUS_OK && status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status), - std::vector<ServiceWorkerRegistrationInfo>()); + std::move(callback).Run(DatabaseStatusToStatusCode(status), + std::vector<ServiceWorkerRegistrationInfo>()); return; } @@ -1279,11 +1351,11 @@ infos.push_back(registration.second->GetInfo()); } - callback.Run(SERVICE_WORKER_OK, infos); + std::move(callback).Run(SERVICE_WORKER_OK, infos); } void ServiceWorkerStorage::DidStoreRegistration( - const StatusCallback& callback, + StatusCallback callback, const ServiceWorkerDatabase::RegistrationData& new_version, const GURL& origin, const ServiceWorkerDatabase::RegistrationData& deleted_version, @@ -1291,7 +1363,7 @@ ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) { ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status)); + std::move(callback).Run(DatabaseStatusToStatusCode(status)); return; } registered_origins_.insert(origin); @@ -1312,45 +1384,44 @@ deleted_version.resources_total_size_bytes); } - callback.Run(SERVICE_WORKER_OK); + std::move(callback).Run(SERVICE_WORKER_OK); if (!context_->GetLiveVersion(deleted_version.version_id)) StartPurgingResources(newly_purgeable_resources); } void ServiceWorkerStorage::DidUpdateToActiveState( - const StatusCallback& callback, + StatusCallback callback, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK && status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { ScheduleDeleteAndStartOver(); } - callback.Run(DatabaseStatusToStatusCode(status)); + std::move(callback).Run(DatabaseStatusToStatusCode(status)); } void ServiceWorkerStorage::DidDeleteRegistration( - const DidDeleteRegistrationParams& params, + std::unique_ptr<DidDeleteRegistrationParams> params, OriginState origin_state, const ServiceWorkerDatabase::RegistrationData& deleted_version, const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status) { - pending_deletions_.erase(params.registration_id); + pending_deletions_.erase(params->registration_id); if (status != ServiceWorkerDatabase::STATUS_OK) { ScheduleDeleteAndStartOver(); - params.callback.Run(DatabaseStatusToStatusCode(status)); + std::move(params->callback).Run(DatabaseStatusToStatusCode(status)); return; } if (quota_manager_proxy_) { // Can be nullptr in tests. quota_manager_proxy_->NotifyStorageModified( - storage::QuotaClient::kServiceWorker, - params.origin, + storage::QuotaClient::kServiceWorker, params->origin, storage::StorageType::kStorageTypeTemporary, -deleted_version.resources_total_size_bytes); } if (origin_state == OriginState::kDelete) - registered_origins_.erase(params.origin); - params.callback.Run(SERVICE_WORKER_OK); + registered_origins_.erase(params->origin); + std::move(params->callback).Run(SERVICE_WORKER_OK); if (!context_->GetLiveVersion(deleted_version.version_id)) StartPurgingResources(newly_purgeable_resources); @@ -1373,7 +1444,7 @@ } void ServiceWorkerStorage::DidStoreUserData( - const StatusCallback& callback, + StatusCallback callback, ServiceWorkerDatabase::Status status) { // |status| can be NOT_FOUND when the associated registration did not exist in // the database. In the case, we don't have to schedule the corruption @@ -1382,46 +1453,46 @@ status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { ScheduleDeleteAndStartOver(); } - callback.Run(DatabaseStatusToStatusCode(status)); + std::move(callback).Run(DatabaseStatusToStatusCode(status)); } void ServiceWorkerStorage::DidGetUserData( - const GetUserDataCallback& callback, + GetUserDataCallback callback, const std::vector<std::string>& data, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK && status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { ScheduleDeleteAndStartOver(); } - callback.Run(data, DatabaseStatusToStatusCode(status)); + std::move(callback).Run(data, DatabaseStatusToStatusCode(status)); } void ServiceWorkerStorage::DidGetUserKeysAndData( - const GetUserKeysAndDataCallback& callback, + GetUserKeysAndDataCallback callback, const base::flat_map<std::string, std::string>& data_map, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK && status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { ScheduleDeleteAndStartOver(); } - callback.Run(data_map, DatabaseStatusToStatusCode(status)); + std::move(callback).Run(data_map, DatabaseStatusToStatusCode(status)); } void ServiceWorkerStorage::DidDeleteUserData( - const StatusCallback& callback, + StatusCallback callback, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) ScheduleDeleteAndStartOver(); - callback.Run(DatabaseStatusToStatusCode(status)); + std::move(callback).Run(DatabaseStatusToStatusCode(status)); } void ServiceWorkerStorage::DidGetUserDataForAllRegistrations( - const GetUserDataForAllRegistrationsCallback& callback, + GetUserDataForAllRegistrationsCallback callback, const std::vector<std::pair<int64_t, std::string>>& user_data, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) ScheduleDeleteAndStartOver(); - callback.Run(user_data, DatabaseStatusToStatusCode(status)); + std::move(callback).Run(user_data, DatabaseStatusToStatusCode(status)); } scoped_refptr<ServiceWorkerRegistration> @@ -1600,9 +1671,8 @@ is_purge_pending_ = true; int64_t id = purgeable_resource_ids_.front(); purgeable_resource_ids_.pop_front(); - RunSoon(FROM_HERE, - base::Bind(&ServiceWorkerStorage::PurgeResource, - weak_factory_.GetWeakPtr(), id)); + RunSoon(FROM_HERE, base::BindOnce(&ServiceWorkerStorage::PurgeResource, + weak_factory_.GetWeakPtr(), id)); } void ServiceWorkerStorage::PurgeResource(int64_t id) { @@ -1636,10 +1706,11 @@ has_checked_for_stale_resources_ = true; database_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&ServiceWorkerStorage::CollectStaleResourcesFromDB, - database_.get(), base::ThreadTaskRunnerHandle::Get(), - base::Bind(&ServiceWorkerStorage::DidCollectStaleResources, - weak_factory_.GetWeakPtr()))); + base::BindOnce( + &ServiceWorkerStorage::CollectStaleResourcesFromDB, database_.get(), + base::ThreadTaskRunnerHandle::Get(), + base::BindOnce(&ServiceWorkerStorage::DidCollectStaleResources, + weak_factory_.GetWeakPtr()))); } void ServiceWorkerStorage::DidCollectStaleResources( @@ -1676,15 +1747,15 @@ void ServiceWorkerStorage::CollectStaleResourcesFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - const GetResourcesCallback& callback) { + GetResourcesCallback callback) { std::set<int64_t> ids; ServiceWorkerDatabase::Status status = database->GetUncommittedResourceIds(&ids); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, - base::BindOnce(callback, std::vector<int64_t>(ids.begin(), ids.end()), - status)); + base::BindOnce(std::move(callback), + std::vector<int64_t>(ids.begin(), ids.end()), status)); return; } @@ -1692,8 +1763,8 @@ if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, - base::BindOnce(callback, std::vector<int64_t>(ids.begin(), ids.end()), - status)); + base::BindOnce(std::move(callback), + std::vector<int64_t>(ids.begin(), ids.end()), status)); return; } @@ -1701,15 +1772,15 @@ status = database->GetPurgeableResourceIds(&ids); original_task_runner->PostTask( FROM_HERE, - base::BindOnce(callback, std::vector<int64_t>(ids.begin(), ids.end()), - status)); + base::BindOnce(std::move(callback), + std::vector<int64_t>(ids.begin(), ids.end()), status)); } // static void ServiceWorkerStorage::ReadInitialDataFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - const InitializeCallback& callback) { + InitializeCallback callback) { DCHECK(database); std::unique_ptr<ServiceWorkerStorage::InitialData> data( new ServiceWorkerStorage::InitialData()); @@ -1721,7 +1792,7 @@ if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, - base::BindOnce(callback, base::Passed(std::move(data)), status)); + base::BindOnce(std::move(callback), std::move(data), status)); return; } @@ -1729,13 +1800,12 @@ if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, - base::BindOnce(callback, base::Passed(std::move(data)), status)); + base::BindOnce(std::move(callback), std::move(data), status)); return; } original_task_runner->PostTask( - FROM_HERE, - base::BindOnce(callback, base::Passed(std::move(data)), status)); + FROM_HERE, base::BindOnce(std::move(callback), std::move(data), status)); } void ServiceWorkerStorage::DeleteRegistrationFromDB( @@ -1743,7 +1813,7 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const GURL& origin, - const DeleteRegistrationCallback& callback) { + DeleteRegistrationCallback callback) { DCHECK(database); ServiceWorkerDatabase::RegistrationData deleted_version; @@ -1752,8 +1822,9 @@ registration_id, origin, &deleted_version, &newly_purgeable_resources); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( - FROM_HERE, base::BindOnce(callback, OriginState::kKeep, deleted_version, - std::vector<int64_t>(), status)); + FROM_HERE, + base::BindOnce(std::move(callback), OriginState::kKeep, deleted_version, + std::vector<int64_t>(), status)); return; } @@ -1763,16 +1834,18 @@ status = database->GetRegistrationsForOrigin(origin, ®istrations, nullptr); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( - FROM_HERE, base::BindOnce(callback, OriginState::kKeep, deleted_version, - std::vector<int64_t>(), status)); + FROM_HERE, + base::BindOnce(std::move(callback), OriginState::kKeep, deleted_version, + std::vector<int64_t>(), status)); return; } OriginState origin_state = registrations.empty() ? OriginState::kDelete : OriginState::kKeep; original_task_runner->PostTask( - FROM_HERE, base::BindOnce(callback, origin_state, deleted_version, - newly_purgeable_resources, status)); + FROM_HERE, + base::BindOnce(std::move(callback), origin_state, deleted_version, + newly_purgeable_resources, status)); } void ServiceWorkerStorage::WriteRegistrationInDB( @@ -1780,7 +1853,7 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, - const WriteRegistrationCallback& callback) { + WriteRegistrationCallback callback) { DCHECK(database); ServiceWorkerDatabase::RegistrationData deleted_version; std::vector<int64_t> newly_purgeable_resources; @@ -1788,8 +1861,8 @@ data, resources, &deleted_version, &newly_purgeable_resources); original_task_runner->PostTask( FROM_HERE, - base::BindOnce(callback, data.script.GetOrigin(), deleted_version, - newly_purgeable_resources, status)); + base::BindOnce(std::move(callback), data.script.GetOrigin(), + deleted_version, newly_purgeable_resources, status)); } // static @@ -1797,16 +1870,16 @@ ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const GURL& document_url, - const FindInDBCallback& callback) { + FindInDBCallback callback) { GURL origin = document_url.GetOrigin(); RegistrationList registration_data_list; ServiceWorkerDatabase::Status status = database->GetRegistrationsForOrigin( origin, ®istration_data_list, nullptr); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( - FROM_HERE, - base::BindOnce(callback, ServiceWorkerDatabase::RegistrationData(), - ResourceList(), status)); + FROM_HERE, base::BindOnce(std::move(callback), + ServiceWorkerDatabase::RegistrationData(), + ResourceList(), status)); return; } @@ -1824,7 +1897,7 @@ status = database->ReadRegistration(match, origin, &data, &resources); original_task_runner->PostTask( - FROM_HERE, base::BindOnce(callback, data, resources, status)); + FROM_HERE, base::BindOnce(std::move(callback), data, resources, status)); } // static @@ -1832,16 +1905,16 @@ ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const GURL& scope, - const FindInDBCallback& callback) { + FindInDBCallback callback) { GURL origin = scope.GetOrigin(); RegistrationList registration_data_list; ServiceWorkerDatabase::Status status = database->GetRegistrationsForOrigin( origin, ®istration_data_list, nullptr); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( - FROM_HERE, - base::BindOnce(callback, ServiceWorkerDatabase::RegistrationData(), - ResourceList(), status)); + FROM_HERE, base::BindOnce(std::move(callback), + ServiceWorkerDatabase::RegistrationData(), + ResourceList(), status)); return; } @@ -1858,7 +1931,7 @@ } original_task_runner->PostTask( - FROM_HERE, base::BindOnce(callback, data, resources, status)); + FROM_HERE, base::BindOnce(std::move(callback), data, resources, status)); } // static @@ -1867,13 +1940,13 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const GURL& origin, - const FindInDBCallback& callback) { + FindInDBCallback callback) { ServiceWorkerDatabase::RegistrationData data; ResourceList resources; ServiceWorkerDatabase::Status status = database->ReadRegistration(registration_id, origin, &data, &resources); original_task_runner->PostTask( - FROM_HERE, base::BindOnce(callback, data, resources, status)); + FROM_HERE, base::BindOnce(std::move(callback), data, resources, status)); } // static @@ -1881,19 +1954,19 @@ ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, - const FindInDBCallback& callback) { + FindInDBCallback callback) { GURL origin; ServiceWorkerDatabase::Status status = database->ReadRegistrationOrigin(registration_id, &origin); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( - FROM_HERE, - base::BindOnce(callback, ServiceWorkerDatabase::RegistrationData(), - ResourceList(), status)); + FROM_HERE, base::BindOnce(std::move(callback), + ServiceWorkerDatabase::RegistrationData(), + ResourceList(), status)); return; } FindForIdInDB(database, original_task_runner, registration_id, origin, - callback); + std::move(callback)); } void ServiceWorkerStorage::GetUserDataInDB( @@ -1901,12 +1974,12 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const std::vector<std::string>& keys, - const GetUserDataInDBCallback& callback) { + GetUserDataInDBCallback callback) { std::vector<std::string> values; ServiceWorkerDatabase::Status status = database->ReadUserData(registration_id, keys, &values); - original_task_runner->PostTask(FROM_HERE, - base::BindOnce(callback, values, status)); + original_task_runner->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), values, status)); } void ServiceWorkerStorage::GetUserDataByKeyPrefixInDB( @@ -1914,12 +1987,12 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const std::string& key_prefix, - const GetUserDataInDBCallback& callback) { + GetUserDataInDBCallback callback) { std::vector<std::string> values; ServiceWorkerDatabase::Status status = database->ReadUserDataByKeyPrefix(registration_id, key_prefix, &values); - original_task_runner->PostTask(FROM_HERE, - base::BindOnce(callback, values, status)); + original_task_runner->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), values, status)); } void ServiceWorkerStorage::GetUserKeysAndDataByKeyPrefixInDB( @@ -1927,38 +2000,38 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const std::string& key_prefix, - const GetUserKeysAndDataInDBCallback& callback) { + GetUserKeysAndDataInDBCallback callback) { base::flat_map<std::string, std::string> data_map; ServiceWorkerDatabase::Status status = database->ReadUserKeysAndDataByKeyPrefix(registration_id, key_prefix, &data_map); - original_task_runner->PostTask(FROM_HERE, - base::BindOnce(callback, data_map, status)); + original_task_runner->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), data_map, status)); } void ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const std::string& key, - const GetUserDataForAllRegistrationsInDBCallback& callback) { + GetUserDataForAllRegistrationsInDBCallback callback) { std::vector<std::pair<int64_t, std::string>> user_data; ServiceWorkerDatabase::Status status = database->ReadUserDataForAllRegistrations(key, &user_data); - original_task_runner->PostTask(FROM_HERE, - base::BindOnce(callback, user_data, status)); + original_task_runner->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), user_data, status)); } void ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefixInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const std::string& key_prefix, - const GetUserDataForAllRegistrationsInDBCallback& callback) { + GetUserDataForAllRegistrationsInDBCallback callback) { std::vector<std::pair<int64_t, std::string>> user_data; ServiceWorkerDatabase::Status status = database->ReadUserDataForAllRegistrationsByKeyPrefix(key_prefix, &user_data); - original_task_runner->PostTask(FROM_HERE, - base::BindOnce(callback, user_data, status)); + original_task_runner->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), user_data, status)); } void ServiceWorkerStorage::DeleteAllDataForOriginsFromDB( @@ -1992,7 +2065,7 @@ } void ServiceWorkerStorage::DidDeleteDatabase( - const StatusCallback& callback, + StatusCallback callback, ServiceWorkerDatabase::Status status) { DCHECK_EQ(DISABLED, state_); if (status != ServiceWorkerDatabase::STATUS_OK) { @@ -2001,7 +2074,7 @@ << ServiceWorkerDatabase::StatusToString(status); ServiceWorkerMetrics::RecordDeleteAndStartOverResult( ServiceWorkerMetrics::DELETE_DATABASE_ERROR); - callback.Run(DatabaseStatusToStatusCode(status)); + std::move(callback).Run(DatabaseStatusToStatusCode(status)); return; } DVLOG(1) << "Deleted ServiceWorkerDatabase successfully."; @@ -2018,26 +2091,26 @@ // We should probably rename the directory and delete it later. PostTaskWithTraitsAndReplyWithResult( FROM_HERE, {base::MayBlock(), base::TaskShutdownBehavior::BLOCK_SHUTDOWN}, - base::Bind(&base::DeleteFile, GetDiskCachePath(), true), - base::Bind(&ServiceWorkerStorage::DidDeleteDiskCache, - weak_factory_.GetWeakPtr(), callback)); + base::BindOnce(&base::DeleteFile, GetDiskCachePath(), true), + base::BindOnce(&ServiceWorkerStorage::DidDeleteDiskCache, + weak_factory_.GetWeakPtr(), std::move(callback))); } -void ServiceWorkerStorage::DidDeleteDiskCache( - const StatusCallback& callback, bool result) { +void ServiceWorkerStorage::DidDeleteDiskCache(StatusCallback callback, + bool result) { DCHECK_EQ(DISABLED, state_); if (!result) { // Give up the corruption recovery until the browser restarts. LOG(ERROR) << "Failed to delete the diskcache."; ServiceWorkerMetrics::RecordDeleteAndStartOverResult( ServiceWorkerMetrics::DELETE_DISK_CACHE_ERROR); - callback.Run(SERVICE_WORKER_ERROR_FAILED); + std::move(callback).Run(SERVICE_WORKER_ERROR_FAILED); return; } DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; ServiceWorkerMetrics::RecordDeleteAndStartOverResult( ServiceWorkerMetrics::DELETE_OK); - callback.Run(SERVICE_WORKER_OK); + std::move(callback).Run(SERVICE_WORKER_OK); } } // namespace content
diff --git a/content/browser/service_worker/service_worker_storage.h b/content/browser/service_worker/service_worker_storage.h index 50b5b8e..56fe9d2 100644 --- a/content/browser/service_worker/service_worker_storage.h +++ b/content/browser/service_worker/service_worker_storage.h
@@ -55,30 +55,28 @@ class CONTENT_EXPORT ServiceWorkerStorage : public ServiceWorkerVersion::Listener { public: - typedef std::vector<ServiceWorkerDatabase::ResourceRecord> ResourceList; - typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; - typedef base::Callback<void( + using ResourceList = std::vector<ServiceWorkerDatabase::ResourceRecord>; + using StatusCallback = + base::OnceCallback<void(ServiceWorkerStatusCode status)>; + using FindRegistrationCallback = base::OnceCallback<void( ServiceWorkerStatusCode status, - scoped_refptr<ServiceWorkerRegistration> registration)> - FindRegistrationCallback; - typedef base::Callback<void( + scoped_refptr<ServiceWorkerRegistration> registration)>; + using GetRegistrationsCallback = base::OnceCallback<void( ServiceWorkerStatusCode status, const std::vector<scoped_refptr<ServiceWorkerRegistration>>& - registrations)> - GetRegistrationsCallback; - typedef base::Callback<void( + registrations)>; + using GetRegistrationsInfosCallback = base::OnceCallback<void( ServiceWorkerStatusCode status, - const std::vector<ServiceWorkerRegistrationInfo>& registrations)> - GetRegistrationsInfosCallback; + const std::vector<ServiceWorkerRegistrationInfo>& registrations)>; using GetUserDataCallback = - base::Callback<void(const std::vector<std::string>& data, - ServiceWorkerStatusCode status)>; - using GetUserKeysAndDataCallback = base::Callback<void( + base::OnceCallback<void(const std::vector<std::string>& data, + ServiceWorkerStatusCode status)>; + using GetUserKeysAndDataCallback = base::OnceCallback<void( const base::flat_map<std::string, std::string>& data_map, ServiceWorkerStatusCode status)>; - typedef base::Callback<void( + using GetUserDataForAllRegistrationsCallback = base::OnceCallback<void( const std::vector<std::pair<int64_t, std::string>>& user_data, - ServiceWorkerStatusCode status)> GetUserDataForAllRegistrationsCallback; + ServiceWorkerStatusCode status)>; ~ServiceWorkerStorage() override; @@ -104,12 +102,12 @@ // (the callback may be called prior to the method returning) or // asynchronously. void FindRegistrationForDocument(const GURL& document_url, - const FindRegistrationCallback& callback); + FindRegistrationCallback callback); void FindRegistrationForPattern(const GURL& scope, - const FindRegistrationCallback& callback); + FindRegistrationCallback callback); void FindRegistrationForId(int64_t registration_id, const GURL& origin, - const FindRegistrationCallback& callback); + FindRegistrationCallback callback); // Generally |FindRegistrationForId| should be used to look up a registration // by |registration_id| since it's more efficient. But if a |registration_id| @@ -117,16 +115,16 @@ // Like |FindRegistrationForId| this method may complete immediately (the // callback may be called prior to the method returning) or asynchronously. void FindRegistrationForIdOnly(int64_t registration_id, - const FindRegistrationCallback& callback); + FindRegistrationCallback callback); ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope); // Returns all stored registrations for a given origin. void GetRegistrationsForOrigin(const GURL& origin, - const GetRegistrationsCallback& callback); + GetRegistrationsCallback callback); // Returns info about all stored and initially installing registrations. - void GetAllRegistrationsInfos(const GetRegistrationsInfosCallback& callback); + void GetAllRegistrationsInfos(GetRegistrationsInfosCallback callback); // Commits |registration| with the installed but not activated |version| // to storage, overwritting any pre-existing registration data for the scope. @@ -134,12 +132,11 @@ // is live. PurgeResources should be called when it's OK to delete them. void StoreRegistration(ServiceWorkerRegistration* registration, ServiceWorkerVersion* version, - const StatusCallback& callback); + StatusCallback callback); // Updates the state of the registration's stored version to active. - void UpdateToActiveState( - ServiceWorkerRegistration* registration, - const StatusCallback& callback); + void UpdateToActiveState(ServiceWorkerRegistration* registration, + StatusCallback callback); // Updates the stored time to match the value of // registration->last_update_check(). @@ -150,18 +147,18 @@ void UpdateNavigationPreloadEnabled(int64_t registration_id, const GURL& origin, bool enable, - const StatusCallback& callback); + StatusCallback callback); void UpdateNavigationPreloadHeader(int64_t registration_id, const GURL& origin, const std::string& value, - const StatusCallback& callback); + StatusCallback callback); // Deletes the registration data for |registration_id|. If the registration's // version is live, its script resources will remain available. // PurgeResources should be called when it's OK to delete them. void DeleteRegistration(int64_t registration_id, const GURL& origin, - const StatusCallback& callback); + StatusCallback callback); // Creates a resource accessor. Never returns nullptr but an accessor may be // associated with the disabled disk cache if the storage is disabled. @@ -187,48 +184,47 @@ // and the callback's data will be empty. void GetUserData(int64_t registration_id, const std::vector<std::string>& keys, - const GetUserDataCallback& callback); + GetUserDataCallback callback); // GetUserDataByKeyPrefix responds OK with a vector containing data rows that // had matching keys assuming the database was read successfully. void GetUserDataByKeyPrefix(int64_t registration_id, const std::string& key_prefix, - const GetUserDataCallback& callback); + GetUserDataCallback callback); // GetUserKeysAndDataByKeyPrefix responds OK with a flat_map containing // matching keys and their data assuming the database was read successfully. // The map keys have |key_prefix| stripped from them. - void GetUserKeysAndDataByKeyPrefix( - int64_t registration_id, - const std::string& key_prefix, - const GetUserKeysAndDataCallback& callback); + void GetUserKeysAndDataByKeyPrefix(int64_t registration_id, + const std::string& key_prefix, + GetUserKeysAndDataCallback callback); // Stored data is deleted when the associated registraton is deleted. void StoreUserData( int64_t registration_id, const GURL& origin, const std::vector<std::pair<std::string, std::string>>& key_value_pairs, - const StatusCallback& callback); + StatusCallback callback); // Responds OK if all are successfully deleted or not found in the database. void ClearUserData(int64_t registration_id, const std::vector<std::string>& keys, - const StatusCallback& callback); + StatusCallback callback); // Responds OK if all are successfully deleted or not found in the database. // Neither |key_prefixes| nor the prefixes within can be empty. void ClearUserDataByKeyPrefixes(int64_t registration_id, const std::vector<std::string>& key_prefixes, - const StatusCallback& callback); + StatusCallback callback); // Responds with all registrations that have user data with a particular key, // as well as that user data. void GetUserDataForAllRegistrations( const std::string& key, - const GetUserDataForAllRegistrationsCallback& callback); + GetUserDataForAllRegistrationsCallback callback); // Responds with all registrations that have user data with a particular key, // as well as that user data. void GetUserDataForAllRegistrationsByKeyPrefix( const std::string& key_prefix, - const GetUserDataForAllRegistrationsCallback& callback); + GetUserDataForAllRegistrationsCallback callback); // Deletes the storage and starts over. - void DeleteAndStartOver(const StatusCallback& callback); + void DeleteAndStartOver(StatusCallback callback); // Returns a new registration id which is guaranteed to be unique in the // storage. Returns blink::mojom::kInvalidServiceWorkerRegistrationId if the @@ -291,8 +287,9 @@ GURL origin; StatusCallback callback; - DidDeleteRegistrationParams(); - DidDeleteRegistrationParams(const DidDeleteRegistrationParams& other); + DidDeleteRegistrationParams(int64_t registration_id, + GURL origin, + StatusCallback callback); ~DidDeleteRegistrationParams(); }; @@ -303,41 +300,38 @@ kDelete }; - typedef std::vector<ServiceWorkerDatabase::RegistrationData> RegistrationList; - typedef std::map<int64_t, scoped_refptr<ServiceWorkerRegistration>> - RegistrationRefsById; - typedef base::Callback<void(std::unique_ptr<InitialData> data, - ServiceWorkerDatabase::Status status)> - InitializeCallback; - typedef base::Callback<void(ServiceWorkerDatabase::Status status)> - DatabaseStatusCallback; - typedef base::Callback<void( + using RegistrationList = std::vector<ServiceWorkerDatabase::RegistrationData>; + using RegistrationRefsById = + std::map<int64_t, scoped_refptr<ServiceWorkerRegistration>>; + using InitializeCallback = + base::OnceCallback<void(std::unique_ptr<InitialData> data, + ServiceWorkerDatabase::Status status)>; + using WriteRegistrationCallback = base::OnceCallback<void( const GURL& origin, const ServiceWorkerDatabase::RegistrationData& deleted_version_data, const std::vector<int64_t>& newly_purgeable_resources, - ServiceWorkerDatabase::Status status)> WriteRegistrationCallback; - typedef base::Callback<void( + ServiceWorkerDatabase::Status status)>; + using DeleteRegistrationCallback = base::OnceCallback<void( OriginState origin_state, const ServiceWorkerDatabase::RegistrationData& deleted_version_data, const std::vector<int64_t>& newly_purgeable_resources, - ServiceWorkerDatabase::Status status)> DeleteRegistrationCallback; - typedef base::Callback<void( + ServiceWorkerDatabase::Status status)>; + using FindInDBCallback = base::OnceCallback<void( const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, - ServiceWorkerDatabase::Status status)> FindInDBCallback; - using GetUserKeysAndDataInDBCallback = base::Callback<void( + ServiceWorkerDatabase::Status status)>; + using GetUserKeysAndDataInDBCallback = base::OnceCallback<void( const base::flat_map<std::string, std::string>& data_map, ServiceWorkerDatabase::Status)>; - typedef base::Callback<void(const std::vector<std::string>& data, - ServiceWorkerDatabase::Status)> - GetUserDataInDBCallback; - typedef base::Callback<void( + using GetUserDataInDBCallback = + base::OnceCallback<void(const std::vector<std::string>& data, + ServiceWorkerDatabase::Status)>; + using GetUserDataForAllRegistrationsInDBCallback = base::OnceCallback<void( const std::vector<std::pair<int64_t, std::string>>& user_data, - ServiceWorkerDatabase::Status)> - GetUserDataForAllRegistrationsInDBCallback; - typedef base::Callback<void(const std::vector<int64_t>& resource_ids, - ServiceWorkerDatabase::Status status)> - GetResourcesCallback; + ServiceWorkerDatabase::Status)>; + using GetResourcesCallback = + base::OnceCallback<void(const std::vector<int64_t>& resource_ids, + ServiceWorkerDatabase::Status status)>; ServiceWorkerStorage( const base::FilePath& path, @@ -349,48 +343,46 @@ base::FilePath GetDatabasePath(); base::FilePath GetDiskCachePath(); - bool LazyInitialize(base::OnceClosure callback); + void LazyInitialize(base::OnceClosure callback); void DidReadInitialData(std::unique_ptr<InitialData> data, ServiceWorkerDatabase::Status status); void DidFindRegistrationForDocument( const GURL& document_url, - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, int64_t callback_id, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status); void DidFindRegistrationForPattern( const GURL& scope, - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status); void DidFindRegistrationForId( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status); - void DidGetRegistrationsForOrigin(const GetRegistrationsCallback& callback, + void DidGetRegistrationsForOrigin(GetRegistrationsCallback callback, RegistrationList* registration_data_list, std::vector<ResourceList>* resources_list, const GURL& origin_filter, ServiceWorkerDatabase::Status status); - void DidGetAllRegistrationsInfos( - const GetRegistrationsInfosCallback& callback, - RegistrationList* registration_data_list, - ServiceWorkerDatabase::Status status); + void DidGetAllRegistrationsInfos(GetRegistrationsInfosCallback callback, + RegistrationList* registration_data_list, + ServiceWorkerDatabase::Status status); void DidStoreRegistration( - const StatusCallback& callback, + StatusCallback callback, const ServiceWorkerDatabase::RegistrationData& new_version, const GURL& origin, const ServiceWorkerDatabase::RegistrationData& deleted_version, const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status); - void DidUpdateToActiveState( - const StatusCallback& callback, - ServiceWorkerDatabase::Status status); + void DidUpdateToActiveState(StatusCallback callback, + ServiceWorkerDatabase::Status status); void DidDeleteRegistration( - const DidDeleteRegistrationParams& params, + std::unique_ptr<DidDeleteRegistrationParams> params, OriginState origin_state, const ServiceWorkerDatabase::RegistrationData& deleted_version, const std::vector<int64_t>& newly_purgeable_resources, @@ -398,24 +390,23 @@ void DidWriteUncommittedResourceIds(ServiceWorkerDatabase::Status status); void DidPurgeUncommittedResourceIds(const std::set<int64_t>& resource_ids, ServiceWorkerDatabase::Status status); - void DidStoreUserData( - const StatusCallback& callback, - ServiceWorkerDatabase::Status status); - void DidGetUserData(const GetUserDataCallback& callback, + void DidStoreUserData(StatusCallback callback, + ServiceWorkerDatabase::Status status); + void DidGetUserData(GetUserDataCallback callback, const std::vector<std::string>& data, ServiceWorkerDatabase::Status status); void DidGetUserKeysAndData( - const GetUserKeysAndDataCallback& callback, + GetUserKeysAndDataCallback callback, const base::flat_map<std::string, std::string>& map, ServiceWorkerDatabase::Status status); - void DidDeleteUserData(const StatusCallback& callback, + void DidDeleteUserData(StatusCallback callback, ServiceWorkerDatabase::Status status); void DidGetUserDataForAllRegistrations( - const GetUserDataForAllRegistrationsCallback& callback, + GetUserDataForAllRegistrationsCallback callback, const std::vector<std::pair<int64_t, std::string>>& user_data, ServiceWorkerDatabase::Status status); void ReturnFoundRegistration( - const FindRegistrationCallback& callback, + FindRegistrationCallback callback, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources); @@ -454,72 +445,72 @@ static void CollectStaleResourcesFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - const GetResourcesCallback& callback); + GetResourcesCallback callback); static void ReadInitialDataFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - const InitializeCallback& callback); + InitializeCallback callback); static void DeleteRegistrationFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const GURL& origin, - const DeleteRegistrationCallback& callback); + DeleteRegistrationCallback callback); static void WriteRegistrationInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const ServiceWorkerDatabase::RegistrationData& registration, const ResourceList& resources, - const WriteRegistrationCallback& callback); + WriteRegistrationCallback callback); static void FindForDocumentInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const GURL& document_url, - const FindInDBCallback& callback); + FindInDBCallback callback); static void FindForPatternInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const GURL& scope, - const FindInDBCallback& callback); + FindInDBCallback callback); static void FindForIdInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const GURL& origin, - const FindInDBCallback& callback); + FindInDBCallback callback); static void FindForIdOnlyInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, - const FindInDBCallback& callback); + FindInDBCallback callback); static void GetUserDataInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const std::vector<std::string>& keys, - const GetUserDataInDBCallback& callback); + GetUserDataInDBCallback callback); static void GetUserDataByKeyPrefixInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const std::string& key_prefix, - const GetUserDataInDBCallback& callback); + GetUserDataInDBCallback callback); static void GetUserKeysAndDataByKeyPrefixInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, int64_t registration_id, const std::string& key_prefix, - const GetUserKeysAndDataInDBCallback& callback); + GetUserKeysAndDataInDBCallback callback); static void GetUserDataForAllRegistrationsInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const std::string& key, - const GetUserDataForAllRegistrationsInDBCallback& callback); + GetUserDataForAllRegistrationsInDBCallback callback); static void GetUserDataForAllRegistrationsByKeyPrefixInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const std::string& key_prefix, - const GetUserDataForAllRegistrationsInDBCallback& callback); + GetUserDataForAllRegistrationsInDBCallback callback); static void DeleteAllDataForOriginsFromDB( ServiceWorkerDatabase* database, const std::set<GURL>& origins); @@ -530,12 +521,10 @@ // Posted by the underlying cache implementation after it finishes making // disk changes upon its destruction. void DiskCacheImplDoneWithDisk(); - void DidDeleteDatabase(const StatusCallback& callback, + void DidDeleteDatabase(StatusCallback callback, ServiceWorkerDatabase::Status status); // Posted when we finish deleting the cache directory. - void DidDeleteDiskCache( - const StatusCallback& callback, - bool result); + void DidDeleteDiskCache(StatusCallback callback, bool result); // For finding registrations being installed or uninstalled. RegistrationRefsById installing_registrations_;
diff --git a/content/browser/service_worker/service_worker_storage_unittest.cc b/content/browser/service_worker/service_worker_storage_unittest.cc index 2c3fa575..4aaa66f 100644 --- a/content/browser/service_worker/service_worker_storage_unittest.cc +++ b/content/browser/service_worker/service_worker_storage_unittest.cc
@@ -40,8 +40,8 @@ #include "net/test/cert_test_util.h" #include "net/test/test_data_directory.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" using net::IOBuffer; using net::TestCompletionCallback; @@ -86,7 +86,7 @@ ServiceWorkerStorage::StatusCallback MakeStatusCallback( bool* was_called, ServiceWorkerStatusCode* result) { - return base::Bind(&StatusCallback, was_called, result); + return base::BindOnce(&StatusCallback, was_called, result); } void FindCallback(bool* was_called, @@ -103,7 +103,7 @@ bool* was_called, ServiceWorkerStatusCode* result, scoped_refptr<ServiceWorkerRegistration>* found) { - return base::Bind(&FindCallback, was_called, result, found); + return base::BindOnce(&FindCallback, was_called, result, found); } void GetAllCallback( @@ -132,7 +132,7 @@ bool* was_called, ServiceWorkerStatusCode* status, std::vector<scoped_refptr<ServiceWorkerRegistration>>* all) { - return base::Bind(&GetAllCallback, was_called, status, all); + return base::BindOnce(&GetAllCallback, was_called, status, all); } ServiceWorkerStorage::GetRegistrationsInfosCallback @@ -140,7 +140,7 @@ bool* was_called, ServiceWorkerStatusCode* status, std::vector<ServiceWorkerRegistrationInfo>* all) { - return base::Bind(&GetAllInfosCallback, was_called, status, all); + return base::BindOnce(&GetAllInfosCallback, was_called, status, all); } void GetUserDataCallback(bool* was_called, @@ -356,7 +356,7 @@ } void LazyInitialize() { - storage()->LazyInitialize(base::BindOnce(&base::DoNothing)); + storage()->LazyInitializeForTest(base::BindOnce(&base::DoNothing)); base::RunLoop().RunUntilIdle(); } @@ -440,7 +440,7 @@ ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; storage()->GetUserData( registration_id, keys, - base::Bind(&GetUserDataCallback, &was_called, data, &result)); + base::BindOnce(&GetUserDataCallback, &was_called, data, &result)); EXPECT_FALSE(was_called); // always async base::RunLoop().RunUntilIdle(); EXPECT_TRUE(was_called); @@ -455,7 +455,7 @@ ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; storage()->GetUserDataByKeyPrefix( registration_id, key_prefix, - base::Bind(&GetUserDataCallback, &was_called, data, &result)); + base::BindOnce(&GetUserDataCallback, &was_called, data, &result)); EXPECT_FALSE(was_called); // always async base::RunLoop().RunUntilIdle(); EXPECT_TRUE(was_called); @@ -508,8 +508,8 @@ bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; storage()->GetUserDataForAllRegistrations( - key, base::Bind(&GetUserDataForAllRegistrationsCallback, &was_called, - data, &result)); + key, base::BindOnce(&GetUserDataForAllRegistrationsCallback, + &was_called, data, &result)); EXPECT_FALSE(was_called); // always async base::RunLoop().RunUntilIdle(); EXPECT_TRUE(was_called); @@ -1357,10 +1357,11 @@ // Deleting the registration should result in the resources being added to the // purgeable list and then doomed in the disk cache and removed from that // list. - storage()->DeleteRegistration(registration_id_, scope_.GetOrigin(), - base::Bind(&VerifyPurgeableListStatusCallback, - base::Unretained(database()), - &verify_ids, &was_called, &result)); + storage()->DeleteRegistration( + registration_id_, scope_.GetOrigin(), + base::BindOnce(&VerifyPurgeableListStatusCallback, + base::Unretained(database()), &verify_ids, &was_called, + &result)); base::RunLoop().RunUntilIdle(); ASSERT_TRUE(was_called); EXPECT_EQ(SERVICE_WORKER_OK, result); @@ -1382,10 +1383,11 @@ // Deleting the registration should result in the resources being added to the // purgeable list and then doomed in the disk cache and removed from that // list. - storage()->DeleteRegistration(registration_->id(), scope_.GetOrigin(), - base::Bind(&VerifyPurgeableListStatusCallback, - base::Unretained(database()), - &verify_ids, &was_called, &result)); + storage()->DeleteRegistration( + registration_->id(), scope_.GetOrigin(), + base::BindOnce(&VerifyPurgeableListStatusCallback, + base::Unretained(database()), &verify_ids, &was_called, + &result)); base::RunLoop().RunUntilIdle(); ASSERT_TRUE(was_called); EXPECT_EQ(SERVICE_WORKER_OK, result); @@ -1416,7 +1418,8 @@ // Promote the worker to active and add a controllee. registration_->SetActiveVersion(registration_->waiting_version()); storage()->UpdateToActiveState( - registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); + registration_.get(), + base::BindOnce(&ServiceWorkerUtils::NoOpStatusCallback)); ServiceWorkerRemoteProviderEndpoint remote_endpoint; std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( 33 /* dummy render process id */, 1 /* dummy provider_id */, @@ -1430,10 +1433,11 @@ // Deleting the registration should move the resources to the purgeable list // but keep them available. - storage()->DeleteRegistration(registration_->id(), scope_.GetOrigin(), - base::Bind(&VerifyPurgeableListStatusCallback, - base::Unretained(database()), - &verify_ids, &was_called, &result)); + storage()->DeleteRegistration( + registration_->id(), scope_.GetOrigin(), + base::BindOnce(&VerifyPurgeableListStatusCallback, + base::Unretained(database()), &verify_ids, &was_called, + &result)); base::RunLoop().RunUntilIdle(); ASSERT_TRUE(was_called); EXPECT_EQ(SERVICE_WORKER_OK, result); @@ -1464,7 +1468,8 @@ registration_->SetActiveVersion(registration_->waiting_version()); registration_->SetWaitingVersion(nullptr); storage()->UpdateToActiveState( - registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); + registration_.get(), + base::BindOnce(&ServiceWorkerUtils::NoOpStatusCallback)); ServiceWorkerRemoteProviderEndpoint remote_endpoint; std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( 33 /* dummy render process id */, 1 /* dummy provider_id */, @@ -1478,10 +1483,11 @@ // Deleting the registration should move the resources to the purgeable list // but keep them available. - storage()->DeleteRegistration(registration_->id(), scope_.GetOrigin(), - base::Bind(&VerifyPurgeableListStatusCallback, - base::Unretained(database()), - &verify_ids, &was_called, &result)); + storage()->DeleteRegistration( + registration_->id(), scope_.GetOrigin(), + base::BindOnce(&VerifyPurgeableListStatusCallback, + base::Unretained(database()), &verify_ids, &was_called, + &result)); base::RunLoop().RunUntilIdle(); ASSERT_TRUE(was_called); EXPECT_EQ(SERVICE_WORKER_OK, result); @@ -1548,7 +1554,7 @@ base::RunLoop run_loop; ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; storage()->DeleteAndStartOver( - base::Bind(&StatusAndQuitCallback, &status, run_loop.QuitClosure())); + base::BindOnce(&StatusAndQuitCallback, &status, run_loop.QuitClosure())); run_loop.Run(); EXPECT_EQ(SERVICE_WORKER_OK, status); @@ -1573,7 +1579,7 @@ base::RunLoop run_loop; ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; storage()->DeleteAndStartOver( - base::Bind(&StatusAndQuitCallback, &status, run_loop.QuitClosure())); + base::BindOnce(&StatusAndQuitCallback, &status, run_loop.QuitClosure())); run_loop.Run(); EXPECT_EQ(SERVICE_WORKER_OK, status); @@ -1599,7 +1605,7 @@ base::RunLoop run_loop; ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; storage()->DeleteAndStartOver( - base::Bind(&StatusAndQuitCallback, &status, run_loop.QuitClosure())); + base::BindOnce(&StatusAndQuitCallback, &status, run_loop.QuitClosure())); run_loop.Run(); #if defined(OS_WIN) @@ -1620,7 +1626,8 @@ // Promote the worker to active worker and add a controllee. registration_->SetActiveVersion(registration_->waiting_version()); storage()->UpdateToActiveState( - registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); + registration_.get(), + base::BindOnce(&ServiceWorkerUtils::NoOpStatusCallback)); ServiceWorkerRemoteProviderEndpoint remote_endpoint; std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( 33 /* dummy render process id */, 1 /* dummy provider_id */, @@ -1646,11 +1653,11 @@ // Writing the registration should move the old version's resources to the // purgeable list but keep them available. - storage()->StoreRegistration(registration_.get(), - registration_->waiting_version(), - base::Bind(&VerifyPurgeableListStatusCallback, - base::Unretained(database()), - &verify_ids, &was_called, &result)); + storage()->StoreRegistration( + registration_.get(), registration_->waiting_version(), + base::BindOnce(&VerifyPurgeableListStatusCallback, + base::Unretained(database()), &verify_ids, &was_called, + &result)); base::RunLoop().RunUntilIdle(); ASSERT_TRUE(was_called); EXPECT_EQ(SERVICE_WORKER_OK, result);
diff --git a/content/browser/service_worker/service_worker_test_utils.h b/content/browser/service_worker/service_worker_test_utils.h index eb67a84..2775be36 100644 --- a/content/browser/service_worker/service_worker_test_utils.h +++ b/content/browser/service_worker/service_worker_test_utils.h
@@ -16,7 +16,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/common/content_switches.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace net {
diff --git a/content/browser/service_worker/service_worker_type_converters.h b/content/browser/service_worker/service_worker_type_converters.h index 10b3f0fb..4aa2193b 100644 --- a/content/browser/service_worker/service_worker_type_converters.h +++ b/content/browser/service_worker/service_worker_type_converters.h
@@ -7,8 +7,8 @@ #include "content/browser/service_worker/service_worker_version.h" #include "content/common/service_worker/service_worker_status_code.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_state.mojom.h" namespace mojo {
diff --git a/content/browser/service_worker/service_worker_unregister_job.cc b/content/browser/service_worker/service_worker_unregister_job.cc index 8f4ccf9..9fbe51be 100644 --- a/content/browser/service_worker/service_worker_unregister_job.cc +++ b/content/browser/service_worker/service_worker_unregister_job.cc
@@ -11,7 +11,7 @@ #include "content/browser/service_worker/service_worker_storage.h" #include "content/browser/service_worker/service_worker_version.h" #include "content/common/service_worker/service_worker_utils.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_url_loader_job.h b/content/browser/service_worker/service_worker_url_loader_job.h index 84553df..b22e8b7 100644 --- a/content/browser/service_worker/service_worker_url_loader_job.h +++ b/content/browser/service_worker/service_worker_url_loader_job.h
@@ -21,7 +21,7 @@ #include "content/public/common/url_loader.mojom.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/system/data_pipe.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_stream_handle.mojom.h" namespace net { struct RedirectInfo;
diff --git a/content/browser/service_worker/service_worker_url_loader_job_unittest.cc b/content/browser/service_worker/service_worker_url_loader_job_unittest.cc index 57fe74a..fc3403c 100644 --- a/content/browser/service_worker/service_worker_url_loader_job_unittest.cc +++ b/content/browser/service_worker/service_worker_url_loader_job_unittest.cc
@@ -30,8 +30,8 @@ #include "storage/browser/blob/blob_impl.h" #include "storage/browser/blob/blob_storage_context.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_url_request_job_unittest.cc b/content/browser/service_worker/service_worker_url_request_job_unittest.cc index 7f709052..b1a5f4e 100644 --- a/content/browser/service_worker/service_worker_url_request_job_unittest.cc +++ b/content/browser/service_worker/service_worker_url_request_job_unittest.cc
@@ -63,9 +63,9 @@ #include "storage/browser/blob/blob_url_request_job_factory.h" #include "storage/common/blob_storage/blob_handle.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index 079c61c..6d62c16 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc
@@ -47,8 +47,8 @@ #include "net/http/http_response_info.h" #include "third_party/WebKit/common/origin_trials/trial_token_validator.h" #include "third_party/WebKit/common/service_worker/service_worker_client.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/web/WebConsoleMessage.h" namespace content {
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h index a309f73f..2e267780 100644 --- a/content/browser/service_worker/service_worker_version.h +++ b/content/browser/service_worker/service_worker_version.h
@@ -42,8 +42,8 @@ #include "mojo/public/cpp/bindings/interface_ptr.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/WebKit/common/origin_trials/trial_token_validator.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" #include "ui/base/mojo/window_open_disposition.mojom.h" #include "url/gurl.h" #include "url/origin.h"
diff --git a/content/browser/service_worker/service_worker_version_unittest.cc b/content/browser/service_worker/service_worker_version_unittest.cc index d29fc01..318e190 100644 --- a/content/browser/service_worker/service_worker_version_unittest.cc +++ b/content/browser/service_worker/service_worker_version_unittest.cc
@@ -29,9 +29,9 @@ #include "content/public/test/test_utils.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" // IPC messages for testing ---------------------------------------------------
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc index 898ccca7..51e46c33 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
@@ -37,7 +37,7 @@ #include "net/url_request/url_request_test_util.h" #include "storage/browser/blob/blob_storage_context.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 29cc2d2..f6e6757 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn
@@ -376,7 +376,8 @@ "//ppapi/features", "//sandbox", "//sandbox:sandbox_features", - "//services/network/public/interfaces:interfaces", + "//services/network/public/cpp", + "//services/network/public/interfaces", "//services/resource_coordinator/public/cpp:resource_coordinator_cpp", "//services/service_manager", "//services/service_manager/embedder",
diff --git a/content/common/DEPS b/content/common/DEPS index 845cce9..26cda20 100644 --- a/content/common/DEPS +++ b/content/common/DEPS
@@ -64,13 +64,6 @@ "+third_party/WebKit/public/platform/modules/payments/WebPaymentAppRequest.h", "+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerClientType.h", "+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h", - "+third_party/WebKit/public/platform/modules/serviceworker/navigation_preload_state.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h", - "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom.h", "+third_party/WebKit/public/web/WebAXEnums.h", "+third_party/WebKit/public/web/WebDeviceEmulationParams.h", "+third_party/WebKit/public/web/WebDragStatus.h",
diff --git a/content/common/resource_messages.cc b/content/common/resource_messages.cc index b97fa77..63071fe 100644 --- a/content/common/resource_messages.cc +++ b/content/common/resource_messages.cc
@@ -40,102 +40,6 @@ l->append("<HttpResponseHeaders>"); } -namespace { - -void WriteCert(base::Pickle* m, net::X509Certificate* cert) { - WriteParam(m, !!cert); - if (cert) - cert->Persist(m); -} - -bool ReadCert(const base::Pickle* m, - base::PickleIterator* iter, - scoped_refptr<net::X509Certificate>* cert) { - DCHECK(!*cert); - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (!has_object) - return true; - *cert = net::X509Certificate::CreateFromPickle(iter); - return !!cert->get(); -} - -} // namespace - -void ParamTraits<net::SSLInfo>::Write(base::Pickle* m, const param_type& p) { - WriteParam(m, p.is_valid()); - if (!p.is_valid()) - return; - WriteCert(m, p.cert.get()); - WriteCert(m, p.unverified_cert.get()); - WriteParam(m, p.cert_status); - WriteParam(m, p.security_bits); - WriteParam(m, p.key_exchange_group); - WriteParam(m, p.connection_status); - WriteParam(m, p.is_issued_by_known_root); - WriteParam(m, p.pkp_bypassed); - WriteParam(m, p.client_cert_sent); - WriteParam(m, p.channel_id_sent); - WriteParam(m, p.token_binding_negotiated); - WriteParam(m, p.token_binding_key_param); - WriteParam(m, p.handshake_type); - WriteParam(m, p.public_key_hashes); - WriteParam(m, p.pinning_failure_log); - WriteParam(m, p.signed_certificate_timestamps); - WriteParam(m, p.ct_policy_compliance); - WriteParam(m, p.ocsp_result.response_status); - WriteParam(m, p.ocsp_result.revocation_status); -} - -bool ParamTraits<net::SSLInfo>::Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* r) { - bool is_valid = false; - if (!ReadParam(m, iter, &is_valid)) - return false; - if (!is_valid) - return true; - return ReadCert(m, iter, &r->cert) && - ReadCert(m, iter, &r->unverified_cert) && - ReadParam(m, iter, &r->cert_status) && - ReadParam(m, iter, &r->security_bits) && - ReadParam(m, iter, &r->key_exchange_group) && - ReadParam(m, iter, &r->connection_status) && - ReadParam(m, iter, &r->is_issued_by_known_root) && - ReadParam(m, iter, &r->pkp_bypassed) && - ReadParam(m, iter, &r->client_cert_sent) && - ReadParam(m, iter, &r->channel_id_sent) && - ReadParam(m, iter, &r->token_binding_negotiated) && - ReadParam(m, iter, &r->token_binding_key_param) && - ReadParam(m, iter, &r->handshake_type) && - ReadParam(m, iter, &r->public_key_hashes) && - ReadParam(m, iter, &r->pinning_failure_log) && - ReadParam(m, iter, &r->signed_certificate_timestamps) && - ReadParam(m, iter, &r->ct_policy_compliance) && - ReadParam(m, iter, &r->ocsp_result.response_status) && - ReadParam(m, iter, &r->ocsp_result.revocation_status); -} - -void ParamTraits<net::SSLInfo>::Log(const param_type& p, std::string* l) { - l->append("<SSLInfo>"); -} - -void ParamTraits<net::HashValue>::Write(base::Pickle* m, const param_type& p) { - WriteParam(m, p.ToString()); -} - -bool ParamTraits<net::HashValue>::Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* r) { - std::string str; - return ReadParam(m, iter, &str) && r->FromString(str); -} - -void ParamTraits<net::HashValue>::Log(const param_type& p, std::string* l) { - l->append("<HashValue>"); -} - void ParamTraits<storage::DataElement>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<int>(p.type())); @@ -490,30 +394,4 @@ l->append("<ResourceRequestBody>"); } -void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Write( - base::Pickle* m, - const param_type& p) { - WriteParam(m, p.get() != nullptr); - if (p.get()) - p->Persist(m); -} - -bool ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Read( - const base::Pickle* m, - base::PickleIterator* iter, - param_type* r) { - bool has_object; - if (!ReadParam(m, iter, &has_object)) - return false; - if (has_object) - *r = net::ct::SignedCertificateTimestamp::CreateFromPickle(iter); - return true; -} - -void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Log( - const param_type& p, - std::string* l) { - l->append("<SignedCertificateTimestamp>"); -} - } // namespace IPC
diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index 3b37496..d8a3bf4 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h
@@ -22,14 +22,11 @@ #include "content/public/common/service_worker_modes.h" #include "ipc/ipc_message_macros.h" #include "net/base/request_priority.h" -#include "net/cert/ct_policy_status.h" -#include "net/cert/signed_certificate_timestamp.h" -#include "net/cert/signed_certificate_timestamp_and_status.h" #include "net/http/http_response_info.h" -#include "net/ssl/ssl_info.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/redirect_info.h" #include "services/network/public/cpp/cors_error_status.h" +#include "services/network/public/cpp/ssl_info_ipc_traits.h" #include "services/network/public/cpp/url_loader_completion_status.h" #include "services/network/public/interfaces/fetch_api.mojom.h" #include "third_party/WebKit/public/platform/WebMixedContentContextType.h" @@ -58,26 +55,6 @@ }; template <> -struct CONTENT_EXPORT ParamTraits<net::SSLInfo> { - typedef net::SSLInfo param_type; - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct CONTENT_EXPORT ParamTraits<net::HashValue> { - typedef net::HashValue param_type; - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template <> struct CONTENT_EXPORT ParamTraits<storage::DataElement> { typedef storage::DataElement param_type; static void Write(base::Pickle* m, const param_type& p); @@ -117,16 +94,6 @@ static void Log(const param_type& p, std::string* l); }; -template <> -struct ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> { - typedef scoped_refptr<net::ct::SignedCertificateTimestamp> param_type; - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* r); - static void Log(const param_type& p, std::string* l); -}; - } // namespace IPC #endif // INTERNAL_CONTENT_COMMON_RESOURCE_MESSAGES_H_ @@ -139,17 +106,6 @@ net::HttpResponseInfo::ConnectionInfo, \ net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1) -IPC_ENUM_TRAITS_MAX_VALUE(net::TokenBindingParam, net::TB_PARAM_ECDSAP256) -IPC_ENUM_TRAITS_MAX_VALUE(net::SSLInfo::HandshakeType, - net::SSLInfo::HANDSHAKE_FULL) -IPC_ENUM_TRAITS_MAX_VALUE( - net::ct::CTPolicyCompliance, - net::ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE) -IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPVerifyResult::ResponseStatus, - net::OCSPVerifyResult::PARSE_RESPONSE_DATA_ERROR) -IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPRevocationStatus, - net::OCSPRevocationStatus::UNKNOWN) - IPC_ENUM_TRAITS_MAX_VALUE(network::mojom::FetchRequestMode, network::mojom::FetchRequestMode::kLast) @@ -237,13 +193,6 @@ IPC_STRUCT_TRAITS_MEMBER(unique_id_hash_code) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(net::SignedCertificateTimestampAndStatus) - IPC_STRUCT_TRAITS_MEMBER(sct) - IPC_STRUCT_TRAITS_MEMBER(status) -IPC_STRUCT_TRAITS_END() - -IPC_ENUM_TRAITS_MAX_VALUE(net::ct::SCTVerifyStatus, net::ct::SCT_STATUS_MAX) - IPC_STRUCT_TRAITS_BEGIN(content::ResourceRequest) IPC_STRUCT_TRAITS_MEMBER(method) IPC_STRUCT_TRAITS_MEMBER(url)
diff --git a/content/common/service_worker/controller_service_worker.mojom b/content/common/service_worker/controller_service_worker.mojom index 4910c33..7ca8a53 100644 --- a/content/common/service_worker/controller_service_worker.mojom +++ b/content/common/service_worker/controller_service_worker.mojom
@@ -8,7 +8,7 @@ import "content/common/service_worker/service_worker_fetch_response_callback.mojom"; import "content/public/common/url_loader.mojom"; import "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_event_status.mojom"; // S13nServiceWorker: // Represents a service worker that is a 'controller'.
diff --git a/content/common/service_worker/embedded_worker.mojom b/content/common/service_worker/embedded_worker.mojom index 6d61373..80a62b7 100644 --- a/content/common/service_worker/embedded_worker.mojom +++ b/content/common/service_worker/embedded_worker.mojom
@@ -13,7 +13,7 @@ import "mojo/common/time.mojom"; import "mojo/common/unguessable_token.mojom"; import "services/service_manager/public/interfaces/interface_provider.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom"; +import "third_party/WebKit/common/service_worker/service_worker.mojom"; import "third_party/WebKit/public/web/console_message.mojom"; import "third_party/WebKit/public/web/worker_content_settings_proxy.mojom"; import "url/mojo/url.mojom";
diff --git a/content/common/service_worker/service_worker_container.mojom b/content/common/service_worker/service_worker_container.mojom index 3be3efd..b19654c 100644 --- a/content/common/service_worker/service_worker_container.mojom +++ b/content/common/service_worker/service_worker_container.mojom
@@ -6,9 +6,9 @@ import "content/common/service_worker/controller_service_worker.mojom"; import "mojo/common/string16.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_error_type.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_object.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_registration.mojom"; import "third_party/WebKit/public/platform/web_feature.mojom"; import "url/mojo/url.mojom";
diff --git a/content/common/service_worker/service_worker_event_dispatcher.mojom b/content/common/service_worker/service_worker_event_dispatcher.mojom index bb2b3bf..c462f3a 100644 --- a/content/common/service_worker/service_worker_event_dispatcher.mojom +++ b/content/common/service_worker/service_worker_event_dispatcher.mojom
@@ -11,7 +11,7 @@ import "third_party/WebKit/public/platform/modules/background_sync/background_sync.mojom"; import "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom"; import "third_party/WebKit/public/platform/modules/payments/payment_app.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_event_status.mojom"; import "url/mojo/origin.mojom"; import "url/mojo/url.mojom";
diff --git a/content/common/service_worker/service_worker_fetch_response_callback.mojom b/content/common/service_worker/service_worker_fetch_response_callback.mojom index 288b545..dce8a79 100644 --- a/content/common/service_worker/service_worker_fetch_response_callback.mojom +++ b/content/common/service_worker/service_worker_fetch_response_callback.mojom
@@ -6,7 +6,7 @@ import "mojo/common/time.mojom"; import "third_party/WebKit/common/blob/blob.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_stream_handle.mojom"; [Native] struct ServiceWorkerResponse;
diff --git a/content/common/service_worker/service_worker_provider.mojom b/content/common/service_worker/service_worker_provider.mojom index 44df68c7..107fde0 100644 --- a/content/common/service_worker/service_worker_provider.mojom +++ b/content/common/service_worker/service_worker_provider.mojom
@@ -8,7 +8,7 @@ import "content/public/common/url_loader_factory.mojom"; import "services/service_manager/public/interfaces/interface_provider.mojom"; import "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_registration.mojom"; // The name of the InterfaceProviderSpec in service manifests used by the // frame tree to expose service-worker-specific interfaces between renderer
diff --git a/content/common/service_worker/service_worker_types.h b/content/common/service_worker/service_worker_types.h index 5a367035..974e285 100644 --- a/content/common/service_worker/service_worker_types.h +++ b/content/common/service_worker/service_worker_types.h
@@ -22,11 +22,11 @@ #include "services/network/public/interfaces/fetch_api.mojom.h" #include "third_party/WebKit/common/page/page_visibility_state.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_client.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_state.mojom.h" #include "third_party/WebKit/public/platform/modules/cache_storage/cache_storage.mojom.h" #include "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h" #include "url/gurl.h" // This file is to have common definitions that are to be shared by
diff --git a/content/common/service_worker/service_worker_utils.h b/content/common/service_worker/service_worker_utils.h index ec88d10..ee0e5e90f 100644 --- a/content/common/service_worker/service_worker_utils.h +++ b/content/common/service_worker/service_worker_utils.h
@@ -13,7 +13,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/resource_type.h" #include "content/public/common/service_worker_modes.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index d004236..c8e7f9f 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc
@@ -583,7 +583,13 @@ #endif bool ContentBrowserClient::AllowRenderingMhtmlOverHttp( - NavigationUIData* navigation_ui_data) const { + NavigationUIData* navigation_ui_data) { + return false; +} + +bool ContentBrowserClient::ShouldForceDownloadResource( + const GURL& url, + const std::string& mime_type) { return false; }
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index 79caf63..1f7cd3ac 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h
@@ -975,7 +975,12 @@ // Called on IO or UI thread to determine whether or not to allow load and // render MHTML page from http/https URLs. virtual bool AllowRenderingMhtmlOverHttp( - NavigationUIData* navigation_ui_data) const; + NavigationUIData* navigation_ui_data); + + // Called on IO or UI thread to determine whether or not to allow load and + // render MHTML page from http/https URLs. + virtual bool ShouldForceDownloadResource(const GURL& url, + const std::string& mime_type); }; } // namespace content
diff --git a/content/public/browser/resource_dispatcher_host_delegate.cc b/content/public/browser/resource_dispatcher_host_delegate.cc index fe0f8d87..d99af6d 100644 --- a/content/public/browser/resource_dispatcher_host_delegate.cc +++ b/content/public/browser/resource_dispatcher_host_delegate.cc
@@ -47,12 +47,6 @@ return true; } -bool ResourceDispatcherHostDelegate::ShouldForceDownloadResource( - const GURL& url, - const std::string& mime_type) { - return false; -} - bool ResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( net::URLRequest* request, const base::FilePath& plugin_path,
diff --git a/content/public/browser/resource_dispatcher_host_delegate.h b/content/public/browser/resource_dispatcher_host_delegate.h index ea004c5..a7d149d 100644 --- a/content/public/browser/resource_dispatcher_host_delegate.h +++ b/content/public/browser/resource_dispatcher_host_delegate.h
@@ -78,11 +78,6 @@ virtual bool HandleExternalProtocol(const GURL& url, ResourceRequestInfo* info); - // Returns true if we should force the given resource to be downloaded. - // Otherwise, the content layer decides. - virtual bool ShouldForceDownloadResource(const GURL& url, - const std::string& mime_type); - // Returns true and sets |origin| if a Stream should be created for the // resource. |plugin_path| is the plugin which will be used to handle the // request (if the stream will be rendered in a BrowserPlugin). It may be
diff --git a/content/public/browser/service_worker_context.h b/content/public/browser/service_worker_context.h index 7ba1cca..68db709 100644 --- a/content/public/browser/service_worker_context.h +++ b/content/public/browser/service_worker_context.h
@@ -11,7 +11,7 @@ #include "base/callback_forward.h" #include "content/public/browser/service_worker_usage_info.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "url/gurl.h" namespace content {
diff --git a/content/public/common/ssl_info.typemap b/content/public/common/ssl_info.typemap index e598fc72..99ecfd2 100644 --- a/content/public/common/ssl_info.typemap +++ b/content/public/common/ssl_info.typemap
@@ -4,9 +4,10 @@ mojom = "//content/public/common/url_loader.mojom" public_headers = [ "//net/ssl/ssl_info.h" ] -traits_headers = [ "//content/common/resource_messages.h" ] +traits_headers = [ "//services/network/public/cpp/ssl_info_ipc_traits.h" ] deps = [ "//content:export", - "//net:net", + "//net", + "//services/network/public/cpp", ] type_mappings = [ "content.mojom.SSLInfo=net::SSLInfo" ]
diff --git a/content/public/common/url_loader_completion_status.typemap b/content/public/common/url_loader_completion_status.typemap index 18b46bc5..bd756bb 100644 --- a/content/public/common/url_loader_completion_status.typemap +++ b/content/public/common/url_loader_completion_status.typemap
@@ -8,7 +8,7 @@ traits_headers = [ "//content/common/resource_messages.h" ] deps = [ "//content:export", - "//net:net", + "//net", "//services/network/public/cpp", "//third_party/WebKit/public:blink_headers", ]
diff --git a/content/renderer/media/android/stream_texture_factory.cc b/content/renderer/media/android/stream_texture_factory.cc index fd7d4c67..ec052f5 100644 --- a/content/renderer/media/android/stream_texture_factory.cc +++ b/content/renderer/media/android/stream_texture_factory.cc
@@ -95,11 +95,9 @@ StreamTextureFactory::~StreamTextureFactory() {} ScopedStreamTextureProxy StreamTextureFactory::CreateProxy( - unsigned texture_target, unsigned* texture_id, gpu::Mailbox* texture_mailbox) { - int32_t route_id = - CreateStreamTexture(texture_target, texture_id, texture_mailbox); + int32_t route_id = CreateStreamTexture(texture_id, texture_mailbox); if (!route_id) return ScopedStreamTextureProxy(); return ScopedStreamTextureProxy(new StreamTextureProxy( @@ -107,7 +105,6 @@ } unsigned StreamTextureFactory::CreateStreamTexture( - unsigned texture_target, unsigned* texture_id, gpu::Mailbox* texture_mailbox) { GLuint route_id = 0; @@ -124,8 +121,7 @@ *texture_mailbox = gpu::Mailbox(); } else { gl->GenMailboxCHROMIUM(texture_mailbox->name); - gl->ProduceTextureDirectCHROMIUM(*texture_id, texture_target, - texture_mailbox->name); + gl->ProduceTextureDirectCHROMIUM(*texture_id, texture_mailbox->name); } return route_id; }
diff --git a/content/renderer/media/android/stream_texture_factory.h b/content/renderer/media/android/stream_texture_factory.h index ef0c724..9585c03a 100644 --- a/content/renderer/media/android/stream_texture_factory.h +++ b/content/renderer/media/android/stream_texture_factory.h
@@ -100,8 +100,7 @@ // nullptr is returned and *texture_id will be set to 0. If the route_id is // valid it returns StreamTextureProxy object. The caller needs to take care // of cleaning up the texture_id. - ScopedStreamTextureProxy CreateProxy(unsigned texture_target, - unsigned* texture_id, + ScopedStreamTextureProxy CreateProxy(unsigned* texture_id, gpu::Mailbox* texture_mailbox); gpu::gles2::GLES2Interface* ContextGL(); @@ -114,8 +113,7 @@ // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the // client-side id of the gpu::StreamTexture. The texture is produced into // a mailbox so it can be shipped in a VideoFrame. - unsigned CreateStreamTexture(unsigned texture_target, - unsigned* texture_id, + unsigned CreateStreamTexture(unsigned* texture_id, gpu::Mailbox* texture_mailbox); scoped_refptr<ui::ContextProviderCommandBuffer> context_provider_;
diff --git a/content/renderer/media/android/stream_texture_wrapper_impl.cc b/content/renderer/media/android/stream_texture_wrapper_impl.cc index 0b81a19a..18f240e7 100644 --- a/content/renderer/media/android/stream_texture_wrapper_impl.cc +++ b/content/renderer/media/android/stream_texture_wrapper_impl.cc
@@ -12,8 +12,6 @@ using gpu::gles2::GLES2Interface; -static const uint32_t kGLTextureExternalOES = GL_TEXTURE_EXTERNAL_OES; - namespace { // Non-member function to allow it to run even after this class is deleted. void OnReleaseTexture(scoped_refptr<content::StreamTextureFactory> factories, @@ -71,9 +69,9 @@ DCHECK(main_task_runner_->BelongsToCurrentThread()); GLES2Interface* gl = factory_->ContextGL(); - GLuint texture_target = kGLTextureExternalOES; - GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( - texture_target, texture_mailbox_.name); + GLuint texture_target = GL_TEXTURE_EXTERNAL_OES; + GLuint texture_id_ref = + gl->CreateAndConsumeTextureCHROMIUM(texture_mailbox_.name); const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); gl->Flush(); @@ -164,8 +162,8 @@ DCHECK(main_task_runner_->BelongsToCurrentThread()); DVLOG(2) << __func__; - stream_texture_proxy_ = factory_->CreateProxy( - kGLTextureExternalOES, &texture_id_, &texture_mailbox_); + stream_texture_proxy_ = + factory_->CreateProxy(&texture_id_, &texture_mailbox_); if (!stream_texture_proxy_) { init_cb.Run(false); return;
diff --git a/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc b/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc index 27f2529..dfa9aa2 100644 --- a/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc +++ b/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc
@@ -218,8 +218,8 @@ 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); } gles2->GenMailboxCHROMIUM(texture_mailboxes->at(i).name); - gles2->ProduceTextureCHROMIUM(texture_target, - texture_mailboxes->at(i).name); + gles2->ProduceTextureDirectCHROMIUM(texture_id, + texture_mailboxes->at(i).name); } // We need ShallowFlushCHROMIUM() here to order the command buffer commands
diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index cfb923c..4167235 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc
@@ -712,7 +712,7 @@ } gl->GenMailboxCHROMIUM(gpu_mailbox.name); - gl->ProduceTextureCHROMIUM(texture_target, gpu_mailbox.name); + gl->ProduceTextureDirectCHROMIUM(texture_id, gpu_mailbox.name); } TextureInfo info;
diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc index 8efb305..ca8d89c 100644 --- a/content/renderer/pepper/video_decoder_shim.cc +++ b/content/renderer/pepper/video_decoder_shim.cc
@@ -946,7 +946,7 @@ for (uint32_t i = 0; i < num_textures; i++) { DCHECK_EQ(1u, buffers[i].client_texture_ids().size()); local_texture_ids[i] = gles2->CreateAndConsumeTextureCHROMIUM( - GL_TEXTURE_2D, pending_texture_mailboxes_[i].name); + pending_texture_mailboxes_[i].name); // Map the plugin texture id to the local texture id. uint32_t plugin_texture_id = buffers[i].client_texture_ids()[0]; texture_id_map_[plugin_texture_id] = local_texture_ids[i];
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index 31d16c0..0ac2c32b 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -61,6 +61,10 @@ #include "storage/common/blob_storage/blob_handle.h" #include "third_party/WebKit/common/blob/blob.mojom.h" #include "third_party/WebKit/common/blob/blob_registry.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/InterfaceProvider.h" #include "third_party/WebKit/public/platform/Platform.h" #include "third_party/WebKit/public/platform/URLConversion.h" @@ -78,10 +82,6 @@ #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h" #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextProxy.h"
diff --git a/content/renderer/service_worker/service_worker_context_client.h b/content/renderer/service_worker/service_worker_context_client.h index 07e243c..c31234a4 100644 --- a/content/renderer/service_worker/service_worker_context_client.h +++ b/content/renderer/service_worker/service_worker_context_client.h
@@ -29,11 +29,11 @@ #include "ipc/ipc_listener.h" #include "mojo/public/cpp/bindings/binding.h" #include "third_party/WebKit/common/blob/blob_registry.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/payments/payment_app.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h" #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextProxy.h" #include "v8/include/v8.h"
diff --git a/content/renderer/service_worker/service_worker_dispatcher.cc b/content/renderer/service_worker/service_worker_dispatcher.cc index 1da3370..d3432cd 100644 --- a/content/renderer/service_worker/service_worker_dispatcher.cc +++ b/content/renderer/service_worker/service_worker_dispatcher.cc
@@ -21,10 +21,10 @@ #include "content/renderer/service_worker/service_worker_handle_reference.h" #include "content/renderer/service_worker/service_worker_provider_context.h" #include "content/renderer/service_worker/web_service_worker_impl.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" #include "url/url_constants.h" using blink::WebServiceWorkerError;
diff --git a/content/renderer/service_worker/service_worker_dispatcher.h b/content/renderer/service_worker/service_worker_dispatcher.h index 1e03c84..11c7488 100644 --- a/content/renderer/service_worker/service_worker_dispatcher.h +++ b/content/renderer/service_worker/service_worker_dispatcher.h
@@ -20,12 +20,12 @@ #include "content/common/service_worker/service_worker_types.h" #include "content/public/renderer/worker_thread.h" #include "mojo/public/cpp/system/message_pipe.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_state.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h" namespace base { class SingleThreadTaskRunner;
diff --git a/content/renderer/service_worker/service_worker_dispatcher_unittest.cc b/content/renderer/service_worker/service_worker_dispatcher_unittest.cc index 918631cf..384b7ad8 100644 --- a/content/renderer/service_worker/service_worker_dispatcher_unittest.cc +++ b/content/renderer/service_worker/service_worker_dispatcher_unittest.cc
@@ -18,8 +18,8 @@ #include "ipc/ipc_test_sink.h" #include "mojo/public/cpp/bindings/associated_binding_set.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_handle_reference.cc b/content/renderer/service_worker/service_worker_handle_reference.cc index 5e4fd91..837ee20 100644 --- a/content/renderer/service_worker/service_worker_handle_reference.cc +++ b/content/renderer/service_worker/service_worker_handle_reference.cc
@@ -7,7 +7,7 @@ #include "base/memory/ptr_util.h" #include "content/child/thread_safe_sender.h" #include "content/common/service_worker/service_worker_messages.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_handle_reference.h b/content/renderer/service_worker/service_worker_handle_reference.h index 4d8e97db2..bc404e48 100644 --- a/content/renderer/service_worker/service_worker_handle_reference.h +++ b/content/renderer/service_worker/service_worker_handle_reference.h
@@ -13,7 +13,7 @@ #include "base/memory/ref_counted.h" #include "content/common/content_export.h" #include "content/common/service_worker/service_worker_types.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_network_provider.cc b/content/renderer/service_worker/service_worker_network_provider.cc index 0500acb..588ec2c 100644 --- a/content/renderer/service_worker/service_worker_network_provider.cc +++ b/content/renderer/service_worker/service_worker_network_provider.cc
@@ -20,9 +20,9 @@ #include "ipc/ipc_sync_channel.h" #include "mojo/public/cpp/bindings/associated_group.h" #include "third_party/WebKit/common/sandbox_flags.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_provider_context.cc b/content/renderer/service_worker/service_worker_provider_context.cc index 90f9474..97f08aa 100644 --- a/content/renderer/service_worker/service_worker_provider_context.cc +++ b/content/renderer/service_worker/service_worker_provider_context.cc
@@ -29,8 +29,8 @@ #include "mojo/public/cpp/bindings/strong_binding.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/interface_provider.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_provider_context.h b/content/renderer/service_worker/service_worker_provider_context.h index 843ac5f..75dd066 100644 --- a/content/renderer/service_worker/service_worker_provider_context.h +++ b/content/renderer/service_worker/service_worker_provider_context.h
@@ -17,10 +17,10 @@ #include "content/public/renderer/child_url_loader_factory_getter.h" #include "content/renderer/service_worker/web_service_worker_provider_impl.h" #include "mojo/public/cpp/bindings/associated_binding.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" namespace base { class SingleThreadTaskRunner;
diff --git a/content/renderer/service_worker/service_worker_provider_context_unittest.cc b/content/renderer/service_worker/service_worker_provider_context_unittest.cc index 5050aa4..6aad2ad 100644 --- a/content/renderer/service_worker/service_worker_provider_context_unittest.cc +++ b/content/renderer/service_worker/service_worker_provider_context_unittest.cc
@@ -22,10 +22,10 @@ #include "ipc/ipc_test_sink.h" #include "mojo/public/cpp/bindings/associated_binding_set.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/web_feature.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_subresource_loader.h b/content/renderer/service_worker/service_worker_subresource_loader.h index 6f52f4b..53c2357 100644 --- a/content/renderer/service_worker/service_worker_subresource_loader.h +++ b/content/renderer/service_worker/service_worker_subresource_loader.h
@@ -19,8 +19,8 @@ #include "net/url_request/redirect_info.h" #include "third_party/WebKit/common/blob/blob.mojom.h" #include "third_party/WebKit/common/blob/blob_registry.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_stream_handle.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/service_worker_type_converters.h b/content/renderer/service_worker/service_worker_type_converters.h index a40c51d..6bb7ec9 100644 --- a/content/renderer/service_worker/service_worker_type_converters.h +++ b/content/renderer/service_worker/service_worker_type_converters.h
@@ -7,10 +7,10 @@ #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" #include "content/common/service_worker/service_worker_status_code.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom.h" #include "third_party/WebKit/public/platform/modules/payments/WebCanMakePaymentEventData.h" #include "third_party/WebKit/public/platform/modules/payments/WebPaymentRequestEventData.h" #include "third_party/WebKit/public/platform/modules/payments/payment_app.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h" #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextProxy.h" namespace mojo {
diff --git a/content/renderer/service_worker/web_service_worker_impl.cc b/content/renderer/service_worker/web_service_worker_impl.cc index 9c53fe46a..0f7907b 100644 --- a/content/renderer/service_worker/web_service_worker_impl.cc +++ b/content/renderer/service_worker/web_service_worker_impl.cc
@@ -13,11 +13,11 @@ #include "content/renderer/service_worker/service_worker_dispatcher.h" #include "content/renderer/service_worker/service_worker_handle_reference.h" #include "content/renderer/service_worker/web_service_worker_provider_impl.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/platform/WebRuntimeFeatures.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProxy.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" using blink::WebSecurityOrigin; using blink::WebString;
diff --git a/content/renderer/service_worker/web_service_worker_provider_impl.cc b/content/renderer/service_worker/web_service_worker_provider_impl.cc index b405449..05549cc8 100644 --- a/content/renderer/service_worker/web_service_worker_provider_impl.cc +++ b/content/renderer/service_worker/web_service_worker_provider_impl.cc
@@ -18,9 +18,9 @@ #include "content/renderer/service_worker/web_service_worker_registration_impl.h" #include "third_party/WebKit/common/message_port/message_port_channel.h" #include "third_party/WebKit/common/service_worker/service_worker_provider_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/WebURL.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" using blink::WebURL;
diff --git a/content/renderer/service_worker/web_service_worker_provider_impl.h b/content/renderer/service_worker/web_service_worker_provider_impl.h index 1a087035..cb4ebb8 100644 --- a/content/renderer/service_worker/web_service_worker_provider_impl.h +++ b/content/renderer/service_worker/web_service_worker_provider_impl.h
@@ -12,9 +12,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "content/common/service_worker/service_worker_types.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/web_feature.mojom.h" namespace blink {
diff --git a/content/renderer/service_worker/web_service_worker_registration_impl.h b/content/renderer/service_worker/web_service_worker_registration_impl.h index 2388b1d..5d0732c 100644 --- a/content/renderer/service_worker/web_service_worker_registration_impl.h +++ b/content/renderer/service_worker/web_service_worker_registration_impl.h
@@ -16,9 +16,9 @@ #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" #include "mojo/public/cpp/bindings/associated_binding.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" namespace base { class SingleThreadTaskRunner;
diff --git a/content/renderer/service_worker/worker_fetch_context_impl.cc b/content/renderer/service_worker/worker_fetch_context_impl.cc index da8ec85..f73599d 100644 --- a/content/renderer/service_worker/worker_fetch_context_impl.cc +++ b/content/renderer/service_worker/worker_fetch_context_impl.cc
@@ -19,7 +19,7 @@ #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "services/service_manager/public/cpp/connector.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" namespace content {
diff --git a/content/renderer/service_worker/worker_fetch_context_impl.h b/content/renderer/service_worker/worker_fetch_context_impl.h index 1e981e6..2a9acc4 100644 --- a/content/renderer/service_worker/worker_fetch_context_impl.h +++ b/content/renderer/service_worker/worker_fetch_context_impl.h
@@ -13,9 +13,9 @@ #include "ipc/ipc_message.h" #include "mojo/public/cpp/bindings/binding.h" #include "third_party/WebKit/common/blob/blob_registry.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/platform/WebApplicationCacheHost.h" #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" #include "url/gurl.h" namespace base {
diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc index aaa0525..e18abff 100644 --- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc +++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc
@@ -28,11 +28,11 @@ #include "content/renderer/shared_worker/shared_worker_devtools_agent.h" #include "ipc/ipc_message_macros.h" #include "third_party/WebKit/common/message_port/message_port_channel.h" +#include "third_party/WebKit/common/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/platform/InterfaceProvider.h" #include "third_party/WebKit/public/platform/URLConversion.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom.h" #include "third_party/WebKit/public/web/WebSharedWorker.h" #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" #include "url/origin.h"
diff --git a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc index f0d4944..a15e671 100644 --- a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc +++ b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc
@@ -14,7 +14,7 @@ #include "content/shell/browser/layout_test/layout_test_browser_context.h" #include "content/shell/browser/layout_test/layout_test_content_browser_client.h" #include "content/shell/browser/layout_test/layout_test_permission_manager.h" -#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom.h" namespace content {
diff --git a/content/shell/test_runner/test_plugin.cc b/content/shell/test_runner/test_plugin.cc index d17a484..a19b7b1e 100644 --- a/content/shell/test_runner/test_plugin.cc +++ b/content/shell/test_runner/test_plugin.cc
@@ -263,7 +263,7 @@ DrawSceneGL(); gl_->GenMailboxCHROMIUM(mailbox_.name); - gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_.name); + gl_->ProduceTextureDirectCHROMIUM(color_texture_, mailbox_.name); const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); gl_->Flush();
diff --git a/content/test/test_background_sync_manager.cc b/content/test/test_background_sync_manager.cc index 8cd39c0..3cc040f 100644 --- a/content/test/test_background_sync_manager.cc +++ b/content/test/test_background_sync_manager.cc
@@ -36,16 +36,18 @@ const GURL& origin, const std::string& key, const std::string& data, - const ServiceWorkerStorage::StatusCallback& callback) { + ServiceWorkerStorage::StatusCallback callback) { EXPECT_FALSE(continuation_); if (corrupt_backend_) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(callback, SERVICE_WORKER_ERROR_FAILED)); + FROM_HERE, + base::BindOnce(std::move(callback), SERVICE_WORKER_ERROR_FAILED)); return; } - continuation_ = base::BindOnce( - &TestBackgroundSyncManager::StoreDataInBackendContinue, - base::Unretained(this), sw_registration_id, origin, key, data, callback); + continuation_ = + base::BindOnce(&TestBackgroundSyncManager::StoreDataInBackendContinue, + base::Unretained(this), sw_registration_id, origin, key, + data, std::move(callback)); if (delay_backend_) return; @@ -54,19 +56,19 @@ void TestBackgroundSyncManager::GetDataFromBackend( const std::string& key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback) { + ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback callback) { EXPECT_FALSE(continuation_); if (corrupt_backend_) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::BindOnce(callback, std::vector<std::pair<int64_t, std::string>>(), + base::BindOnce(std::move(callback), + std::vector<std::pair<int64_t, std::string>>(), SERVICE_WORKER_ERROR_FAILED)); return; } continuation_ = base::BindOnce(&TestBackgroundSyncManager::GetDataFromBackendContinue, - base::Unretained(this), key, callback); + base::Unretained(this), key, std::move(callback)); if (delay_backend_) return; @@ -100,16 +102,15 @@ const GURL& origin, const std::string& key, const std::string& data, - const ServiceWorkerStorage::StatusCallback& callback) { + ServiceWorkerStorage::StatusCallback callback) { BackgroundSyncManager::StoreDataInBackend(sw_registration_id, origin, key, - data, callback); + data, std::move(callback)); } void TestBackgroundSyncManager::GetDataFromBackendContinue( const std::string& key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback) { - BackgroundSyncManager::GetDataFromBackend(key, callback); + ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback callback) { + BackgroundSyncManager::GetDataFromBackend(key, std::move(callback)); } } // namespace content
diff --git a/content/test/test_background_sync_manager.h b/content/test/test_background_sync_manager.h index 295c8e6..7762cf8 100644 --- a/content/test/test_background_sync_manager.h +++ b/content/test/test_background_sync_manager.h
@@ -94,13 +94,13 @@ const GURL& origin, const std::string& key, const std::string& data, - const ServiceWorkerStorage::StatusCallback& callback) override; + ServiceWorkerStorage::StatusCallback callback) override; // Override to allow delays to be injected by tests. void GetDataFromBackend( const std::string& key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback) override; + ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback callback) + override; // Override to avoid actual dispatching of the event, just call the provided // callback instead. @@ -128,14 +128,13 @@ const GURL& origin, const std::string& key, const std::string& data, - const ServiceWorkerStorage::StatusCallback& callback); + ServiceWorkerStorage::StatusCallback callback); // Callback to resume the GetDataFromBackend operation, after explicit delays // injected by tests. void GetDataFromBackendContinue( const std::string& key, - const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& - callback); + ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback callback); bool corrupt_backend_ = false; bool delay_backend_ = false;
diff --git a/device/bluetooth/README.md b/device/bluetooth/README.md index a2f3b1a..02d51ce70 100644 --- a/device/bluetooth/README.md +++ b/device/bluetooth/README.md
@@ -35,13 +35,28 @@ * [chrome.bluetoothLowEnergy](https://developer.chrome.com/apps/bluetoothLowEnergy) * [chrome.bluetoothSocket](https://developer.chrome.com/apps/bluetoothSocket) -Active development in 2015 & 2016 is focused on enabling GATT features for: +Active development in 2015 & 2016 focused on enabling GATT features for: * [Web Bluetooth](https://crbug.com/419413) * Peripheral mode for Chrome OS. -Known future work is tracked in the -[Refactoring meta issue](https://crbug.com/580406). +## Future Work + +The API and implementation have many known issues. + +The initial API was heavily influenced by BlueZ. Low Energy GATT APIs are not +consistent across platforms. Some of the high level abstractions built into +`device/bluetooth` are difficult for clients. Several TODOs exist in the C++ +header files, e.g. `BluetoothAdapter::Observer`. + +Primarily, the API should be split into fundamental Bluetooth concepts and +seperate, optional, high level utility classes. + +E.g. receiving advertising packets should be routed directly to clients allowing +contents of the individual packet to be inspected. Caching of known devices +should not exist in the fundamental API, but be offered as utility classes. + +See also the [Refactoring meta issue](https://crbug.com/580406). ## Android
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt index 32604ac..1ee0b5e1 100644 --- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt +++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt
@@ -30,7 +30,7 @@ by the server, it only guarantees submission order. It does however guarantee operation order with respect to - CreateAndConsumeTextureCHROMIUM and ProduceTextureCHROMIUM from + CreateAndConsumeTextureCHROMIUM and ProduceTextureDirectCHROMIUM from CHROMIUM_texture_mailbox, if present. Issues
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt index 684f2f27..4de049cb 100644 --- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt +++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt
@@ -20,10 +20,10 @@ objects in different contexts where the contexts would not normally share texture resources. Five new functions are exported. glGenMailboxCHROMIUM generates a name that can be used to identify texture image data outside - the scope of a context group. glProduceTextureCHROMIUM and - glProduceTextureDirectCHROMIUM associate a texture object with a global - mailbox name. glConsumeMailboxCHROMIUM and glCreateAndConsumeTextureCHROMIUM - associate the texture object referenced by a mailbox name to a texture name. + the scope of a context group. glProduceTextureDirectCHROMIUM associates a + texture object with a global mailbox name. glCreateAndConsumeTextureCHROMIUM + associates the texture object referenced by a mailbox name to a texture + name. New Procedures and Functions @@ -36,73 +36,49 @@ <mailbox> returns a GL_MAILBOX_SIZE_CHROMIUM byte sized name + void glProduceTextureDirectCHROMIUM (GLuint texture, const GLbyte *mailbox) - void glProduceTextureCHROMIUM (GLenum target, const GLbyte *mailbox) - - Associates the currently bound texture object with the mailbox name. A - given texture object can be associated with several mailbox names. If a + Associates the specified texture object with the mailbox name. A given + texture object can be associated with several mailbox names. If a mailbox name was previously associated with a texture object, that - previous association is broken. The currently bound texture object is not - modified by the operation. + previous association is broken. - If glProduceTextureCHROMIUM generates an error, the mailbox name keeps its - current association, if any. + This operation does not change the texture bindings or alter the bound + texture in any way. If <texture> is 0 then any previous association of the + mailbox with a texture object is broken and no new association is created. - The mailbox does not keep a reference to the texture object. When the - texture object is destroyed (deleted from all context groups, and unbound - from all texture units and framebuffer attachments), the mailbox is - disassociated from the texture object. - - <target> uses the same parameters as TexImage2D. + <texture> Specifies the name of a texture. <mailbox> identifies a GL_MAILBOX_SIZE_CHROMIUM byte sized name returned by glGenMailboxCHROMIUM. - INVALID_OPERATION is generated if <target> is not a valid target. + INVALID_OPERATION is generated if <texture> is not a valid texture. INVALID_OPERATION is generated if <mailbox> is invalid. - void glProduceTextureDirectCHROMIUM (GLuint texture, GLenum target, - const GLbyte *mailbox) + GLuint glCreateAndConsumeTextureCHROMIUM (const GLbyte *mailbox) - Associates the specified texture object with the mailbox name. Performs - identically to glProduceTextureCHROMIUM except that the texture specified by - <texture> is used instead of the currently bound texture. This operation - does not change the texture bindings or alter the bound texture in any - way. If <texture> is 0 then any previous association of the mailbox with a - texture object is broken and no new association is created. + Returns a new texture name pointing to the texture object associated with + the mailbox name. Does not alter the texture bindings or alter the currently + bound texture in any way. All the contexts that have consumed the texture + object, as well as produced it share the texture object, as if the contexts + were part of the share group. The texture object is deleted once all + contexts have deleted the texture name associated with the texture object, + and detached it from all framebuffer objects as well as texture unit + bindings. See Appendix C of the OpenGL ES 2.0 specification for details + relative to visibility in one context of changes to the shared texture + object in another context. - <texture> Specifies the name of a texture. - - - GLuint glCreateAndConsumeTextureCHROMIUM (GLenum target, - const GLbyte *mailbox) - - Returns a new texture name associated with the given target pointing to the - texture object associated with the mailbox name. Does not alter the texture - bindings or alter the currently bound texture in any way. All the - contexts that have consumed the texture object, as well as produced it share - the texture object, as if the contexts were part of the share group. The - texture object is deleted once all contexts have deleted the texture name - associated with the texture object, and detached it from all framebuffer - objects as well as texture unit bindings. See Appendix C of the OpenGL ES - 2.0 specification for details relative to visibility in one context of - changes to the shared texture object in another context. - - If glCreateAndConsumeTextureCHROMIUM generates an error, the currently bound - texture object is preserved. - - INVALID_OPERATION is generated if <target> is not a valid target. + If glCreateAndConsumeTextureCHROMIUM generates an error, the new texture + name remains unbound. It is treated in the same way as a new texture name + returned by GenTextures. INVALID_OPERATION is generated if <mailbox> is invalid. INVALID_OPERATION is generated if <mailbox> is not associated with a texture object. - INVALID_OPERATION is generated if the texture object associated with - <mailbox> has a different target than <target>. - New Tokens The size of a mailbox name in bytes. @@ -131,3 +107,6 @@ 8/03/2016 Allow unbinding mailbox using glProduceTextureDirectCHROMIUM. 10/20/2017 Remove glConsumeTextureCHROMIUM and update glCreateAndConsumeTextureCHROMIUM definition. + 11/20/2017 Remove glProduceTextureCHROMIUM. Removed <target> arguments + from glProduceTextureDirectCHROMIUM and + glCreateAndConsumeTextureCHROMIUM, and updated definition.
diff --git a/gpu/GLES2/gl2chromium_autogen.h b/gpu/GLES2/gl2chromium_autogen.h index 6b2d4bf..8be62b5 100644 --- a/gpu/GLES2/gl2chromium_autogen.h +++ b/gpu/GLES2/gl2chromium_autogen.h
@@ -302,7 +302,6 @@ #define glDrawElementsInstancedANGLE GLES2_GET_FUN(DrawElementsInstancedANGLE) #define glVertexAttribDivisorANGLE GLES2_GET_FUN(VertexAttribDivisorANGLE) #define glGenMailboxCHROMIUM GLES2_GET_FUN(GenMailboxCHROMIUM) -#define glProduceTextureCHROMIUM GLES2_GET_FUN(ProduceTextureCHROMIUM) #define glProduceTextureDirectCHROMIUM \ GLES2_GET_FUN(ProduceTextureDirectCHROMIUM) #define glCreateAndConsumeTextureCHROMIUM \
diff --git a/gpu/GLES2/gl2extchromium.h b/gpu/GLES2/gl2extchromium.h index fa2d3a5..1ec6c20 100644 --- a/gpu/GLES2/gl2extchromium.h +++ b/gpu/GLES2/gl2extchromium.h
@@ -23,24 +23,16 @@ #endif #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGenMailboxCHROMIUM(GLbyte* mailbox); -GL_APICALL void GL_APIENTRY glProduceTextureCHROMIUM( - GLenum target, const GLbyte* mailbox); -GL_APICALL void GL_APIENTRY glProduceTextureDirectCHROMIUM( - GLuint texture, GLenum target, const GLbyte* mailbox); -GL_APICALL void GL_APIENTRY glConsumeTextureCHROMIUM( - GLenum target, const GLbyte* mailbox); -GL_APICALL GLuint GL_APIENTRY glCreateAndConsumeTextureCHROMIUM( - GLenum target, const GLbyte* mailbox); +GL_APICALL void GL_APIENTRY +glProduceTextureDirectCHROMIUM(GLuint texture, const GLbyte* mailbox); +GL_APICALL GLuint GL_APIENTRY +glCreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox); #endif typedef void (GL_APIENTRYP PFNGLGENMAILBOXCHROMIUMPROC) (GLbyte* mailbox); -typedef void (GL_APIENTRYP PFNGLPRODUCETEXTURECHROMIUMPROC) ( - GLenum target, const GLbyte* mailbox); typedef void (GL_APIENTRYP PFNGLPRODUCETEXTUREDIRECTCHROMIUMPROC) ( GLuint texture, GLenum target, const GLbyte* mailbox); -typedef void (GL_APIENTRYP PFNGLCONSUMETEXTURECHROMIUMPROC) ( - GLenum target, const GLbyte* mailbox); -typedef GLuint (GL_APIENTRYP PFNGLCREATEANDCONSUMETEXTURECHROMIUMPROC) ( - GLenum target, const GLbyte* mailbox); +typedef GLuint(GL_APIENTRYP PFNGLCREATEANDCONSUMETEXTURECHROMIUMPROC)( + const GLbyte* mailbox); #endif /* GL_CHROMIUM_texture_mailbox */ /* GL_CHROMIUM_pixel_transfer_buffer_object */
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index b3f0866..a5c7262a 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -3516,16 +3516,6 @@ 'client_test': False, 'extension': True, }, - 'ProduceTextureCHROMIUM': { - 'decoder_func': 'DoProduceTextureCHROMIUM', - 'impl_func': False, - 'type': 'PUT', - 'count': 16, # GL_MAILBOX_SIZE_CHROMIUM - 'unit_test': False, - 'client_test': False, - 'extension': "CHROMIUM_texture_mailbox", - 'trace_level': 1, - }, 'ProduceTextureDirectCHROMIUM': { 'decoder_func': 'DoProduceTextureDirectCHROMIUM', 'impl_func': False,
diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index e155246..6817e98 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h
@@ -1391,19 +1391,12 @@ void GL_APIENTRY GLES2GenMailboxCHROMIUM(GLbyte* mailbox) { gles2::GetGLContext()->GenMailboxCHROMIUM(mailbox); } -void GL_APIENTRY GLES2ProduceTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) { - gles2::GetGLContext()->ProduceTextureCHROMIUM(target, mailbox); -} void GL_APIENTRY GLES2ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) { - gles2::GetGLContext()->ProduceTextureDirectCHROMIUM(texture, target, mailbox); + gles2::GetGLContext()->ProduceTextureDirectCHROMIUM(texture, mailbox); } -GLuint GL_APIENTRY GLES2CreateAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) { - return gles2::GetGLContext()->CreateAndConsumeTextureCHROMIUM(target, - mailbox); +GLuint GL_APIENTRY GLES2CreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox) { + return gles2::GetGLContext()->CreateAndConsumeTextureCHROMIUM(mailbox); } void GL_APIENTRY GLES2BindUniformLocationCHROMIUM(GLuint program, GLint location, @@ -2871,10 +2864,6 @@ reinterpret_cast<GLES2FunctionPointer>(glGenMailboxCHROMIUM), }, { - "glProduceTextureCHROMIUM", - reinterpret_cast<GLES2FunctionPointer>(glProduceTextureCHROMIUM), - }, - { "glProduceTextureDirectCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(glProduceTextureDirectCHROMIUM), },
diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 1423350..0d18d30 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -2586,19 +2586,7 @@ } } -void ProduceTextureCHROMIUMImmediate(GLenum target, const GLbyte* mailbox) { - const uint32_t size = - gles2::cmds::ProduceTextureCHROMIUMImmediate::ComputeSize(); - gles2::cmds::ProduceTextureCHROMIUMImmediate* c = - GetImmediateCmdSpaceTotalSize< - gles2::cmds::ProduceTextureCHROMIUMImmediate>(size); - if (c) { - c->Init(target, mailbox); - } -} - void ProduceTextureDirectCHROMIUMImmediate(GLuint texture, - GLenum target, const GLbyte* mailbox) { const uint32_t size = gles2::cmds::ProduceTextureDirectCHROMIUMImmediate::ComputeSize(); @@ -2606,12 +2594,11 @@ GetImmediateCmdSpaceTotalSize< gles2::cmds::ProduceTextureDirectCHROMIUMImmediate>(size); if (c) { - c->Init(texture, target, mailbox); + c->Init(texture, mailbox); } } -void CreateAndConsumeTextureINTERNALImmediate(GLenum target, - GLuint texture, +void CreateAndConsumeTextureINTERNALImmediate(GLuint texture, const GLbyte* mailbox) { const uint32_t size = gles2::cmds::CreateAndConsumeTextureINTERNALImmediate::ComputeSize(); @@ -2619,7 +2606,7 @@ GetImmediateCmdSpaceTotalSize< gles2::cmds::CreateAndConsumeTextureINTERNALImmediate>(size); if (c) { - c->Init(target, texture, mailbox); + c->Init(texture, mailbox); } }
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index f3393f1..ce225c9d 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -5906,21 +5906,8 @@ memcpy(mailbox, result.name, sizeof(result.name)); } -void GLES2Implementation::ProduceTextureCHROMIUM(GLenum target, - const GLbyte* data) { - GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glProduceTextureCHROMIUM(" - << static_cast<const void*>(data) << ")"); - const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); - DCHECK(mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a " - "mailbox that was not generated by " - "GenMailboxCHROMIUM."; - helper_->ProduceTextureCHROMIUMImmediate(target, data); - CheckGLError(); -} - -void GLES2Implementation::ProduceTextureDirectCHROMIUM( - GLuint texture, GLenum target, const GLbyte* data) { +void GLES2Implementation::ProduceTextureDirectCHROMIUM(GLuint texture, + const GLbyte* data) { GPU_CLIENT_SINGLE_THREAD_CHECK(); GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glProduceTextureDirectCHROMIUM(" << static_cast<const void*>(data) << ")"); @@ -5928,12 +5915,12 @@ DCHECK(mailbox.Verify()) << "ProduceTextureDirectCHROMIUM was passed a " "mailbox that was not generated by " "GenMailboxCHROMIUM."; - helper_->ProduceTextureDirectCHROMIUMImmediate(texture, target, data); + helper_->ProduceTextureDirectCHROMIUMImmediate(texture, data); CheckGLError(); } GLuint GLES2Implementation::CreateAndConsumeTextureCHROMIUM( - GLenum target, const GLbyte* data) { + const GLbyte* data) { GPU_CLIENT_SINGLE_THREAD_CHECK(); GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateAndConsumeTextureCHROMIUM(" << static_cast<const void*>(data) << ")"); @@ -5943,8 +5930,7 @@ "GenMailboxCHROMIUM."; GLuint client_id; GetIdHandler(SharedIdNamespaces::kTextures)->MakeIds(this, 0, 1, &client_id); - helper_->CreateAndConsumeTextureINTERNALImmediate(target, - client_id, data); + helper_->CreateAndConsumeTextureINTERNALImmediate(client_id, data); if (share_group_->bind_generates_resource()) helper_->CommandBufferHelper::Flush(); CheckGLError();
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index b5d99a0..db45ca6 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -980,14 +980,10 @@ void GenMailboxCHROMIUM(GLbyte* mailbox) override; -void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override; - void ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) override; -GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) override; +GLuint CreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox) override; void BindUniformLocationCHROMIUM(GLuint program, GLint location,
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index 1aaa2437..b2d17463 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -3725,25 +3725,12 @@ Mailbox mailbox = Mailbox::Generate(); Cmds expected; - expected.cmd.Init(GL_TEXTURE_2D, kTexturesStartId, mailbox.name); - GLuint id = gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + expected.cmd.Init(kTexturesStartId, mailbox.name); + GLuint id = gl_->CreateAndConsumeTextureCHROMIUM(mailbox.name); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); EXPECT_EQ(kTexturesStartId, id); } -TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) { - struct Cmds { - cmds::ProduceTextureCHROMIUMImmediate cmd; - GLbyte data[GL_MAILBOX_SIZE_CHROMIUM]; - }; - - Mailbox mailbox = Mailbox::Generate(); - Cmds expected; - expected.cmd.Init(GL_TEXTURE_2D, mailbox.name); - gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); - EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); -} - TEST_F(GLES2ImplementationTest, ProduceTextureDirectCHROMIUM) { struct Cmds { cmds::ProduceTextureDirectCHROMIUMImmediate cmd; @@ -3752,9 +3739,8 @@ Mailbox mailbox = Mailbox::Generate(); Cmds expected; - expected.cmd.Init(kTexturesStartId, GL_TEXTURE_2D, mailbox.name); - gl_->ProduceTextureDirectCHROMIUM( - kTexturesStartId, GL_TEXTURE_2D, mailbox.name); + expected.cmd.Init(kTexturesStartId, mailbox.name); + gl_->ProduceTextureDirectCHROMIUM(kTexturesStartId, mailbox.name); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); }
diff --git a/gpu/command_buffer/client/gles2_interface_autogen.h b/gpu/command_buffer/client/gles2_interface_autogen.h index c332e63a..dac39f1 100644 --- a/gpu/command_buffer/client/gles2_interface_autogen.h +++ b/gpu/command_buffer/client/gles2_interface_autogen.h
@@ -722,12 +722,9 @@ GLsizei primcount) = 0; virtual void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) = 0; virtual void GenMailboxCHROMIUM(GLbyte* mailbox) = 0; -virtual void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) = 0; virtual void ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) = 0; -virtual GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) = 0; +virtual GLuint CreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox) = 0; virtual void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) = 0;
diff --git a/gpu/command_buffer/client/gles2_interface_stub_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_autogen.h index 0d59364..2ae67be9 100644 --- a/gpu/command_buffer/client/gles2_interface_stub_autogen.h +++ b/gpu/command_buffer/client/gles2_interface_stub_autogen.h
@@ -700,12 +700,9 @@ GLsizei primcount) override; void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) override; void GenMailboxCHROMIUM(GLbyte* mailbox) override; -void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override; void ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) override; -GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) override; +GLuint CreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox) override; void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) override;
diff --git a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h index 1214bc2..da07284 100644 --- a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h +++ b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
@@ -948,14 +948,10 @@ void GLES2InterfaceStub::VertexAttribDivisorANGLE(GLuint /* index */, GLuint /* divisor */) {} void GLES2InterfaceStub::GenMailboxCHROMIUM(GLbyte* /* mailbox */) {} -void GLES2InterfaceStub::ProduceTextureCHROMIUM(GLenum /* target */, - const GLbyte* /* mailbox */) {} void GLES2InterfaceStub::ProduceTextureDirectCHROMIUM( GLuint /* texture */, - GLenum /* target */, const GLbyte* /* mailbox */) {} GLuint GLES2InterfaceStub::CreateAndConsumeTextureCHROMIUM( - GLenum /* target */, const GLbyte* /* mailbox */) { return 0; }
diff --git a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h index f0ef8bd..bbcdec7 100644 --- a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
@@ -700,12 +700,9 @@ GLsizei primcount) override; void VertexAttribDivisorANGLE(GLuint index, GLuint divisor) override; void GenMailboxCHROMIUM(GLbyte* mailbox) override; -void ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override; void ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) override; -GLuint CreateAndConsumeTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) override; +GLuint CreateAndConsumeTextureCHROMIUM(const GLbyte* mailbox) override; void BindUniformLocationCHROMIUM(GLuint program, GLint location, const char* name) override;
diff --git a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h index 32730225..7573f41f 100644 --- a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h +++ b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
@@ -2012,27 +2012,19 @@ gl_->GenMailboxCHROMIUM(mailbox); } -void GLES2TraceImplementation::ProduceTextureCHROMIUM(GLenum target, - const GLbyte* mailbox) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::ProduceTextureCHROMIUM"); - gl_->ProduceTextureCHROMIUM(target, mailbox); -} - void GLES2TraceImplementation::ProduceTextureDirectCHROMIUM( GLuint texture, - GLenum target, const GLbyte* mailbox) { TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::ProduceTextureDirectCHROMIUM"); - gl_->ProduceTextureDirectCHROMIUM(texture, target, mailbox); + gl_->ProduceTextureDirectCHROMIUM(texture, mailbox); } GLuint GLES2TraceImplementation::CreateAndConsumeTextureCHROMIUM( - GLenum target, const GLbyte* mailbox) { TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::CreateAndConsumeTextureCHROMIUM"); - return gl_->CreateAndConsumeTextureCHROMIUM(target, mailbox); + return gl_->CreateAndConsumeTextureCHROMIUM(mailbox); } void GLES2TraceImplementation::BindUniformLocationCHROMIUM(GLuint program,
diff --git a/gpu/command_buffer/cmd_buffer_functions.txt b/gpu/command_buffer/cmd_buffer_functions.txt index 255dad7c..0335720 100644 --- a/gpu/command_buffer/cmd_buffer_functions.txt +++ b/gpu/command_buffer/cmd_buffer_functions.txt
@@ -286,10 +286,9 @@ GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenumDrawMode mode, GLsizei count, GLenumIndexType type, const void* indices, GLsizei primcount); GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); GL_APICALL void GL_APIENTRY glGenMailboxCHROMIUM (GLbyte* mailbox); -GL_APICALL void GL_APIENTRY glProduceTextureCHROMIUM (GLenumTextureBindTarget target, const GLbyte* mailbox); -GL_APICALL void GL_APIENTRY glProduceTextureDirectCHROMIUM (GLidBindTexture texture, GLenumTextureBindTarget target, const GLbyte* mailbox); -GL_APICALL GLuint GL_APIENTRY glCreateAndConsumeTextureCHROMIUM (GLenumTextureBindTarget target, const GLbyte* mailbox); -GL_APICALL void GL_APIENTRY glCreateAndConsumeTextureINTERNAL (GLenumTextureBindTarget target, GLuint texture, const GLbyte* mailbox); +GL_APICALL void GL_APIENTRY glProduceTextureDirectCHROMIUM (GLidBindTexture texture, const GLbyte* mailbox); +GL_APICALL GLuint GL_APIENTRY glCreateAndConsumeTextureCHROMIUM (const GLbyte* mailbox); +GL_APICALL void GL_APIENTRY glCreateAndConsumeTextureINTERNAL (GLuint texture, const GLbyte* mailbox); GL_APICALL void GL_APIENTRY glBindUniformLocationCHROMIUM (GLidProgram program, GLint location, const char* name); GL_APICALL void GL_APIENTRY glBindTexImage2DCHROMIUM (GLenumTextureBindTarget target, GLint imageId); GL_APICALL void GL_APIENTRY glBindTexImage2DWithInternalformatCHROMIUM (GLenumTextureBindTarget target, GLenumTextureInternalFormat internalformat, GLint imageId);
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 46de934..ebf80cd 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -12832,45 +12832,6 @@ static_assert(offsetof(VertexAttribDivisorANGLE, divisor) == 8, "offset of VertexAttribDivisorANGLE divisor should be 8"); -struct ProduceTextureCHROMIUMImmediate { - typedef ProduceTextureCHROMIUMImmediate ValueType; - static const CommandId kCmdId = kProduceTextureCHROMIUMImmediate; - static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; - static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(1); - - static uint32_t ComputeDataSize() { - return static_cast<uint32_t>(sizeof(GLbyte) * 16); - } - - static uint32_t ComputeSize() { - return static_cast<uint32_t>(sizeof(ValueType) + ComputeDataSize()); - } - - void SetHeader() { header.SetCmdByTotalSize<ValueType>(ComputeSize()); } - - void Init(GLenum _target, const GLbyte* _mailbox) { - SetHeader(); - target = _target; - memcpy(ImmediateDataAddress(this), _mailbox, ComputeDataSize()); - } - - void* Set(void* cmd, GLenum _target, const GLbyte* _mailbox) { - static_cast<ValueType*>(cmd)->Init(_target, _mailbox); - const uint32_t size = ComputeSize(); - return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); - } - - gpu::CommandHeader header; - uint32_t target; -}; - -static_assert(sizeof(ProduceTextureCHROMIUMImmediate) == 8, - "size of ProduceTextureCHROMIUMImmediate should be 8"); -static_assert(offsetof(ProduceTextureCHROMIUMImmediate, header) == 0, - "offset of ProduceTextureCHROMIUMImmediate header should be 0"); -static_assert(offsetof(ProduceTextureCHROMIUMImmediate, target) == 4, - "offset of ProduceTextureCHROMIUMImmediate target should be 4"); - struct ProduceTextureDirectCHROMIUMImmediate { typedef ProduceTextureDirectCHROMIUMImmediate ValueType; static const CommandId kCmdId = kProduceTextureDirectCHROMIUMImmediate; @@ -12887,38 +12848,30 @@ void SetHeader() { header.SetCmdByTotalSize<ValueType>(ComputeSize()); } - void Init(GLuint _texture, GLenum _target, const GLbyte* _mailbox) { + void Init(GLuint _texture, const GLbyte* _mailbox) { SetHeader(); texture = _texture; - target = _target; memcpy(ImmediateDataAddress(this), _mailbox, ComputeDataSize()); } - void* Set(void* cmd, - GLuint _texture, - GLenum _target, - const GLbyte* _mailbox) { - static_cast<ValueType*>(cmd)->Init(_texture, _target, _mailbox); + void* Set(void* cmd, GLuint _texture, const GLbyte* _mailbox) { + static_cast<ValueType*>(cmd)->Init(_texture, _mailbox); const uint32_t size = ComputeSize(); return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } gpu::CommandHeader header; uint32_t texture; - uint32_t target; }; -static_assert(sizeof(ProduceTextureDirectCHROMIUMImmediate) == 12, - "size of ProduceTextureDirectCHROMIUMImmediate should be 12"); +static_assert(sizeof(ProduceTextureDirectCHROMIUMImmediate) == 8, + "size of ProduceTextureDirectCHROMIUMImmediate should be 8"); static_assert( offsetof(ProduceTextureDirectCHROMIUMImmediate, header) == 0, "offset of ProduceTextureDirectCHROMIUMImmediate header should be 0"); static_assert( offsetof(ProduceTextureDirectCHROMIUMImmediate, texture) == 4, "offset of ProduceTextureDirectCHROMIUMImmediate texture should be 4"); -static_assert( - offsetof(ProduceTextureDirectCHROMIUMImmediate, target) == 8, - "offset of ProduceTextureDirectCHROMIUMImmediate target should be 8"); struct CreateAndConsumeTextureINTERNALImmediate { typedef CreateAndConsumeTextureINTERNALImmediate ValueType; @@ -12936,38 +12889,30 @@ void SetHeader() { header.SetCmdByTotalSize<ValueType>(ComputeSize()); } - void Init(GLenum _target, GLuint _texture, const GLbyte* _mailbox) { + void Init(GLuint _texture, const GLbyte* _mailbox) { SetHeader(); - target = _target; texture = _texture; memcpy(ImmediateDataAddress(this), _mailbox, ComputeDataSize()); } - void* Set(void* cmd, - GLenum _target, - GLuint _texture, - const GLbyte* _mailbox) { - static_cast<ValueType*>(cmd)->Init(_target, _texture, _mailbox); + void* Set(void* cmd, GLuint _texture, const GLbyte* _mailbox) { + static_cast<ValueType*>(cmd)->Init(_texture, _mailbox); const uint32_t size = ComputeSize(); return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } gpu::CommandHeader header; - uint32_t target; uint32_t texture; }; -static_assert(sizeof(CreateAndConsumeTextureINTERNALImmediate) == 12, - "size of CreateAndConsumeTextureINTERNALImmediate should be 12"); +static_assert(sizeof(CreateAndConsumeTextureINTERNALImmediate) == 8, + "size of CreateAndConsumeTextureINTERNALImmediate should be 8"); static_assert( offsetof(CreateAndConsumeTextureINTERNALImmediate, header) == 0, "offset of CreateAndConsumeTextureINTERNALImmediate header should be 0"); static_assert( - offsetof(CreateAndConsumeTextureINTERNALImmediate, target) == 4, - "offset of CreateAndConsumeTextureINTERNALImmediate target should be 4"); -static_assert( - offsetof(CreateAndConsumeTextureINTERNALImmediate, texture) == 8, - "offset of CreateAndConsumeTextureINTERNALImmediate texture should be 8"); + offsetof(CreateAndConsumeTextureINTERNALImmediate, texture) == 4, + "offset of CreateAndConsumeTextureINTERNALImmediate texture should be 4"); struct BindUniformLocationCHROMIUMBucket { typedef BindUniformLocationCHROMIUMBucket ValueType;
diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index 491e549d..de02084 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -4271,39 +4271,6 @@ CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd)); } -TEST_F(GLES2FormatTest, ProduceTextureCHROMIUMImmediate) { - const int kSomeBaseValueToTestWith = 51; - static GLbyte data[] = { - static_cast<GLbyte>(kSomeBaseValueToTestWith + 0), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 1), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 2), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 3), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 4), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 5), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 6), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 7), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 8), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 9), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 10), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 11), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 12), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 13), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 14), - static_cast<GLbyte>(kSomeBaseValueToTestWith + 15), - }; - cmds::ProduceTextureCHROMIUMImmediate& cmd = - *GetBufferAs<cmds::ProduceTextureCHROMIUMImmediate>(); - void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11), data); - EXPECT_EQ( - static_cast<uint32_t>(cmds::ProduceTextureCHROMIUMImmediate::kCmdId), - cmd.header.command); - EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); - EXPECT_EQ(static_cast<GLenum>(11), cmd.target); - CheckBytesWrittenMatchesExpectedSize( - next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); -} - TEST_F(GLES2FormatTest, ProduceTextureDirectCHROMIUMImmediate) { const int kSomeBaseValueToTestWith = 51; static GLbyte data[] = { @@ -4326,15 +4293,13 @@ }; cmds::ProduceTextureDirectCHROMIUMImmediate& cmd = *GetBufferAs<cmds::ProduceTextureDirectCHROMIUMImmediate>(); - void* next_cmd = - cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLenum>(12), data); + void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11), data); EXPECT_EQ(static_cast<uint32_t>( cmds::ProduceTextureDirectCHROMIUMImmediate::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), cmd.header.size * 4u); EXPECT_EQ(static_cast<GLuint>(11), cmd.texture); - EXPECT_EQ(static_cast<GLenum>(12), cmd.target); CheckBytesWrittenMatchesExpectedSize( next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); } @@ -4361,15 +4326,13 @@ }; cmds::CreateAndConsumeTextureINTERNALImmediate& cmd = *GetBufferAs<cmds::CreateAndConsumeTextureINTERNALImmediate>(); - void* next_cmd = - cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12), data); + void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11), data); EXPECT_EQ(static_cast<uint32_t>( cmds::CreateAndConsumeTextureINTERNALImmediate::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), cmd.header.size * 4u); - EXPECT_EQ(static_cast<GLenum>(11), cmd.target); - EXPECT_EQ(static_cast<GLuint>(12), cmd.texture); + EXPECT_EQ(static_cast<GLuint>(11), cmd.texture); CheckBytesWrittenMatchesExpectedSize( next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); }
diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index c9cc3ac..6281a7e 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -275,77 +275,76 @@ OP(DrawArraysInstancedANGLE) /* 516 */ \ OP(DrawElementsInstancedANGLE) /* 517 */ \ OP(VertexAttribDivisorANGLE) /* 518 */ \ - OP(ProduceTextureCHROMIUMImmediate) /* 519 */ \ - OP(ProduceTextureDirectCHROMIUMImmediate) /* 520 */ \ - OP(CreateAndConsumeTextureINTERNALImmediate) /* 521 */ \ - OP(BindUniformLocationCHROMIUMBucket) /* 522 */ \ - OP(BindTexImage2DCHROMIUM) /* 523 */ \ - OP(BindTexImage2DWithInternalformatCHROMIUM) /* 524 */ \ - OP(ReleaseTexImage2DCHROMIUM) /* 525 */ \ - OP(TraceBeginCHROMIUM) /* 526 */ \ - OP(TraceEndCHROMIUM) /* 527 */ \ - OP(DiscardFramebufferEXTImmediate) /* 528 */ \ - OP(LoseContextCHROMIUM) /* 529 */ \ - OP(InsertFenceSyncCHROMIUM) /* 530 */ \ - OP(WaitSyncTokenCHROMIUM) /* 531 */ \ - OP(DrawBuffersEXTImmediate) /* 532 */ \ - OP(DiscardBackbufferCHROMIUM) /* 533 */ \ - OP(ScheduleOverlayPlaneCHROMIUM) /* 534 */ \ - OP(ScheduleCALayerSharedStateCHROMIUM) /* 535 */ \ - OP(ScheduleCALayerCHROMIUM) /* 536 */ \ - OP(ScheduleCALayerInUseQueryCHROMIUMImmediate) /* 537 */ \ - OP(CommitOverlayPlanesCHROMIUM) /* 538 */ \ - OP(SwapInterval) /* 539 */ \ - OP(FlushDriverCachesCHROMIUM) /* 540 */ \ - OP(ScheduleDCLayerSharedStateCHROMIUM) /* 541 */ \ - OP(ScheduleDCLayerCHROMIUM) /* 542 */ \ - OP(MatrixLoadfCHROMIUMImmediate) /* 543 */ \ - OP(MatrixLoadIdentityCHROMIUM) /* 544 */ \ - OP(GenPathsCHROMIUM) /* 545 */ \ - OP(DeletePathsCHROMIUM) /* 546 */ \ - OP(IsPathCHROMIUM) /* 547 */ \ - OP(PathCommandsCHROMIUM) /* 548 */ \ - OP(PathParameterfCHROMIUM) /* 549 */ \ - OP(PathParameteriCHROMIUM) /* 550 */ \ - OP(PathStencilFuncCHROMIUM) /* 551 */ \ - OP(StencilFillPathCHROMIUM) /* 552 */ \ - OP(StencilStrokePathCHROMIUM) /* 553 */ \ - OP(CoverFillPathCHROMIUM) /* 554 */ \ - OP(CoverStrokePathCHROMIUM) /* 555 */ \ - OP(StencilThenCoverFillPathCHROMIUM) /* 556 */ \ - OP(StencilThenCoverStrokePathCHROMIUM) /* 557 */ \ - OP(StencilFillPathInstancedCHROMIUM) /* 558 */ \ - OP(StencilStrokePathInstancedCHROMIUM) /* 559 */ \ - OP(CoverFillPathInstancedCHROMIUM) /* 560 */ \ - OP(CoverStrokePathInstancedCHROMIUM) /* 561 */ \ - OP(StencilThenCoverFillPathInstancedCHROMIUM) /* 562 */ \ - OP(StencilThenCoverStrokePathInstancedCHROMIUM) /* 563 */ \ - OP(BindFragmentInputLocationCHROMIUMBucket) /* 564 */ \ - OP(ProgramPathFragmentInputGenCHROMIUM) /* 565 */ \ - OP(GetBufferSubDataAsyncCHROMIUM) /* 566 */ \ - OP(CoverageModulationCHROMIUM) /* 567 */ \ - OP(BlendBarrierKHR) /* 568 */ \ - OP(ApplyScreenSpaceAntialiasingCHROMIUM) /* 569 */ \ - OP(BindFragDataLocationIndexedEXTBucket) /* 570 */ \ - OP(BindFragDataLocationEXTBucket) /* 571 */ \ - OP(GetFragDataIndexEXT) /* 572 */ \ - OP(UniformMatrix4fvStreamTextureMatrixCHROMIUMImmediate) /* 573 */ \ - OP(OverlayPromotionHintCHROMIUM) /* 574 */ \ - OP(SwapBuffersWithBoundsCHROMIUMImmediate) /* 575 */ \ - OP(SetDrawRectangleCHROMIUM) /* 576 */ \ - OP(SetEnableDCLayersCHROMIUM) /* 577 */ \ - OP(InitializeDiscardableTextureCHROMIUM) /* 578 */ \ - OP(UnlockDiscardableTextureCHROMIUM) /* 579 */ \ - OP(LockDiscardableTextureCHROMIUM) /* 580 */ \ - OP(BeginRasterCHROMIUM) /* 581 */ \ - OP(RasterCHROMIUM) /* 582 */ \ - OP(EndRasterCHROMIUM) /* 583 */ \ - OP(CreateTransferCacheEntryCHROMIUM) /* 584 */ \ - OP(DeleteTransferCacheEntryCHROMIUM) /* 585 */ \ - OP(UnlockTransferCacheEntryCHROMIUM) /* 586 */ \ - OP(TexStorage2DImageCHROMIUM) /* 587 */ \ - OP(SetColorSpaceMetadataCHROMIUM) /* 588 */ \ - OP(WindowRectanglesEXTImmediate) /* 589 */ + OP(ProduceTextureDirectCHROMIUMImmediate) /* 519 */ \ + OP(CreateAndConsumeTextureINTERNALImmediate) /* 520 */ \ + OP(BindUniformLocationCHROMIUMBucket) /* 521 */ \ + OP(BindTexImage2DCHROMIUM) /* 522 */ \ + OP(BindTexImage2DWithInternalformatCHROMIUM) /* 523 */ \ + OP(ReleaseTexImage2DCHROMIUM) /* 524 */ \ + OP(TraceBeginCHROMIUM) /* 525 */ \ + OP(TraceEndCHROMIUM) /* 526 */ \ + OP(DiscardFramebufferEXTImmediate) /* 527 */ \ + OP(LoseContextCHROMIUM) /* 528 */ \ + OP(InsertFenceSyncCHROMIUM) /* 529 */ \ + OP(WaitSyncTokenCHROMIUM) /* 530 */ \ + OP(DrawBuffersEXTImmediate) /* 531 */ \ + OP(DiscardBackbufferCHROMIUM) /* 532 */ \ + OP(ScheduleOverlayPlaneCHROMIUM) /* 533 */ \ + OP(ScheduleCALayerSharedStateCHROMIUM) /* 534 */ \ + OP(ScheduleCALayerCHROMIUM) /* 535 */ \ + OP(ScheduleCALayerInUseQueryCHROMIUMImmediate) /* 536 */ \ + OP(CommitOverlayPlanesCHROMIUM) /* 537 */ \ + OP(SwapInterval) /* 538 */ \ + OP(FlushDriverCachesCHROMIUM) /* 539 */ \ + OP(ScheduleDCLayerSharedStateCHROMIUM) /* 540 */ \ + OP(ScheduleDCLayerCHROMIUM) /* 541 */ \ + OP(MatrixLoadfCHROMIUMImmediate) /* 542 */ \ + OP(MatrixLoadIdentityCHROMIUM) /* 543 */ \ + OP(GenPathsCHROMIUM) /* 544 */ \ + OP(DeletePathsCHROMIUM) /* 545 */ \ + OP(IsPathCHROMIUM) /* 546 */ \ + OP(PathCommandsCHROMIUM) /* 547 */ \ + OP(PathParameterfCHROMIUM) /* 548 */ \ + OP(PathParameteriCHROMIUM) /* 549 */ \ + OP(PathStencilFuncCHROMIUM) /* 550 */ \ + OP(StencilFillPathCHROMIUM) /* 551 */ \ + OP(StencilStrokePathCHROMIUM) /* 552 */ \ + OP(CoverFillPathCHROMIUM) /* 553 */ \ + OP(CoverStrokePathCHROMIUM) /* 554 */ \ + OP(StencilThenCoverFillPathCHROMIUM) /* 555 */ \ + OP(StencilThenCoverStrokePathCHROMIUM) /* 556 */ \ + OP(StencilFillPathInstancedCHROMIUM) /* 557 */ \ + OP(StencilStrokePathInstancedCHROMIUM) /* 558 */ \ + OP(CoverFillPathInstancedCHROMIUM) /* 559 */ \ + OP(CoverStrokePathInstancedCHROMIUM) /* 560 */ \ + OP(StencilThenCoverFillPathInstancedCHROMIUM) /* 561 */ \ + OP(StencilThenCoverStrokePathInstancedCHROMIUM) /* 562 */ \ + OP(BindFragmentInputLocationCHROMIUMBucket) /* 563 */ \ + OP(ProgramPathFragmentInputGenCHROMIUM) /* 564 */ \ + OP(GetBufferSubDataAsyncCHROMIUM) /* 565 */ \ + OP(CoverageModulationCHROMIUM) /* 566 */ \ + OP(BlendBarrierKHR) /* 567 */ \ + OP(ApplyScreenSpaceAntialiasingCHROMIUM) /* 568 */ \ + OP(BindFragDataLocationIndexedEXTBucket) /* 569 */ \ + OP(BindFragDataLocationEXTBucket) /* 570 */ \ + OP(GetFragDataIndexEXT) /* 571 */ \ + OP(UniformMatrix4fvStreamTextureMatrixCHROMIUMImmediate) /* 572 */ \ + OP(OverlayPromotionHintCHROMIUM) /* 573 */ \ + OP(SwapBuffersWithBoundsCHROMIUMImmediate) /* 574 */ \ + OP(SetDrawRectangleCHROMIUM) /* 575 */ \ + OP(SetEnableDCLayersCHROMIUM) /* 576 */ \ + OP(InitializeDiscardableTextureCHROMIUM) /* 577 */ \ + OP(UnlockDiscardableTextureCHROMIUM) /* 578 */ \ + OP(LockDiscardableTextureCHROMIUM) /* 579 */ \ + OP(BeginRasterCHROMIUM) /* 580 */ \ + OP(RasterCHROMIUM) /* 581 */ \ + OP(EndRasterCHROMIUM) /* 582 */ \ + OP(CreateTransferCacheEntryCHROMIUM) /* 583 */ \ + OP(DeleteTransferCacheEntryCHROMIUM) /* 584 */ \ + OP(UnlockTransferCacheEntryCHROMIUM) /* 585 */ \ + OP(TexStorage2DImageCHROMIUM) /* 586 */ \ + OP(SetColorSpaceMetadataCHROMIUM) /* 587 */ \ + OP(WindowRectanglesEXTImmediate) /* 588 */ enum CommandId { kOneBeforeStartPoint =
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index ace7b43..1d2f930 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1045,19 +1045,15 @@ GLsizei width, GLsizei height); - void DoProduceTextureCHROMIUM(GLenum target, const volatile GLbyte* key); void DoProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const volatile GLbyte* key); void ProduceTextureRef(const char* func_name, bool clear, TextureRef* texture_ref, - GLenum target, const volatile GLbyte* data); void EnsureTextureForClientId(GLenum target, GLuint client_id); - void DoCreateAndConsumeTextureINTERNAL(GLenum target, - GLuint client_id, + void DoCreateAndConsumeTextureINTERNAL(GLuint client_id, const volatile GLbyte* key); void DoApplyScreenSpaceAntialiasingCHROMIUM(); @@ -18064,34 +18060,20 @@ framebuffer_state_.clear_state_dirty = true; } -void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, - const volatile GLbyte* data) { - TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", - "context", logger_.GetLogPrefix(), - "mailbox[0]", static_cast<unsigned char>(data[0])); - - TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( - &state_, target); - ProduceTextureRef("glProduceTextureCHROMIUM", false, texture_ref, target, - data); -} - void GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM( GLuint client_id, - GLenum target, const volatile GLbyte* data) { TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM", "context", logger_.GetLogPrefix(), "mailbox[0]", static_cast<unsigned char>(data[0])); ProduceTextureRef("glProduceTextureDirectCHROMIUM", !client_id, - GetTexture(client_id), target, data); + GetTexture(client_id), data); } void GLES2DecoderImpl::ProduceTextureRef(const char* func_name, bool clear, TextureRef* texture_ref, - GLenum target, const volatile GLbyte* data) { Mailbox mailbox = Mailbox::FromVolatile(*reinterpret_cast<const volatile Mailbox*>(data)); @@ -18107,8 +18089,7 @@ } if (!texture_ref) { - LOCAL_SET_GL_ERROR( - GL_INVALID_OPERATION, func_name, "unknown texture for target"); + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, "unknown texture"); return; } @@ -18119,12 +18100,6 @@ return; } - if (produced->target() != target) { - LOCAL_SET_GL_ERROR( - GL_INVALID_OPERATION, func_name, "invalid target"); - return; - } - group_->mailbox_manager()->ProduceTexture(mailbox, produced); } @@ -18144,7 +18119,6 @@ } void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL( - GLenum target, GLuint client_id, const volatile GLbyte* data) { TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", @@ -18174,21 +18148,14 @@ Texture* texture = static_cast<Texture*>(group_->mailbox_manager()->ConsumeTexture(mailbox)); if (!texture) { - EnsureTextureForClientId(target, client_id); + bool result = GenTexturesHelper(1, &client_id); + DCHECK(result); LOCAL_SET_GL_ERROR( GL_INVALID_OPERATION, "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); return; } - if (texture->target() != target) { - EnsureTextureForClientId(target, client_id); - LOCAL_SET_GL_ERROR( - GL_INVALID_OPERATION, - "glCreateAndConsumeTextureCHROMIUM", "invalid target"); - return; - } - texture_ref = texture_manager()->Consume(client_id, texture); }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index a833ffb..de48cec 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -4643,33 +4643,6 @@ return error::kNoError; } -error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate( - uint32_t immediate_data_size, - const volatile void* cmd_data) { - const volatile gles2::cmds::ProduceTextureCHROMIUMImmediate& c = *static_cast< - const volatile gles2::cmds::ProduceTextureCHROMIUMImmediate*>(cmd_data); - GLenum target = static_cast<GLenum>(c.target); - uint32_t data_size; - if (!GLES2Util::ComputeDataSize<GLbyte, 16>(1, &data_size)) { - return error::kOutOfBounds; - } - if (data_size > immediate_data_size) { - return error::kOutOfBounds; - } - volatile const GLbyte* mailbox = GetImmediateDataAs<volatile const GLbyte*>( - c, data_size, immediate_data_size); - if (!validators_->texture_bind_target.IsValid(target)) { - LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target, - "target"); - return error::kNoError; - } - if (mailbox == NULL) { - return error::kOutOfBounds; - } - DoProduceTextureCHROMIUM(target, mailbox); - return error::kNoError; -} - error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate( uint32_t immediate_data_size, const volatile void* cmd_data) { @@ -4678,7 +4651,6 @@ const volatile gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>( cmd_data); GLuint texture = c.texture; - GLenum target = static_cast<GLenum>(c.target); uint32_t data_size; if (!GLES2Util::ComputeDataSize<GLbyte, 16>(1, &data_size)) { return error::kOutOfBounds; @@ -4688,15 +4660,10 @@ } volatile const GLbyte* mailbox = GetImmediateDataAs<volatile const GLbyte*>( c, data_size, immediate_data_size); - if (!validators_->texture_bind_target.IsValid(target)) { - LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target, - "target"); - return error::kNoError; - } if (mailbox == NULL) { return error::kOutOfBounds; } - DoProduceTextureDirectCHROMIUM(texture, target, mailbox); + DoProduceTextureDirectCHROMIUM(texture, mailbox); return error::kNoError; } @@ -4706,7 +4673,6 @@ const volatile gles2::cmds::CreateAndConsumeTextureINTERNALImmediate& c = *static_cast<const volatile gles2::cmds:: CreateAndConsumeTextureINTERNALImmediate*>(cmd_data); - GLenum target = static_cast<GLenum>(c.target); GLuint texture = static_cast<GLuint>(c.texture); uint32_t data_size; if (!GLES2Util::ComputeDataSize<GLbyte, 16>(1, &data_size)) { @@ -4717,15 +4683,10 @@ } volatile const GLbyte* mailbox = GetImmediateDataAs<volatile const GLbyte*>( c, data_size, immediate_data_size); - if (!validators_->texture_bind_target.IsValid(target)) { - LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateAndConsumeTextureINTERNAL", target, - "target"); - return error::kNoError; - } if (mailbox == NULL) { return error::kOutOfBounds; } - DoCreateAndConsumeTextureINTERNAL(target, texture, mailbox); + DoCreateAndConsumeTextureINTERNAL(texture, mailbox); return error::kNoError; }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototypes.h b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototypes.h index fe776e1f..6e30b1d 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototypes.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototypes.h
@@ -802,13 +802,9 @@ const void* indices, GLsizei primcount); error::Error DoVertexAttribDivisorANGLE(GLuint index, GLuint divisor); -error::Error DoProduceTextureCHROMIUM(GLenum target, - const volatile GLbyte* mailbox); error::Error DoProduceTextureDirectCHROMIUM(GLuint texture_client_id, - GLenum target, const volatile GLbyte* mailbox); -error::Error DoCreateAndConsumeTextureINTERNAL(GLenum target, - GLuint texture_client_id, +error::Error DoCreateAndConsumeTextureINTERNAL(GLuint texture_client_id, const volatile GLbyte* mailbox); error::Error DoBindUniformLocationCHROMIUM(GLuint program, GLint location,
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc index f6ead7b0..7bc0e7a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
@@ -3942,44 +3942,17 @@ return error::kNoError; } -error::Error GLES2DecoderPassthroughImpl::DoProduceTextureCHROMIUM( - GLenum target, - const volatile GLbyte* mailbox) { - auto bound_textures_iter = bound_textures_.find(target); - if (bound_textures_iter == bound_textures_.end()) { - InsertError(GL_INVALID_OPERATION, "Invalid texture target."); - return error::kNoError; - } - - const BoundTexture& bound_texture = - bound_textures_iter->second[active_texture_unit_]; - if (bound_texture.texture == nullptr) { - InsertError(GL_INVALID_OPERATION, "Unknown texture for target."); - return error::kNoError; - } - - const Mailbox& mb = Mailbox::FromVolatile( - *reinterpret_cast<const volatile Mailbox*>(mailbox)); - mailbox_manager_->ProduceTexture(mb, bound_texture.texture.get()); - return error::kNoError; -} - error::Error GLES2DecoderPassthroughImpl::DoProduceTextureDirectCHROMIUM( GLuint texture_client_id, - GLenum target, const volatile GLbyte* mailbox) { auto texture_object_iter = resources_->texture_object_map.find(texture_client_id); if (texture_object_iter == resources_->texture_object_map.end()) { - InsertError(GL_INVALID_OPERATION, "Unknown texture for target."); + InsertError(GL_INVALID_OPERATION, "Unknown texture."); return error::kNoError; } scoped_refptr<TexturePassthrough> texture = texture_object_iter->second; - if (texture->target() != target) { - InsertError(GL_INVALID_OPERATION, "Texture target does not match."); - return error::kNoError; - } const Mailbox& mb = Mailbox::FromVolatile( *reinterpret_cast<const volatile Mailbox*>(mailbox)); @@ -3988,7 +3961,6 @@ } error::Error GLES2DecoderPassthroughImpl::DoCreateAndConsumeTextureINTERNAL( - GLenum target, GLuint texture_client_id, const volatile GLbyte* mailbox) { if (!texture_client_id || @@ -4005,11 +3977,6 @@ return error::kNoError; } - if (texture->target() != target) { - InsertError(GL_INVALID_OPERATION, "Texture target does not match."); - return error::kNoError; - } - // Update id mappings resources_->texture_id_map.RemoveClientID(texture_client_id); resources_->texture_id_map.SetIDMapping(texture_client_id, @@ -4018,9 +3985,6 @@ resources_->texture_object_map.insert( std::make_pair(texture_client_id, texture)); - // Bind the service id that now represents this texture - UpdateTextureBinding(target, texture_client_id, texture.get()); - return error::kNoError; }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc index 8acaa4c..d143cb4 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc
@@ -4031,31 +4031,6 @@ return error::kNoError; } -error::Error GLES2DecoderPassthroughImpl::HandleProduceTextureCHROMIUMImmediate( - uint32_t immediate_data_size, - const volatile void* cmd_data) { - const volatile gles2::cmds::ProduceTextureCHROMIUMImmediate& c = *static_cast< - const volatile gles2::cmds::ProduceTextureCHROMIUMImmediate*>(cmd_data); - GLenum target = static_cast<GLenum>(c.target); - uint32_t data_size; - if (!GLES2Util::ComputeDataSize<GLbyte, 16>(1, &data_size)) { - return error::kOutOfBounds; - } - if (data_size > immediate_data_size) { - return error::kOutOfBounds; - } - volatile const GLbyte* mailbox = GetImmediateDataAs<volatile const GLbyte*>( - c, data_size, immediate_data_size); - if (mailbox == nullptr) { - return error::kOutOfBounds; - } - error::Error error = DoProduceTextureCHROMIUM(target, mailbox); - if (error != error::kNoError) { - return error; - } - return error::kNoError; -} - error::Error GLES2DecoderPassthroughImpl::HandleProduceTextureDirectCHROMIUMImmediate( uint32_t immediate_data_size, @@ -4065,7 +4040,6 @@ const volatile gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>( cmd_data); GLuint texture = c.texture; - GLenum target = static_cast<GLenum>(c.target); uint32_t data_size; if (!GLES2Util::ComputeDataSize<GLbyte, 16>(1, &data_size)) { return error::kOutOfBounds; @@ -4078,7 +4052,7 @@ if (mailbox == nullptr) { return error::kOutOfBounds; } - error::Error error = DoProduceTextureDirectCHROMIUM(texture, target, mailbox); + error::Error error = DoProduceTextureDirectCHROMIUM(texture, mailbox); if (error != error::kNoError) { return error; } @@ -4092,7 +4066,6 @@ const volatile gles2::cmds::CreateAndConsumeTextureINTERNALImmediate& c = *static_cast<const volatile gles2::cmds:: CreateAndConsumeTextureINTERNALImmediate*>(cmd_data); - GLenum target = static_cast<GLenum>(c.target); GLuint texture = static_cast<GLuint>(c.texture); uint32_t data_size; if (!GLES2Util::ComputeDataSize<GLbyte, 16>(1, &data_size)) { @@ -4106,8 +4079,7 @@ if (mailbox == nullptr) { return error::kOutOfBounds; } - error::Error error = - DoCreateAndConsumeTextureINTERNAL(target, texture, mailbox); + error::Error error = DoCreateAndConsumeTextureINTERNAL(texture, mailbox); if (error != error::kNoError) { return error; }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc index a3b8869..955a875 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
@@ -3196,9 +3196,9 @@ Texture* texture = texture_ref->texture(); EXPECT_EQ(kServiceTextureId, texture->service_id()); - ProduceTextureCHROMIUMImmediate& produce_cmd = - *GetImmediateAs<ProduceTextureCHROMIUMImmediate>(); - produce_cmd.Init(GL_TEXTURE_2D, mailbox.name); + ProduceTextureDirectCHROMIUMImmediate& produce_cmd = + *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); + produce_cmd.Init(client_texture_id_, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -3230,7 +3230,7 @@ CreateAndConsumeTextureINTERNALImmediate& consume_cmd = *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); - consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); + consume_cmd.Init(new_texture_id, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -3272,7 +3272,7 @@ ProduceTextureDirectCHROMIUMImmediate& produce_cmd = *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); - produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); + produce_cmd.Init(client_texture_id_, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -3306,7 +3306,7 @@ GLuint new_texture_id = kNewClientId; CreateAndConsumeTextureINTERNALImmediate& consume_cmd = *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); - consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); + consume_cmd.Init(new_texture_id, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -3337,29 +3337,6 @@ EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); } -TEST_P(GLES2DecoderTest, ProduceTextureCHROMIUMInvalidTarget) { - Mailbox mailbox = Mailbox::Generate(); - - DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); - DoTexImage2D( - GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 1, 0, GL_RGBA, - GL_UNSIGNED_BYTE, 0, 0); - TextureRef* texture_ref = - group().texture_manager()->GetTexture(client_texture_id_); - ASSERT_TRUE(texture_ref != NULL); - Texture* texture = texture_ref->texture(); - EXPECT_EQ(kServiceTextureId, texture->service_id()); - - ProduceTextureDirectCHROMIUMImmediate& produce_cmd = - *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); - produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); - - // ProduceTexture should fail it the texture and produce targets don't match. - EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); -} - TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidMailbox) { // Attempt to consume the mailbox when no texture has been produced with it. Mailbox mailbox = Mailbox::Generate(); @@ -3368,9 +3345,6 @@ EXPECT_CALL(*gl_, GenTextures(1, _)) .WillOnce(SetArgPointee<1>(kNewServiceId)) .RetiresOnSaturation(); - EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, _)) - .Times(2) - .RetiresOnSaturation(); EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)).Times(1).RetiresOnSaturation(); ActiveTexture& texture_cmd = *GetImmediateAs<ActiveTexture>(); @@ -3379,7 +3353,7 @@ CreateAndConsumeTextureINTERNALImmediate& consume_cmd = *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); - consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); + consume_cmd.Init(new_texture_id, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); @@ -3393,8 +3367,8 @@ group().texture_manager()->GetTexture(new_texture_id); ASSERT_TRUE(texture_ref != NULL); Texture* texture = texture_ref->texture(); - // New texture should have the correct target type. - EXPECT_TRUE(texture->target() == GL_TEXTURE_2D); + // New texture should be unbound to a target. + EXPECT_TRUE(texture->target() == GL_NONE); // New texture should have a valid service_id. EXPECT_EQ(kNewServiceId, texture->service_id()); } @@ -3409,7 +3383,7 @@ ProduceTextureDirectCHROMIUMImmediate& produce_cmd = *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); - produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); + produce_cmd.Init(client_texture_id_, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -3418,7 +3392,7 @@ GLuint new_texture_id = 0; CreateAndConsumeTextureINTERNALImmediate& consume_cmd = *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); - consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); + consume_cmd.Init(new_texture_id, mailbox.name); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); @@ -3426,60 +3400,6 @@ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } -TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidTarget) { - Mailbox mailbox = Mailbox::Generate(); - - DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); - TextureRef* texture_ref = - group().texture_manager()->GetTexture(client_texture_id_); - ASSERT_TRUE(texture_ref != NULL); - - ProduceTextureDirectCHROMIUMImmediate& produce_cmd = - *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>(); - produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - - EXPECT_CALL(*gl_, GenTextures(1, _)) - .WillOnce(SetArgPointee<1>(kNewServiceId)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, _)) - .Times(2) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)).Times(1).RetiresOnSaturation(); - - ActiveTexture& texture_cmd = *GetImmediateAs<ActiveTexture>(); - texture_cmd.Init(GL_TEXTURE1); - EXPECT_EQ(error::kNoError, ExecuteCmd(texture_cmd)); - - // Attempt to consume the mailbox with a different target. - GLuint new_texture_id = kNewClientId; - CreateAndConsumeTextureINTERNALImmediate& consume_cmd = - *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); - consume_cmd.Init(GL_TEXTURE_CUBE_MAP, new_texture_id, mailbox.name); - EXPECT_EQ(error::kNoError, - ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); - - // CreateAndConsumeTexture should fail if the produced texture had a different - // target. - EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); - - // Make sure the new client_id is associated with a texture ref even though - // CreateAndConsumeTexture failed. - texture_ref = group().texture_manager()->GetTexture(new_texture_id); - ASSERT_TRUE(texture_ref != NULL); - Texture* texture = texture_ref->texture(); - // New texture should have the correct target type. - EXPECT_TRUE(texture->target() == GL_TEXTURE_CUBE_MAP); - // New texture should have a valid service_id. - EXPECT_EQ(kNewServiceId, texture->service_id()); - - // Make sure the client_id did not become associated with the produced texture - // service_id. - EXPECT_NE(kServiceTextureId, texture->service_id()); -} - TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { InitState init; init.extensions = "GL_ANGLE_depth_texture";
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc index 5daa4f0..7a592c31 100644 --- a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc +++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
@@ -82,7 +82,7 @@ gl1_.decoder()->TakeFrontBuffer(mailbox); gl2_.MakeCurrent(); - GLuint tex = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint tex = glCreateAndConsumeTextureCHROMIUM(mailbox.name); glBindTexture(GL_TEXTURE_2D, tex); glDeleteTextures(1, &tex); glFlush(); @@ -135,20 +135,20 @@ GL_UNSIGNED_BYTE, &source_pixel); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + glProduceTextureDirectCHROMIUM(tex1, mailbox1); glFlush(); gl2_.MakeCurrent(); - GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(mailbox1); glBindTexture(GL_TEXTURE_2D, tex2); EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0)); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + glProduceTextureDirectCHROMIUM(tex2, mailbox2); glFlush(); gl1_.MakeCurrent(); - tex1 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + tex1 = glCreateAndConsumeTextureCHROMIUM(mailbox2); glBindTexture(GL_TEXTURE_2D, tex1); EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0)); } @@ -177,20 +177,20 @@ GL_UNSIGNED_BYTE, &source_pixel); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + glProduceTextureDirectCHROMIUM(tex1, mailbox1); glFlush(); gl2_.MakeCurrent(); - GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(mailbox1); glBindTexture(GL_TEXTURE_2D, tex2); EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0)); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + glProduceTextureDirectCHROMIUM(tex2, mailbox2); glFlush(); gl1_.MakeCurrent(); - tex1 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + tex1 = glCreateAndConsumeTextureCHROMIUM(mailbox2); glBindTexture(GL_TEXTURE_2D, tex1); EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0)); } @@ -219,20 +219,20 @@ GL_UNSIGNED_BYTE, &source_pixel); - glProduceTextureDirectCHROMIUM(tex1, GL_TEXTURE_2D, mailbox1); + glProduceTextureDirectCHROMIUM(tex1, mailbox1); glFlush(); gl2_.MakeCurrent(); - GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1); + GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(mailbox1); glBindTexture(GL_TEXTURE_2D, tex2); EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0)); - glProduceTextureDirectCHROMIUM(tex2, GL_TEXTURE_2D, mailbox2); + glProduceTextureDirectCHROMIUM(tex2, mailbox2); glFlush(); gl1_.MakeCurrent(); - GLuint tex3 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2); + GLuint tex3 = glCreateAndConsumeTextureCHROMIUM(mailbox2); glBindTexture(GL_TEXTURE_2D, tex3); EXPECT_EQ(source_pixel, ReadTexel(tex3, 0, 0)); } @@ -256,12 +256,12 @@ GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; glGenMailboxCHROMIUM(mailbox); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); + glProduceTextureDirectCHROMIUM(tex1, mailbox); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); glFlush(); gl2_.MakeCurrent(); - GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox); + GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(mailbox); glBindTexture(GL_TEXTURE_2D, tex2); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); @@ -313,7 +313,7 @@ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); // The mailbox should still exist too. - GLuint tex3 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox); + GLuint tex3 = glCreateAndConsumeTextureCHROMIUM(mailbox); glBindTexture(GL_TEXTURE_2D, tex3); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); @@ -323,7 +323,7 @@ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); // Mailbox should be gone now. - tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox); + tex2 = glCreateAndConsumeTextureCHROMIUM(mailbox); glBindTexture(GL_TEXTURE_2D, tex2); EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); glDeleteTextures(1, &tex2); @@ -360,7 +360,7 @@ GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; glGenMailboxCHROMIUM(mailbox); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); + glProduceTextureDirectCHROMIUM(tex1, mailbox); for (int i = 0; i < 1000; ++i) { // Assume context 1 is current. @@ -371,7 +371,7 @@ gl1_.gles2_implementation()->OrderingBarrierCHROMIUM(); // Consume texture in context 2. gl2_.MakeCurrent(); - GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox); + GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(mailbox); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); // Set up framebuffer in context 2 (strictly, not necessary, could // do this just once). @@ -422,7 +422,7 @@ gl2_.decoder()->TakeFrontBuffer(mailbox); gl1_.MakeCurrent(); - GLuint tex1 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint tex1 = glCreateAndConsumeTextureCHROMIUM(mailbox.name); glBindTexture(GL_TEXTURE_2D, tex1); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); EXPECT_EQ(0xFFFFFF00u, ReadTexel(tex1, 0, 0)); @@ -451,7 +451,7 @@ gl2_.decoder()->TakeFrontBuffer(mailbox2); gl1_.MakeCurrent(); - tex1 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2.name); + tex1 = glCreateAndConsumeTextureCHROMIUM(mailbox2.name); glBindTexture(GL_TEXTURE_2D, tex1); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0)); @@ -567,7 +567,7 @@ glFinish(); gl2_.MakeCurrent(); - GLuint tex = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint tex = glCreateAndConsumeTextureCHROMIUM(mailbox.name); glBindTexture(GL_TEXTURE_2D, tex); EXPECT_EQ(0xFF0000FFu, ReadTexel(tex, 0, 0)); @@ -594,7 +594,7 @@ gl2_.decoder()->TakeFrontBuffer(mailbox); gl1_.MakeCurrent(); - GLuint tex1 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint tex1 = glCreateAndConsumeTextureCHROMIUM(mailbox.name); glBindTexture(GL_TEXTURE_2D, tex1); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); @@ -611,31 +611,6 @@ } } -TEST_F(GLTextureMailboxTest, ProduceTextureDirectInvalidTarget) { - SetUpContexts(); - gl1_.MakeCurrent(); - - GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM]; - glGenMailboxCHROMIUM(mailbox1); - - GLuint tex1; - glGenTextures(1, &tex1); - - glBindTexture(GL_TEXTURE_CUBE_MAP, tex1); - uint32_t source_pixel = 0xFF0000FF; - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, - 0, - GL_RGBA, - 1, 1, - 0, - GL_RGBA, - GL_UNSIGNED_BYTE, - &source_pixel); - - glProduceTextureDirectCHROMIUM(tex1, GL_TEXTURE_2D, mailbox1); - EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); -} - // http://crbug.com/281565 #if !defined(OS_ANDROID) TEST_F(GLTextureMailboxTest, TakeFrontBufferMultipleContexts) { @@ -664,7 +639,7 @@ gl1_.MakeCurrent(); for (size_t i = 0; i < 2; ++i) { - tex[i] = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox[i].name); + tex[i] = glCreateAndConsumeTextureCHROMIUM(mailbox[i].name); glBindTexture(GL_TEXTURE_2D, tex[i]); EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); }
diff --git a/ios/build/bots/chromium.fyi/GomaCanaryiOS.json b/ios/build/bots/chromium.fyi/GomaCanaryiOS.json deleted file mode 100644 index 7f7f3c7..0000000 --- a/ios/build/bots/chromium.fyi/GomaCanaryiOS.json +++ /dev/null
@@ -1,27 +0,0 @@ -{ - "comments": [ - "Goma canary builder for iOS.", - "It is chromium.mac/ios-device.json + use_goma_canary, clobber." - ], - "xcode version": "9.0", - "gn_args": [ - "additional_target_cpus=[ \"arm64\" ]", - "goma_dir=\"$(goma_dir)\"", - "ios_enable_code_signing=false", - "is_component_build=false", - "is_debug=false", - "target_cpu=\"arm\"", - "target_os=\"ios\"", - "use_goma=true" - ], - "additional_compile_targets": [ - "all" - ], - "configuration": "Release", - "explain": true, - "sdk": "iphoneos11.0", - "tests": [ - ], - "clobber": true, - "use_goma_canary": true -}
diff --git a/ios/chrome/browser/feature_engagement/feature_engagement_egtest.mm b/ios/chrome/browser/feature_engagement/feature_engagement_egtest.mm index c43ca647..f0e0bbc 100644 --- a/ios/chrome/browser/feature_engagement/feature_engagement_egtest.mm +++ b/ios/chrome/browser/feature_engagement/feature_engagement_egtest.mm
@@ -89,7 +89,9 @@ // Verifies that the Badged Reading List feature shows when triggering // conditions are met. -- (void)testBadgedReadingListFeatureShouldShow { +// TODO(crbug.com/789943): This test is flaky on devices. Reenable it once it is +// fixed. +- (void)FLAKY_testBadgedReadingListFeatureShouldShow { base::test::ScopedFeatureList scoped_feature_list; EnableBadgedReadingListTriggering(scoped_feature_list);
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm index 5d86fc26..436f4b9 100644 --- a/ios/chrome/browser/ui/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -1259,7 +1259,7 @@ - (void)presentBubblesIfEligible { [self presentNewTabTipBubbleOnInitialized]; - [self presentNewIncognitoTabTipBubble]; + [self presentNewIncognitoTabTipBubbleOnInitialized]; } #pragma mark - UIViewController methods
diff --git a/ios/chrome/browser/ui/bubble/bubble_view_controller_presenter.mm b/ios/chrome/browser/ui/bubble/bubble_view_controller_presenter.mm index 21dd759f..9f9d756 100644 --- a/ios/chrome/browser/ui/bubble/bubble_view_controller_presenter.mm +++ b/ios/chrome/browser/ui/bubble/bubble_view_controller_presenter.mm
@@ -16,7 +16,7 @@ namespace { // How long, in seconds, the bubble is visible on the screen. -const NSTimeInterval kBubbleVisibilityDuration = 3.0; +const NSTimeInterval kBubbleVisibilityDuration = 4.0; // How long, in seconds, the user should be considered engaged with the bubble // after the bubble first becomes visible. const NSTimeInterval kBubbleEngagementDuration = 30.0;
diff --git a/ios/net/cookies/cookie_creation_time_manager.h b/ios/net/cookies/cookie_creation_time_manager.h index 42b9a42..120ba7a 100644 --- a/ios/net/cookies/cookie_creation_time_manager.h +++ b/ios/net/cookies/cookie_creation_time_manager.h
@@ -8,6 +8,7 @@ #include <set> #include "base/containers/hash_tables.h" +#include "base/memory/weak_ptr.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" @@ -17,6 +18,8 @@ // The CookieCreationTimeManager allows to get and set the creation time of a // NSHTTPCookie. +// All the methods of CookieCreationTimeManager must be called on the IO thread, +// except its constructor that can be called from any thread. // Creation time data is stored either in the cookie properties (when the cookie // is created by the system) or in |creation_times_| (when the cookie is created // by CookieStoreIOS). When both are available, |creation_times_| is used, @@ -37,11 +40,14 @@ void DeleteCreationTime(NSHTTPCookie* cookie); // Clears all the creation times. void Clear(); + // Gets base::WeakPtr to the object to be used in sorting. + base::WeakPtr<CookieCreationTimeManager> GetWeakPtr(); private: base::hash_map<std::string, base::Time> creation_times_; std::set<base::Time> unique_times_; base::ThreadChecker thread_checker_; + base::WeakPtrFactory<CookieCreationTimeManager> weak_factory_; }; } // namespace net
diff --git a/ios/net/cookies/cookie_creation_time_manager.mm b/ios/net/cookies/cookie_creation_time_manager.mm index c427641..e3846a45 100644 --- a/ios/net/cookies/cookie_creation_time_manager.mm +++ b/ios/net/cookies/cookie_creation_time_manager.mm
@@ -49,7 +49,8 @@ namespace net { -CookieCreationTimeManager::CookieCreationTimeManager() { +CookieCreationTimeManager::CookieCreationTimeManager() : weak_factory_(this) { + DETACH_FROM_THREAD(thread_checker_); } CookieCreationTimeManager::~CookieCreationTimeManager() { @@ -122,4 +123,9 @@ unique_times_.clear(); } +base::WeakPtr<CookieCreationTimeManager> +CookieCreationTimeManager::GetWeakPtr() { + return weak_factory_.GetWeakPtr(); +} + } // namespace net
diff --git a/ios/net/cookies/system_cookie_store.h b/ios/net/cookies/system_cookie_store.h index 7202f32..95806ee 100644 --- a/ios/net/cookies/system_cookie_store.h +++ b/ios/net/cookies/system_cookie_store.h
@@ -74,8 +74,8 @@ base::WeakPtr<SystemCookieStore> GetWeakPtr(); protected: - // Compares cookies based on the path lengths and the creation times, as per - // RFC6265. + // Compares cookies based on the path lengths and the creation times provided + // by a non null creation time manager |context|, as per RFC6265. static NSInteger CompareCookies(id a, id b, void* context); // Internal cookie stores doesn't store creation time. This object is used
diff --git a/ios/net/cookies/system_cookie_store.mm b/ios/net/cookies/system_cookie_store.mm index a1dd6d0..14761be 100644 --- a/ios/net/cookies/system_cookie_store.mm +++ b/ios/net/cookies/system_cookie_store.mm
@@ -36,6 +36,7 @@ // protected static NSInteger SystemCookieStore::CompareCookies(id a, id b, void* context) { + DCHECK(context); NSHTTPCookie* cookie_a = static_cast<NSHTTPCookie*>(a); NSHTTPCookie* cookie_b = static_cast<NSHTTPCookie*>(b); // Compare path lengths first.
diff --git a/ios/web/net/cookies/wk_http_system_cookie_store.mm b/ios/web/net/cookies/wk_http_system_cookie_store.mm index efd6dc6..695b37df 100644 --- a/ios/web/net/cookies/wk_http_system_cookie_store.mm +++ b/ios/web/net/cookies/wk_http_system_cookie_store.mm
@@ -65,71 +65,95 @@ SystemCookieCallbackForCookies callback) { __block SystemCookieCallbackForCookies shared_callback = std::move(callback); GURL block_url = url; - [cookie_store_ getAllCookies:^(NSArray<NSHTTPCookie*>* cookies) { - NSMutableArray* result = [NSMutableArray array]; - for (NSHTTPCookie* cookie in cookies) { - if (ShouldIncludeForRequestUrl(cookie, block_url)) { - [result addObject:cookie]; - } - } - RunSystemCookieCallbackForCookies(std::move(shared_callback), result); - }]; + web::WebThread::PostTask( + web::WebThread::UI, FROM_HERE, base::BindBlockArc(^{ + [cookie_store_ getAllCookies:^(NSArray<NSHTTPCookie*>* cookies) { + NSMutableArray* result = [NSMutableArray array]; + for (NSHTTPCookie* cookie in cookies) { + if (ShouldIncludeForRequestUrl(cookie, block_url)) { + [result addObject:cookie]; + } + } + RunSystemCookieCallbackForCookies(std::move(shared_callback), result); + }]; + })); } void WKHTTPSystemCookieStore::GetAllCookiesAsync( SystemCookieCallbackForCookies callback) { __block SystemCookieCallbackForCookies shared_callback = std::move(callback); - [cookie_store_ getAllCookies:^(NSArray<NSHTTPCookie*>* cookies) { - RunSystemCookieCallbackForCookies(std::move(shared_callback), cookies); - }]; + web::WebThread::PostTask( + web::WebThread::UI, FROM_HERE, base::BindBlockArc(^{ + [cookie_store_ getAllCookies:^(NSArray<NSHTTPCookie*>* cookies) { + RunSystemCookieCallbackForCookies(std::move(shared_callback), + cookies); + }]; + })); } void WKHTTPSystemCookieStore::DeleteCookieAsync(NSHTTPCookie* cookie, SystemCookieCallback callback) { __block SystemCookieCallback shared_callback = std::move(callback); - [cookie_store_ deleteCookie:cookie - completionHandler:^{ - creation_time_manager_->DeleteCreationTime(cookie); - RunSystemCookieCallbackOnIOThread(std::move(shared_callback)); - }]; + NSHTTPCookie* block_cookie = cookie; + web::WebThread::PostTask( + web::WebThread::UI, FROM_HERE, base::BindBlockArc(^{ + [cookie_store_ deleteCookie:block_cookie + completionHandler:^{ + RunSystemCookieCallbackOnIOThread(base::BindBlockArc(^{ + creation_time_manager_->DeleteCreationTime(block_cookie); + if (!shared_callback.is_null()) + std::move(shared_callback).Run(); + })); + }]; + })); } void WKHTTPSystemCookieStore::SetCookieAsync( NSHTTPCookie* cookie, const base::Time* optional_creation_time, SystemCookieCallback callback) { __block SystemCookieCallback shared_callback = std::move(callback); - [cookie_store_ setCookie:cookie - completionHandler:^{ - // Set creation time as soon as possible - base::Time cookie_time = base::Time::Now(); - if (optional_creation_time && !optional_creation_time->is_null()) - cookie_time = *optional_creation_time; + NSHTTPCookie* block_cookie = cookie; + base::Time cookie_time = base::Time::Now(); + if (optional_creation_time && !optional_creation_time->is_null()) + cookie_time = *optional_creation_time; - creation_time_manager_->SetCreationTime( - cookie, - creation_time_manager_->MakeUniqueCreationTime(cookie_time)); - RunSystemCookieCallbackOnIOThread(std::move(shared_callback)); - }]; + web::WebThread::PostTask( + web::WebThread::UI, FROM_HERE, base::BindBlockArc(^{ + [cookie_store_ setCookie:block_cookie + completionHandler:^{ + RunSystemCookieCallbackOnIOThread(base::BindBlockArc(^{ + creation_time_manager_->SetCreationTime( + block_cookie, + creation_time_manager_->MakeUniqueCreationTime( + cookie_time)); + if (!shared_callback.is_null()) + std::move(shared_callback).Run(); + })); + }]; + })); } void WKHTTPSystemCookieStore::ClearStoreAsync(SystemCookieCallback callback) { __block SystemCookieCallback shared_callback = std::move(callback); - [cookie_store_ getAllCookies:^(NSArray<NSHTTPCookie*>* cookies) { - - scoped_refptr<CallbackCounter> callback_counter = - new CallbackCounter(base::BindBlockArc(^{ - creation_time_manager_->Clear(); - RunSystemCookieCallbackOnIOThread(std::move(shared_callback)); - })); - // Add callback for each cookie - callback_counter->IncrementCount(cookies.count); - for (NSHTTPCookie* cookie in cookies) { - [cookie_store_ deleteCookie:cookie - completionHandler:^{ - callback_counter->DecrementCount(); - }]; - } - }]; + web::WebThread::PostTask( + web::WebThread::UI, FROM_HERE, base::BindBlockArc(^{ + [cookie_store_ getAllCookies:^(NSArray<NSHTTPCookie*>* cookies) { + scoped_refptr<CallbackCounter> callback_counter = + new CallbackCounter(base::BindRepeating( + &RunSystemCookieCallbackOnIOThread, base::BindBlockArc(^{ + creation_time_manager_->Clear(); + std::move(shared_callback).Run(); + }))); + // Add callback for each cookie + callback_counter->IncrementCount(cookies.count); + for (NSHTTPCookie* cookie in cookies) { + [cookie_store_ deleteCookie:cookie + completionHandler:^{ + callback_counter->DecrementCount(); + }]; + } + }]; + })); } NSHTTPCookieAcceptPolicy WKHTTPSystemCookieStore::GetCookieAcceptPolicy() { @@ -145,11 +169,21 @@ NSArray<NSHTTPCookie*>* cookies) { if (callback.is_null()) return; - NSArray* result = [static_cast<NSArray*>(cookies) - sortedArrayUsingFunction:CompareCookies - context:creation_time_manager_.get()]; - RunSystemCookieCallbackOnIOThread( - base::BindOnce(std::move(callback), result)); + base::WeakPtr<net::CookieCreationTimeManager> weak_time_manager = + creation_time_manager_->GetWeakPtr(); + NSArray<NSHTTPCookie*>* block_cookies = cookies; + __block net::SystemCookieStore::SystemCookieCallbackForCookies + shared_callback = std::move(callback); + RunSystemCookieCallbackOnIOThread(base::BindBlockArc(^{ + if (weak_time_manager) { + NSArray* result = [static_cast<NSArray*>(block_cookies) + sortedArrayUsingFunction:CompareCookies + context:weak_time_manager.get()]; + std::move(shared_callback).Run(result); + } else { + std::move(shared_callback).Run(block_cookies); + } + })); } } // namespace web
diff --git a/media/base/test_helpers.h b/media/base/test_helpers.h index 506dc01..3df27b11 100644 --- a/media/base/test_helpers.h +++ b/media/base/test_helpers.h
@@ -312,6 +312,18 @@ "us are in a previously buffered splice."); } +MATCHER_P2(SkippingSpliceTooLittleOverlap, + pts_microseconds, + overlap_microseconds, + "") { + return CONTAINS_STRING( + arg, "Skipping audio splice trimming at PTS=" + + base::IntToString(pts_microseconds) + "us. Found only " + + base::IntToString(overlap_microseconds) + + "us of overlap, need at least 1000us. Multiple occurrences may " + "result in loss of A/V sync."); +} + MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") { return CONTAINS_STRING(arg, "Estimating WebM block duration to be " + base::IntToString(estimated_duration_ms) +
diff --git a/media/blink/webmediaplayer_cast_android.cc b/media/blink/webmediaplayer_cast_android.cc index c0eeaf7..3d801f0 100644 --- a/media/blink/webmediaplayer_cast_android.cc +++ b/media/blink/webmediaplayer_cast_android.cc
@@ -130,7 +130,8 @@ gpu::Mailbox texture_mailbox; gl->GenMailboxCHROMIUM(texture_mailbox.name); - gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); + gl->ProduceTextureDirectCHROMIUM(remote_playback_texture_id, + texture_mailbox.name); const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); gl->Flush();
diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc index c3dcf5a..e6b14732 100644 --- a/media/filters/chunk_demuxer_unittest.cc +++ b/media/filters/chunk_demuxer_unittest.cc
@@ -3465,7 +3465,29 @@ scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts"); EXPECT_CALL(*this, InitSegmentReceivedMock(_)); - ASSERT_TRUE(AppendData(kSourceId, buffer->data(), buffer->data_size())); + + // This mp2ts file contains buffers which can trigger media logs related to + // splicing. Related logic occurs more deterministically (and frequently) when + // buffering ByPts; we append in small chunks to force the same logic when + // buffering by either Pts or Dts here. + EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(1655422, 1655419, 23217)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(1957277, 4)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(2514555, 6)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(3071833, 6)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(3652333, 6)); + + // Append the media in small chunks. 1 byte chunks would cause test timeout; + // 1k chunks appear to be small enough to let ByDts meet the logging + // expectations of the more deterministic ByPts logic, simplifying this test. + size_t appended_bytes = 0; + const size_t chunk_size = 1024; + while (appended_bytes < buffer->data_size()) { + size_t cur_chunk_size = + std::min(chunk_size, buffer->data_size() - appended_bytes); + ASSERT_TRUE( + AppendData(kSourceId, buffer->data() + appended_bytes, cur_chunk_size)); + appended_bytes += cur_chunk_size; + } // Confirm we're in the middle of parsing a media segment. ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); @@ -3513,7 +3535,29 @@ scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts"); EXPECT_CALL(*this, InitSegmentReceivedMock(_)); - ASSERT_TRUE(AppendData(kSourceId, buffer->data(), buffer->data_size())); + + // This mp2ts file contains buffers which can trigger media logs related to + // splicing. Related logic occurs more deterministically (and frequently) when + // buffering ByPts; we append in small chunks to force the same logic when + // buffering by either Pts or Dts here. + EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(1655422, 1655419, 23217)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(1957277, 4)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(2514555, 6)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(3071833, 6)); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(3652333, 6)); + + // Append the media in small chunks. 1 byte chunks would cause test timeout; + // 1k chunks appear to be small enough to let ByDts meet the logging + // expectations of the more deterministic ByPts logic, simplifying this test. + size_t appended_bytes = 0; + const size_t chunk_size = 1024; + while (appended_bytes < buffer->data_size()) { + size_t cur_chunk_size = + std::min(chunk_size, buffer->data_size() - appended_bytes); + ASSERT_TRUE( + AppendData(kSourceId, buffer->data() + appended_bytes, cur_chunk_size)); + appended_bytes += cur_chunk_size; + } // Confirm we're in the middle of parsing a media segment. ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId));
diff --git a/media/filters/frame_processor.cc b/media/filters/frame_processor.cc index 6ad3ec7d..056cc28b 100644 --- a/media/filters/frame_processor.cc +++ b/media/filters/frame_processor.cc
@@ -82,6 +82,9 @@ // |needs_random_access_point_| to true. void Reset(); + // Unsets |highest_presentation_timestamp_|. + void ResetHighestPresentationTimestamp(); + // If |highest_presentation_timestamp_| is unset or |timestamp| is greater // than |highest_presentation_timestamp_|, sets // |highest_presentation_timestamp_| to |timestamp|. Note that bidirectional @@ -207,6 +210,10 @@ last_keyframe_presentation_timestamp_ = kNoTimestamp; } +void MseTrackBuffer::ResetHighestPresentationTimestamp() { + highest_presentation_timestamp_ = kNoTimestamp; +} + void MseTrackBuffer::SetHighestPresentationTimestampIfIncreased( base::TimeDelta timestamp) { if (highest_presentation_timestamp_ == kNoTimestamp || @@ -901,16 +908,36 @@ (track_buffer->pending_group_start_pts() != kNoTimestamp && track_buffer->pending_group_start_pts() > presentation_timestamp); - // When buffering by PTS intervals and a keyframe is discovered to have - // a decreasing PTS versus the previous keyframe for that track in the - // current coded frame group, signal a new coded frame group for that track - // buffer so that it can correctly process overlap-removals of the new GOP. - signal_new_cfg |= - range_api_ == ChunkDemuxerStream::RangeApi::kNewByPts && - frame->is_key_frame() && - track_buffer->last_keyframe_presentation_timestamp() != kNoTimestamp && - track_buffer->last_keyframe_presentation_timestamp() > - presentation_timestamp; + if (range_api_ == ChunkDemuxerStream::RangeApi::kNewByPts && + frame->is_key_frame()) { + // When buffering by PTS intervals and a keyframe is discovered to have a + // decreasing PTS versus the previous highest presentation timestamp for + // that track in the current coded frame group, signal a new coded frame + // group for that track buffer so that it can correctly process + // overlap-removals for the new GOP. + if (track_buffer->highest_presentation_timestamp() != kNoTimestamp && + track_buffer->highest_presentation_timestamp() > + presentation_timestamp) { + signal_new_cfg = true; + // In case there is currently a decreasing keyframe PTS relative to the + // track buffer's highest PTS, that is later followed by a jump forward + // requiring overlap removal of media prior to the track buffer's + // highest PTS, reset that tracking now to ensure correctness of + // signalling the need for such overlap removal later. + track_buffer->ResetHighestPresentationTimestamp(); + } + + // When buffering by PTS intervals and an otherwise continuous coded frame + // group (by DTS, and with non-decreasing keyframe PTS) contains a + // keyframe with PTS in the future, signal a new coded frame group with + // start time set to the previous highest frame end time in the coded + // frame group for this track. This lets the stream coalesce a potential + // gap, and also pass internal buffer adjacency checks. + signal_new_cfg |= + track_buffer->highest_presentation_timestamp() != kNoTimestamp && + track_buffer->highest_presentation_timestamp() < + presentation_timestamp; + } if (signal_new_cfg) { DCHECK(frame->is_key_frame()); @@ -924,10 +951,15 @@ NotifyStartOfCodedFrameGroup(decode_timestamp, presentation_timestamp); pending_notify_all_group_start_ = false; } else { - // Don't signal later times than previously signalled for this group. DecodeTimestamp updated_dts = std::min( track_buffer->last_processed_decode_timestamp(), decode_timestamp); base::TimeDelta updated_pts = track_buffer->pending_group_start_pts(); + if (updated_pts == kNoTimestamp && + track_buffer->highest_presentation_timestamp() != kNoTimestamp && + track_buffer->highest_presentation_timestamp() < + presentation_timestamp) { + updated_pts = track_buffer->highest_presentation_timestamp(); + } if (updated_pts == kNoTimestamp || updated_pts > presentation_timestamp) updated_pts = presentation_timestamp; track_buffer->NotifyStartOfCodedFrameGroup(updated_dts, updated_pts);
diff --git a/media/filters/frame_processor_unittest.cc b/media/filters/frame_processor_unittest.cc index cce81136..92a157ad 100644 --- a/media/filters/frame_processor_unittest.cc +++ b/media/filters/frame_processor_unittest.cc
@@ -858,8 +858,27 @@ if (use_sequence_mode_) frame_processor_->SetSequenceMode(true); SetTimestampOffset(Milliseconds(-10)); + + // When buffering ByDts, splice trimming checks are done only on every audio + // frame following either a discontinuity or the beginning of ProcessFrames(). + // When buffering ByPts, splice trimming checks are also done on audio frames + // with PTS not directly continuous with the highest frame end PTS already + // processed. To simplify the test to have the same splice logging + // expectations, process each frame by itself here. + if (use_sequence_mode_) + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(-10))); + else + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(0))); + EXPECT_TRUE(ProcessFrames("0K", "")); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease( + base::TimeDelta::FromMicroseconds(10250))); + EXPECT_TRUE(ProcessFrames("10.25K", "")); + + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(10000, 250)); EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(20))); - EXPECT_TRUE(ProcessFrames("0K 10.25K 20K", "")); + EXPECT_TRUE(ProcessFrames("20K", "")); + CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,20) }"); CheckReadsThenReadStalls(audio_.get(), "0P 0:10.25 10:20"); } @@ -1321,6 +1340,261 @@ CheckExpectedRangesByTimestamp(audio_.get(), "{ [0,1) [3,4) [6,6) [10,11) }"); } +TEST_P(FrameProcessorTest, + BufferingByPts_ContinuousDts_SapType2_and_PtsJumpForward) { + if (range_api_ == ChunkDemuxerStream::RangeApi::kLegacyByDts) { + DVLOG(1) << "Skipping kLegacyByDts versions of this test"; + return; + } + + InSequence s; + AddTestTracks(HAS_VIDEO); + frame_processor_->SetSequenceMode(use_sequence_mode_); + + // Make the sequence mode buffering appear just like segments mode to simplify + // this test case. + if (use_sequence_mode_) + SetTimestampOffset(Milliseconds(1060)); + + EXPECT_CALL(callbacks_, + OnParseWarning( + SourceBufferParseWarning::kKeyframeTimeGreaterThanDependant)); + EXPECT_MEDIA_LOG(KeyframeTimeGreaterThanDependant("1.06", "1")); + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(1070))); + EXPECT_TRUE(ProcessFrames( + "", "1060|0K 1000|10 1050|20 1010|30 1040|40 1020|50 1030|60")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + // Note that the PTS of GOP non-keyframes earlier than the keyframe doesn't + // modify the GOP start of the buffered range here. This may change if we + // decide to improve spec for SAP Type 2 GOPs that begin a coded frame group. + CheckExpectedRangesByTimestamp(video_.get(), "{ [1060,1070) }"); + + // Process just the keyframe of the next SAP Type 2 GOP in decode continuity + // with the previous one. + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(1140))); + EXPECT_TRUE(ProcessFrames("", "1130|70K")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + // Note that the second GOP is buffered continuous with the first because + // there was no decode discontinuity detected. This results in inclusion of + // the significant PTS jump forward in the same continuous range. + CheckExpectedRangesByTimestamp(video_.get(), "{ [1060,1140) }"); + + // Process the remainder of the second GOP. + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(1140))); + EXPECT_TRUE( + ProcessFrames("", "1070|80 1120|90 1080|100 1110|110 1090|120 1100|130")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + CheckExpectedRangesByTimestamp(video_.get(), "{ [1060,1140) }"); + + // TODO(wolenetz): Here, [1060,1140) should demux continuously without read + // stall in the middle. See https://crbug.com/791095. + SeekStream(video_.get(), Milliseconds(1060)); + CheckReadsThenReadStalls(video_.get(), "1060 1000 1050 1010 1040 1020 1030"); + SeekStream(video_.get(), Milliseconds(1070)); + CheckReadsThenReadStalls(video_.get(), "1130 1070 1120 1080 1110 1090 1100"); +} + +TEST_P(FrameProcessorTest, + BufferingByPts_ContinuousDts_NewGopEndOverlapsLastGop_1) { + // API user might craft a continuous-in-DTS-with-previous-append GOP that has + // PTS interval overlapping the previous append. + // Tests SAP-Type-1 GOPs, where newly appended GOP overlaps a nonkeyframe of + // the last GOP appended. + if (range_api_ == ChunkDemuxerStream::RangeApi::kLegacyByDts) { + DVLOG(1) << "Skipping kLegacyByDts versions of this test"; + return; + } + + InSequence s; + AddTestTracks(HAS_VIDEO); + frame_processor_->SetSequenceMode(use_sequence_mode_); + + // Make the sequence mode buffering appear just like segments mode to simplify + // this test case. + if (use_sequence_mode_) + SetTimestampOffset(Milliseconds(100)); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(140))); + EXPECT_TRUE(ProcessFrames("", "100|0K 110|10 120|20 130|30")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(165))); + EXPECT_TRUE(ProcessFrames("", "125|40K 135|50 145|60 155|70")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + CheckExpectedRangesByTimestamp(video_.get(), "{ [100,165) }"); + CheckReadsThenReadStalls(video_.get(), "100 110 120 125 135 145 155"); +} + +TEST_P(FrameProcessorTest, + BufferingByPts_ContinuousDts_NewGopEndOverlapsLastGop_2) { + // API user might craft a continuous-in-DTS-with-previous-append GOP that has + // PTS interval overlapping the previous append. + // Tests SAP-Type 1 GOPs, where newly appended GOP overlaps the keyframe of + // the last GOP appended. + if (range_api_ == ChunkDemuxerStream::RangeApi::kLegacyByDts) { + DVLOG(1) << "Skipping kLegacyByDts versions of this test"; + return; + } + + InSequence s; + AddTestTracks(HAS_VIDEO); + frame_processor_->SetSequenceMode(use_sequence_mode_); + + // Make the sequence mode buffering appear just like segments mode to simplify + // this test case. + if (use_sequence_mode_) + SetTimestampOffset(Milliseconds(100)); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(140))); + EXPECT_TRUE(ProcessFrames("", "100|0K 110|10 120|20K 130|30")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + // TODO(wolenetz): Duration shouldn't be allowed to possibly increase to 140ms + // here. See https://crbug.com/763620. + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(140))); + EXPECT_TRUE(ProcessFrames("", "115|40K 125|50")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + CheckExpectedRangesByTimestamp(video_.get(), "{ [100,135) }"); + CheckReadsThenReadStalls(video_.get(), "100 110 115 125"); +} + +TEST_P(FrameProcessorTest, + BufferingByPts_ContinuousDts_NewSap2GopEndOverlapsLastGop_1) { + // API user might craft a continuous-in-DTS-with-previous-append GOP that has + // PTS interval overlapping the previous append, using SAP Type 2 GOPs. + // Tests SAP-Type 2 GOPs, where newly appended GOP overlaps nonkeyframes of + // the last GOP appended. + if (range_api_ == ChunkDemuxerStream::RangeApi::kLegacyByDts) { + DVLOG(1) << "Skipping kLegacyByDts versions of this test"; + return; + } + + InSequence s; + AddTestTracks(HAS_VIDEO); + frame_processor_->SetSequenceMode(use_sequence_mode_); + + // Make the sequence mode buffering appear just like segments mode to simplify + // this test case. + if (use_sequence_mode_) + SetTimestampOffset(Milliseconds(120)); + + EXPECT_CALL(callbacks_, + OnParseWarning( + SourceBufferParseWarning::kKeyframeTimeGreaterThanDependant)); + EXPECT_MEDIA_LOG(KeyframeTimeGreaterThanDependant("0.12", "0.1")); + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(140))); + EXPECT_TRUE(ProcessFrames("", "120|0K 100|10 130|20 110|30")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(165))); + EXPECT_TRUE(ProcessFrames("", "145|40K 125|50 155|60 135|70")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + CheckExpectedRangesByTimestamp(video_.get(), "{ [120,165) }"); + // TODO(wolenetz): Here, [120,165) should demux continuously without read + // stall in the middle. See https://crbug.com/791095. + CheckReadsThenReadStalls(video_.get(), "120 100 130 110"); + SeekStream(video_.get(), Milliseconds(145)); + CheckReadsThenReadStalls(video_.get(), "145 125 155 135"); +} + +TEST_P(FrameProcessorTest, + BufferingByPts_ContinuousDts_NewSap2GopEndOverlapsLastGop_2) { + // API user might craft a continuous-in-DTS-with-previous-append GOP that has + // PTS interval overlapping the previous append, using SAP Type 2 GOPs. + // Tests SAP-Type 2 GOPs, where newly appended GOP overlaps the keyframe of + // last GOP appended. + if (range_api_ == ChunkDemuxerStream::RangeApi::kLegacyByDts) { + DVLOG(1) << "Skipping kLegacyByDts versions of this test"; + return; + } + + InSequence s; + AddTestTracks(HAS_VIDEO); + frame_processor_->SetSequenceMode(use_sequence_mode_); + + // Make the sequence mode buffering appear just like segments mode to simplify + // this test case. + if (use_sequence_mode_) + SetTimestampOffset(Milliseconds(120)); + + EXPECT_CALL(callbacks_, + OnParseWarning( + SourceBufferParseWarning::kKeyframeTimeGreaterThanDependant)); + EXPECT_MEDIA_LOG(KeyframeTimeGreaterThanDependant("0.12", "0.1")); + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(180))); + EXPECT_TRUE(ProcessFrames( + "", "120|0K 100|10 130|20 110|30 160|40K 140|50 170|60 150|70")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + // TODO(wolenetz): Duration shouldn't be allowed to possibly increase to 180ms + // here. See https://crbug.com/763620. + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(180))); + EXPECT_TRUE(ProcessFrames("", "155|80K 145|90")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + + // Note that this buffered range discontinuity is due to unclarified MSE spec + // around handling this kind of SAP Type 2 sequence. In particular, we don't + // "grow" the [155,165) range start time earlier based on nonkeyframes with + // PTS < the keyframe at 155ms. + CheckExpectedRangesByTimestamp(video_.get(), "{ [120,140) [155,165) }"); + CheckReadsThenReadStalls(video_.get(), "120 100 130 110"); + SeekStream(video_.get(), Milliseconds(155)); + CheckReadsThenReadStalls(video_.get(), "155 145"); +} + +TEST_P(FrameProcessorTest, + BufferingByPts_ContinuousDts_GopKeyframePtsOrder_2_1_3) { + // White-box test, demonstrating expected behavior for a specially crafted + // sequence that "should" be unusual, but gracefully handled: + // SAP-Type 1 GOPs for simplicity of test. First appended GOP is highest in + // timeline. Second appended GOP is earliest in timeline. Third appended GOP + // is continuous in time with highest end time of first appended GOP. The + // result should be a single continuous range containing just the second and + // third appended GOPs (since the first-appended GOP was overlap-removed from + // the timeline due to being in the gap between the second and third appended + // GOPs). Note that MseTrackBuffer::ResetHighestPresentationTimestamp() done + // at the beginning of the second appended GOP is the key to gracefully + // handling the third appended GOP. + if (range_api_ == ChunkDemuxerStream::RangeApi::kLegacyByDts) { + DVLOG(1) << "Skipping kLegacyByDts versions of this test"; + return; + } + + InSequence s; + AddTestTracks(HAS_VIDEO); + frame_processor_->SetSequenceMode(use_sequence_mode_); + + // Make the sequence mode buffering appear just like segments mode to simplify + // this test case. + if (use_sequence_mode_) + SetTimestampOffset(Milliseconds(200)); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(240))); + EXPECT_TRUE(ProcessFrames("", "200|0K 210|10 220|20 230|30")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + CheckExpectedRangesByTimestamp(video_.get(), "{ [200,240) }"); + + // TODO(wolenetz): Duration shouldn't be allowed to possibly increase to 240ms + // here. See https://crbug.com/763620. + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(240))); + EXPECT_TRUE(ProcessFrames("", "100|40K 110|50 120|60 130|70")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + CheckExpectedRangesByTimestamp(video_.get(), "{ [100,140) [200,240) }"); + + EXPECT_CALL(callbacks_, PossibleDurationIncrease(Milliseconds(260))); + EXPECT_TRUE(ProcessFrames("", "240|80K 250|90")); + EXPECT_EQ(Milliseconds(0), timestamp_offset_); + CheckExpectedRangesByTimestamp(video_.get(), "{ [100,260) }"); + + SeekStream(video_.get(), Milliseconds(100)); + CheckReadsThenReadStalls(video_.get(), "100 110 120 130 240 250"); +} + INSTANTIATE_TEST_CASE_P(SequenceModeLegacyByDts, FrameProcessorTest, Values(FrameProcessorTestParams(
diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc index 5d50b25..f3de210 100644 --- a/media/filters/source_buffer_stream.cc +++ b/media/filters/source_buffer_stream.cc
@@ -545,9 +545,6 @@ if (range_for_next_append_ != ranges_.end()) { if (last_appended_buffer_timestamp_ != kNoDecodeTimestamp()) { - DCHECK(RangeBelongsToRange(range_for_next_append_->get(), - last_appended_buffer_timestamp_)); - // Note start and end of last appended GOP. DecodeTimestamp gop_end = highest_timestamp_in_append_sequence_; DecodeTimestamp gop_start = @@ -1317,9 +1314,40 @@ std::min(coded_frame_group_start_time_, buffers_start_timestamp); } - // Return early if no further overlap removal is needed. - if (buffers_start_timestamp >= buffers_end_timestamp) + // Return early if no further overlap removal is needed. When buffering by PTS + // intervals, first check if |buffers_start_timestamp| is in the middle of the + // range; we could be overlap-appending the middle of a previous coded frame + // sequence's range with non-keyframes prior to + // |highest_timestamp_in_append_sequence_|, so we need to split that range + // appropriately here and then return early. If we don't return early here, + // overlap removal (including any necessary range splitting) will occur. + if (buffers_start_timestamp >= buffers_end_timestamp) { + if (!BufferingByPts()) + return; + + DCHECK(highest_timestamp_in_append_sequence_ != kNoDecodeTimestamp()); + DCHECK(range_for_next_append_ != ranges_.end()); + DCHECK(RangeBelongsToRange(range_for_next_append_->get(), + buffers_start_timestamp)); + + // Split the range at |buffers_start_timestamp|, if necessary, then return + // early. + std::unique_ptr<RangeClass> new_range = + RangeSplitRange(range_for_next_append_->get(), buffers_start_timestamp); + if (!new_range) + return; + + range_for_next_append_ = + ranges_.insert(++range_for_next_append_, std::move(new_range)); + + // Update the selected range if the next buffer position was transferred + // to the newly inserted range. + if ((*range_for_next_append_)->HasNextBufferPosition()) + SetSelectedRange(range_for_next_append_->get()); + + --range_for_next_append_; return; + } // Exclude the start from removal to avoid deleting the highest appended // buffer in cases where the first buffer in |new_buffers| has same timestamp @@ -1401,10 +1429,15 @@ bool SourceBufferStream<RangeClass>:: IsNextGopAdjacentToEndOfCurrentAppendSequence( DecodeTimestamp next_gop_timestamp) const { + DecodeTimestamp upper_bound = highest_timestamp_in_append_sequence_ + + ComputeFudgeRoom(GetMaxInterbufferDistance()); + DVLOG(4) << __func__ << " " << GetStreamTypeName() + << " next_gop_timestamp=" << next_gop_timestamp.InMicroseconds() + << "us, highest_timestamp_in_append_sequence_=" + << highest_timestamp_in_append_sequence_.InMicroseconds() + << "us, upper_bound=" << upper_bound.InMicroseconds() << "us"; return highest_timestamp_in_append_sequence_ < next_gop_timestamp && - next_gop_timestamp <= - highest_timestamp_in_append_sequence_ + - ComputeFudgeRoom(GetMaxInterbufferDistance()); + next_gop_timestamp <= upper_bound; } template <typename RangeClass>
diff --git a/media/filters/source_buffer_stream_unittest.cc b/media/filters/source_buffer_stream_unittest.cc index 5fcbc332..886c61a 100644 --- a/media/filters/source_buffer_stream_unittest.cc +++ b/media/filters/source_buffer_stream_unittest.cc
@@ -4643,9 +4643,7 @@ } TEST_P(SourceBufferStreamTest, Audio_SpliceFrame_NoMillisecondSplices) { - EXPECT_MEDIA_LOG( - HasSubstr("Skipping audio splice trimming at PTS=1250us. Found only 250us" - " of overlap, need at least 1000us.")); + EXPECT_MEDIA_LOG(SkippingSpliceTooLittleOverlap(1250, 250)); video_config_ = TestVideoConfig::Invalid(); audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32,
diff --git a/media/renderers/paint_canvas_video_renderer.cc b/media/renderers/paint_canvas_video_renderer.cc index 1f71196..b3cd2d9 100644 --- a/media/renderers/paint_canvas_video_renderer.cc +++ b/media/renderers/paint_canvas_video_renderer.cc
@@ -110,8 +110,8 @@ mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES || mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB); gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); - source_textures[i].fID = gl->CreateAndConsumeTextureCHROMIUM( - mailbox_holder.texture_target, mailbox_holder.mailbox.name); + source_textures[i].fID = + gl->CreateAndConsumeTextureCHROMIUM(mailbox_holder.mailbox.name); source_textures[i].fTarget = mailbox_holder.texture_target; gl->BindTexture(mailbox_holder.texture_target, source_textures[i].fID); @@ -207,8 +207,8 @@ context_3d.gr_context->resetContext(kTextureBinding_GrGLBackendState); } else { gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); - source_texture = gl->CreateAndConsumeTextureCHROMIUM( - mailbox_holder.texture_target, mailbox_holder.mailbox.name); + source_texture = + gl->CreateAndConsumeTextureCHROMIUM(mailbox_holder.mailbox.name); } GrGLTextureInfo source_texture_info; source_texture_info.fID = source_texture; @@ -827,8 +827,8 @@ << mailbox_holder.texture_target; gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); - uint32_t source_texture = gl->CreateAndConsumeTextureCHROMIUM( - mailbox_holder.texture_target, mailbox_holder.mailbox.name); + uint32_t source_texture = + gl->CreateAndConsumeTextureCHROMIUM(mailbox_holder.mailbox.name); // The video is stored in a unmultiplied format, so premultiply // if necessary. @@ -899,7 +899,6 @@ mailbox_holder.texture_target = texture_info->fTarget; canvas_gl->GenMailboxCHROMIUM(mailbox_holder.mailbox.name); canvas_gl->ProduceTextureDirectCHROMIUM(texture_info->fID, - mailbox_holder.texture_target, mailbox_holder.mailbox.name); // Wait for mailbox creation on canvas context before consuming it and @@ -913,7 +912,7 @@ mailbox_holder.sync_token.GetConstData()); uint32_t intermediate_texture = destination_gl->CreateAndConsumeTextureCHROMIUM( - mailbox_holder.texture_target, mailbox_holder.mailbox.name); + mailbox_holder.mailbox.name); destination_gl->CopyTextureCHROMIUM(intermediate_texture, 0, target, texture, level, internal_format, type,
diff --git a/media/renderers/video_overlay_factory.cc b/media/renderers/video_overlay_factory.cc index 6f5ff3b2..99087698 100644 --- a/media/renderers/video_overlay_factory.cc +++ b/media/renderers/video_overlay_factory.cc
@@ -38,8 +38,7 @@ gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); gl->GenMailboxCHROMIUM(mailbox_.name); - gl->ProduceTextureDirectCHROMIUM(texture_id_, GL_TEXTURE_2D, - mailbox_.name); + gl->ProduceTextureDirectCHROMIUM(texture_id_, mailbox_.name); const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); gl->ShallowFlushCHROMIUM();
diff --git a/media/video/gpu_memory_buffer_video_frame_pool.cc b/media/video/gpu_memory_buffer_video_frame_pool.cc index 10e7b458..81bfada 100644 --- a/media/video/gpu_memory_buffer_video_frame_pool.cc +++ b/media/video/gpu_memory_buffer_video_frame_pool.cc
@@ -822,7 +822,8 @@ gles2->TexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gles2->TexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gles2->GenMailboxCHROMIUM(plane_resource.mailbox.name); - gles2->ProduceTextureCHROMIUM(texture_target, plane_resource.mailbox.name); + gles2->ProduceTextureDirectCHROMIUM(plane_resource.texture_id, + plane_resource.mailbox.name); } return frame_resources; }
diff --git a/ppapi/proxy/compositor_layer_resource.cc b/ppapi/proxy/compositor_layer_resource.cc index ae6bcd5..40af6982 100644 --- a/ppapi/proxy/compositor_layer_resource.cc +++ b/ppapi/proxy/compositor_layer_resource.cc
@@ -164,8 +164,7 @@ gl->GenMailboxCHROMIUM( reinterpret_cast<GLbyte*>(data_.texture->mailbox.name)); gl->ProduceTextureDirectCHROMIUM( - texture, target, - reinterpret_cast<const GLbyte*>(data_.texture->mailbox.name)); + texture, reinterpret_cast<const GLbyte*>(data_.texture->mailbox.name)); // Set the source size to (1, 1). It will be used to verify the source_rect // passed to SetSourceRect().
diff --git a/ppapi/proxy/video_decoder_resource.cc b/ppapi/proxy/video_decoder_resource.cc index 495d257..2a212ce 100644 --- a/ppapi/proxy/video_decoder_resource.cc +++ b/ppapi/proxy/video_decoder_resource.cc
@@ -405,8 +405,8 @@ NULL); } if (!mailboxes.empty()) { - gles2_impl_->ProduceTextureCHROMIUM( - GL_TEXTURE_2D, reinterpret_cast<const GLbyte*>(mailboxes[i].name)); + gles2_impl_->ProduceTextureDirectCHROMIUM( + texture_ids[i], reinterpret_cast<const GLbyte*>(mailboxes[i].name)); } textures_.insert(
diff --git a/services/network/DEPS b/services/network/DEPS index 8fa9d48..88c57e9 100644 --- a/services/network/DEPS +++ b/services/network/DEPS
@@ -1,3 +1,4 @@ include_rules = [ + "+ipc", "+net", ]
diff --git a/services/network/public/cpp/BUILD.gn b/services/network/public/cpp/BUILD.gn index 7dc3fa5..b9d0231 100644 --- a/services/network/public/cpp/BUILD.gn +++ b/services/network/public/cpp/BUILD.gn
@@ -12,6 +12,8 @@ "mutable_partial_network_traffic_annotation_tag_struct_traits.h", "net_adapters.cc", "net_adapters.h", + "ssl_info_ipc_traits.cc", + "ssl_info_ipc_traits.h", "url_loader_completion_status.cc", "url_loader_completion_status.h", ] @@ -22,6 +24,7 @@ deps = [ "//base", + "//ipc", "//mojo/common", "//net", ]
diff --git a/services/network/public/cpp/OWNERS b/services/network/public/cpp/OWNERS index 2c44a46..26c7416 100644 --- a/services/network/public/cpp/OWNERS +++ b/services/network/public/cpp/OWNERS
@@ -1,5 +1,7 @@ per-file *.mojom=set noparent per-file *.mojom=file://ipc/SECURITY_OWNERS +per-file *_ipc_traits*.*=set noparent +per-file *_ipc_traits*.*=file://ipc/SECURITY_OWNERS per-file *_struct_traits*.*=set noparent per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS per-file *.typemap=set noparent
diff --git a/services/network/public/cpp/ssl_info_ipc_traits.cc b/services/network/public/cpp/ssl_info_ipc_traits.cc new file mode 100644 index 0000000..b616dc44 --- /dev/null +++ b/services/network/public/cpp/ssl_info_ipc_traits.cc
@@ -0,0 +1,166 @@ +// Copyright 2017 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 "services/network/public/cpp/ssl_info_ipc_traits.h" + +#include "ipc/ipc_message_utils.h" + +namespace IPC { + +namespace { + +void WriteCert(base::Pickle* m, net::X509Certificate* cert) { + WriteParam(m, !!cert); + if (cert) + cert->Persist(m); +} + +bool ReadCert(const base::Pickle* m, + base::PickleIterator* iter, + scoped_refptr<net::X509Certificate>* cert) { + DCHECK(!*cert); + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (!has_object) + return true; + *cert = net::X509Certificate::CreateFromPickle(iter); + return !!cert->get(); +} + +} // namespace + +void ParamTraits<net::HashValue>::Write(base::Pickle* m, const param_type& p) { + WriteParam(m, p.ToString()); +} + +bool ParamTraits<net::HashValue>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { + std::string str; + return ReadParam(m, iter, &str) && r->FromString(str); +} + +void ParamTraits<net::HashValue>::Log(const param_type& p, std::string* l) { + l->append("<HashValue>"); +} + +void ParamTraits<net::SSLInfo>::Write(base::Pickle* m, const param_type& p) { + WriteParam(m, p.is_valid()); + if (!p.is_valid()) + return; + WriteCert(m, p.cert.get()); + WriteCert(m, p.unverified_cert.get()); + WriteParam(m, p.cert_status); + WriteParam(m, p.security_bits); + WriteParam(m, p.key_exchange_group); + WriteParam(m, p.connection_status); + WriteParam(m, p.is_issued_by_known_root); + WriteParam(m, p.pkp_bypassed); + WriteParam(m, p.client_cert_sent); + WriteParam(m, p.channel_id_sent); + WriteParam(m, p.token_binding_negotiated); + WriteParam(m, p.token_binding_key_param); + WriteParam(m, p.handshake_type); + WriteParam(m, p.public_key_hashes); + WriteParam(m, p.pinning_failure_log); + WriteParam(m, p.signed_certificate_timestamps); + WriteParam(m, p.ct_policy_compliance); + WriteParam(m, p.ocsp_result.response_status); + WriteParam(m, p.ocsp_result.revocation_status); +} + +bool ParamTraits<net::SSLInfo>::Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { + bool is_valid = false; + if (!ReadParam(m, iter, &is_valid)) + return false; + if (!is_valid) + return true; + return ReadCert(m, iter, &r->cert) && + ReadCert(m, iter, &r->unverified_cert) && + ReadParam(m, iter, &r->cert_status) && + ReadParam(m, iter, &r->security_bits) && + ReadParam(m, iter, &r->key_exchange_group) && + ReadParam(m, iter, &r->connection_status) && + ReadParam(m, iter, &r->is_issued_by_known_root) && + ReadParam(m, iter, &r->pkp_bypassed) && + ReadParam(m, iter, &r->client_cert_sent) && + ReadParam(m, iter, &r->channel_id_sent) && + ReadParam(m, iter, &r->token_binding_negotiated) && + ReadParam(m, iter, &r->token_binding_key_param) && + ReadParam(m, iter, &r->handshake_type) && + ReadParam(m, iter, &r->public_key_hashes) && + ReadParam(m, iter, &r->pinning_failure_log) && + ReadParam(m, iter, &r->signed_certificate_timestamps) && + ReadParam(m, iter, &r->ct_policy_compliance) && + ReadParam(m, iter, &r->ocsp_result.response_status) && + ReadParam(m, iter, &r->ocsp_result.revocation_status); +} + +void ParamTraits<net::SSLInfo>::Log(const param_type& p, std::string* l) { + l->append("<SSLInfo>"); +} + +void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Write( + base::Pickle* m, + const param_type& p) { + WriteParam(m, p.get() != nullptr); + if (p.get()) + p->Persist(m); +} + +bool ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Read( + const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { + bool has_object; + if (!ReadParam(m, iter, &has_object)) + return false; + if (has_object) + *r = net::ct::SignedCertificateTimestamp::CreateFromPickle(iter); + return true; +} + +void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Log( + const param_type& p, + std::string* l) { + l->append("<SignedCertificateTimestamp>"); +} + +} // namespace IPC + +// Generation of IPC definitions. + +// Generate constructors. +#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#include "ipc/struct_constructor_macros.h" +#include "ssl_info_ipc_traits.h" + +// Generate destructors. +#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#include "ipc/struct_destructor_macros.h" +#include "ssl_info_ipc_traits.h" + +// Generate param traits write methods. +#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#include "ssl_info_ipc_traits.h" +} // namespace IPC + +// Generate param traits read methods. +#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#include "ssl_info_ipc_traits.h" +} // namespace IPC + +// Generate param traits log methods. +#undef SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#include "ssl_info_ipc_traits.h" +} // namespace IPC
diff --git a/services/network/public/cpp/ssl_info_ipc_traits.h b/services/network/public/cpp/ssl_info_ipc_traits.h new file mode 100644 index 0000000..c3fdafdf --- /dev/null +++ b/services/network/public/cpp/ssl_info_ipc_traits.h
@@ -0,0 +1,83 @@ +// Copyright 2017 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 SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#define SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ + +#include <string> + +#include "base/pickle.h" +#include "ipc/ipc_param_traits.h" +#include "ipc/param_traits_macros.h" +#include "net/cert/ct_policy_status.h" +#include "net/cert/signed_certificate_timestamp.h" +#include "net/cert/signed_certificate_timestamp_and_status.h" +#include "net/ssl/ssl_info.h" + +#ifndef INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ +#define INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ + +// services/network/public/cpp is currently packaged as a static library, +// so there's no need for export defines; it's linked directly into whatever +// other components need it. +// This redefinition is present for the IPC macros below. +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT + +namespace IPC { + +template <> +struct ParamTraits<net::HashValue> { + typedef net::HashValue param_type; + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<net::SSLInfo> { + typedef net::SSLInfo param_type; + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +template <> +struct ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> { + typedef scoped_refptr<net::ct::SignedCertificateTimestamp> param_type; + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); + static void Log(const param_type& p, std::string* l); +}; + +} // namespace IPC + +#endif // INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_ + +IPC_ENUM_TRAITS_MAX_VALUE( + net::ct::CTPolicyCompliance, + net::ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE) +IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPVerifyResult::ResponseStatus, + net::OCSPVerifyResult::PARSE_RESPONSE_DATA_ERROR) +IPC_ENUM_TRAITS_MAX_VALUE(net::OCSPRevocationStatus, + net::OCSPRevocationStatus::UNKNOWN) + +IPC_ENUM_TRAITS_MAX_VALUE(net::ct::SCTVerifyStatus, net::ct::SCT_STATUS_MAX) + +IPC_ENUM_TRAITS_MAX_VALUE(net::SSLInfo::HandshakeType, + net::SSLInfo::HANDSHAKE_FULL) +IPC_ENUM_TRAITS_MAX_VALUE(net::TokenBindingParam, net::TB_PARAM_ECDSAP256) + +IPC_STRUCT_TRAITS_BEGIN(net::SignedCertificateTimestampAndStatus) + IPC_STRUCT_TRAITS_MEMBER(sct) + IPC_STRUCT_TRAITS_MEMBER(status) +IPC_STRUCT_TRAITS_END() + +#endif // SERVICES_NETWORK_PUBLIC_CPP_SSL_INFO_IPC_TRAITS_H_
diff --git a/styleguide/c++/c++-dos-and-donts.md b/styleguide/c++/c++-dos-and-donts.md new file mode 100644 index 0000000..7496169 --- /dev/null +++ b/styleguide/c++/c++-dos-and-donts.md
@@ -0,0 +1,633 @@ +# C++ Dos and Don'ts + +## A Note About Usage + +Unlike the style guide, the content of this page is advisory, not required. You +can always deviate from something on this page, if the relevant +author/reviewer/OWNERS agree that another course is better. + + +## Minimize Code in Headers + +### Don't include unneeded headers + +If a file isn't using the symbols from some header, remove the header. It turns +out that this happens frequently in the Chromium codebase due to refactoring. + +### Move inner classes into the implementation + +You can also forward declare classes inside a class: + +```cpp +class Whatever { + public: + /* ... */ + private: + struct DataStruct; + std::vector<DataStruct> data_; +}; +``` + +Any headers that DataStruct needed no longer need to be included in the header +file and only need to be included in the implementation. This will often let you +pull includes out of the header. For reference, the syntax in the implementation +file is: + +```cpp +struct Whatever::DataStruct { +}; +``` + +Note that sometimes you can't do this because certain STL data structures +require the full definition at declaration time (most notably, std::deque and +the STL adapters that wrap it). + +### Move static implementation details to the implementation whenever possible + +If you have the class in a header file, you should try to move that from a class +member into the anonymous namespace in the implementation file: + +DON'T: + +```cpp +#include "BigImplementationDetail.h" +class PublicInterface { + public: + /* ... */ + private: + static BigImplementationDetail detail_; +}; +``` + +DO: + +```cpp +namespace { +BigImplementationDetail g_detail; +} // namespace +``` + +That way, people who don't use your interface don't need to know about or care +about `BigImplementationDetail`. + +You can do this for helper functions, too. Note that if there is more than one +class in the .cc file, it can aid clarity to define your file-scope helpers in +an anonymous namespace just above the class that uses them, instead of at the +top of the file. + +## Stop inlining code in headers + +*** note +**BACKGROUND**: Unless something is a cheap accessor or you truly need it to be +inlined, don't ask for it to be inlined. Remember that definitions inside class +declarations are implicitly requested to be inlined. +*** + +DON'T: + +```cpp +class InlinedMethods { + InlinedMethods() { + // This constructor is equivalent to having the inline keyword in front + // of it! + } + void Method() { + // Same here! + } +}; +``` + +### Stop inlining complex methods. + +DON'T: + +```cpp +class DontDoThis { + public: + int ComputeSomething() { + int sum = 0; + for (int i = 0; i < limit; ++i) { + sum += OtherMethod(i, ... ); + } + return sum; + } +}; +``` + +A request to inline is merely a suggestion to the compiler, and anything more +than a few operations on integral data types will probably not be inlined. +However, every file that has to use an inline method will also emit a function +version in the resulting .o, even if the method was inlined. (This is to support +function pointer behavior properly.) Therefore, by requesting an inline in this +case, you're likely just adding crud to the .o files which the linker will need +to do work to resolve. + +If the method has significant implementation, there's also a good chance that by +not inlining it, you could eliminate some includes. + +### Stop inlining virtual methods + +You can't inline virtual methods under most circumstances, even if the method +would otherwise be inlined because it's very short. The compiler must do runtime +dispatch on any virtual method where the compiler doesn't know the object's +complete type, which rules out the majority of cases where you have an object. + +### Stop inlining constructors and destructors + +Constructors and destructors are often significantly more complex than you think +they are, especially if your class has any non-POD data members. Many STL +classes have inlined constructors/destructors which may be copied into your +function body. Because the bodies of these appear to be empty, they often seem +like trivial functions that can safely be inlined. Don't give in to this +temptation. Define them in the implementation file unless you really _need_ +them to be inlined. Even if they do nothing now, someone could later add +something seemingly-trivial to the class and make your hundreds of inlined +destructors much more complex. + +Even worse, inlining constructors/destructors prevents you from using forward +declared variables: + +DON'T: + +```cpp +class Forward; +class WontCompile { + public: + // THIS WON'T COMPILE, BUT IT WOULD HAVE IF WE PUT THESE IN THE + // IMPLEMENTATION FILE! + // + // The compiler needs the definition of Forward to call the + // vector/scoped_ptr ctors/dtors. + Example() { } + ~Example() { } + + private: + std::vector<Forward> examples_; + scoped_ptr<Forward> super_example_; +}; +``` + +For more information, read Item 30 in Effective C++. + +### When you CAN inline constructors and destructors + +C++ has the concept of a +[trivial destructor](http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc15cplr380.htm). +If your class has only POD types and does not explicitly declare a destructor, +then the compiler will not bother to generate or run a destructor. + +```cpp +struct Data { + Data() : count_one(0), count_two(0) {} + // No explicit destructor, thus no implicit destructor either. + + // The members must all be POD for this trick to work. + int count_one; + int count_two; +}; +``` + +In this example, since there is no inheritance and only a few POD members, the +constructor will be only a few trivial integer operations, and thus OK to +inline. + +For abstract base classes with no members, it's safe to define the (trivial) +destructor inline: + +```cpp +class Interface { + public: + virtual ~Interface() {} + + virtual void DoSomething(int parameter) = 0; + virtual int GetAValue() = 0; +}; +``` +But be careful; these two "interfaces" don't count: + +DON'T: + +```cpp +class ClaimsToBeAnInterface : public base::RefCounted<ClaimsToBeAnInterface> { + public: + virtual ~ClaimsToBeAnInterface() { /* But derives from a template! */ } +}; + +class HasARealMember { + public: + virtual void InterfaceMethod() = 0; + virtual ~HasARealMember() {} + + protected: + vector<string> some_data_; +}; +``` + +If in doubt, don't rely on these sorts of exceptions. Err on the side of not +inlining. + +### Be careful about your accessors + +Not all accessors are light weight. Compare: + +```cpp +class Foo { + public: + int count() const { return count_; } + + private: + int count_; +}; +``` + +Here the accessor is trivial and safe to inline. But the following code is +probably not, even though it also looks simple: + +DON'T: + +```cpp +struct MyData { + vector<GURL> urls_; + base::Time last_access_; +}; + +class Manager { + public: + MyData get_data() { return my_data_; } + + private: + MyData my_data_; +}; +``` + +The underlying copy constructor calls for MyData are going to be complex. (Also, +they're going to be synthesized, which is bad.) + +### What about code outside of headers? + +For classes declared in .cc files, there's no risk of bloating several .o files +with the definitions of the same "inlined" function. While there are other, +weaker arguments to continue to avoid inlining, the primary remaining +consideration is simply what would make code most readable. + +This is especially true in testing code. Test framework classes don't tend to +be instantiated separately and passed around as objects; they're effectively +just bundles of file-scope functionality coupled with a mechanism to reset state +between tests. In these cases, defining the test functions inline at their +declaration sites has little negative effect and can reduce the amount of +"boilerplate" in the test file. + +Different reviewers may have different opinions here; use good judgment. + +## Static variables + +Dynamic initialization of function-scope static variables is now thread**safe** +in Chromium (per standard C++11 behavior). Before 2017, this was thread- +unsafe, and base::LazyInstance was widely used. This is no longer necessary. +Background can be found in this +[thread](https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/p6h3HC8Wro4/HHBMg7fYiMYJ) +and this +[thread](https://groups.google.com/a/chromium.org/d/topic/cxx/j5rFewBzSBQ/discussion). + +```cpp +void foo() { + static int ok_count = ComputeTheCount(); // OK now, previously a problem. + static int good_count = 42; // C++03 3.6.2 says this is done before dynamic initialization, so probably thread-safe. + static constexpr int better_count = 42; // Even better, as this will now likely be inlined at compile time. + static auto& object = *new Object; // For class types. +} +``` + +## Variable initialization + +There are myriad ways to initialize variables in C++11. Prefer the following +general rules: + +1. Use assignment syntax when performing "simple" initialization with one or + more literal values which will simply be composed into the object: + + ```cpp + int i = 1; + std::string s = "Hello"; + std::pair<bool, double> p = {true, 2.0}; + std::vector<std::string> v = {"one", "two", "three"}; + ``` + + Using '=' here is no less efficient than "()" (the compiler won't generate a + temp + copy), and ensures that only implicit constructors are called, so + readers seeing this syntax can assume nothing complex or subtle is + happening. Note that "{}" are allowed on the right side of the '=' here + (e.g. when you're merely passing a set of initial values to a "simple" + struct/ container constructor; see below items for contrast). + +2. Use constructor syntax when construction performs significant logic, uses an + explicit constructor, or in some other way is not intuitively "simple" to the + reader: + + ```cpp + MyClass c(1.7, false, "test"); + std::vector<double> v(500, 0.97); // Creates 50 copies of the provided initializer + ``` + +3. Use C++11 "uniform init" syntax ("{}" without '=') only when neither of the + above work: + + ```cpp + class C { + public: + explicit C(bool b) { ... }; + ... + }; + class UsesC { + ... + private: + C c{true}; // Cannot use '=' since C() is explicit (and "()" is invalid syntax here) + }; + class Vexing { + public: + explicit Vexing(const std::string& s) { ... }; + ... + }; + void func() { + Vexing v{std::string()}; // Using "()" here triggers "most vexing parse"; + // "{}" is arguably more readable than "(())" + ... + } + ``` + +4. Never mix uniform init syntax with auto, since what it deduces is unlikely + to be what was intended: + + ```cpp + auto x{1}; // Until C++17, decltype(x) is std::initializer_list<int>, not int! + ``` + +## Prefer `MakeUnique` to `WrapUnique` + +[`base::MakeUnique`](https://cs.chromium.org/chromium/src/base/memory/ptr_util.h?q=MakeUnique)`<Type>(...)` +and +[`base::WrapUnique`](https://cs.chromium.org/chromium/src/base/memory/ptr_util.h?q=WrapUnique)`(new Type(...))` +are equivalent. +`MakeUnique` should be preferred, because it is harder to use unsafely than +`WrapUnique`. In general, bare calls to `new` require careful scrutiny. Bare +calls to `new` are currently required to construct reference-counted types; +however, reference counted types themselves require careful scrutiny. + +```cpp +return std::unique_ptr<C>(new C(1, 2, 3)); // BAD: type name mentioned twice +return base::WrapUnique(new C(1, 2, 3)); // BAD: bare call to new +return base::MakeUnique<C>(1, 2, 3); // GOOD +``` + +**Notes:** + +1. Never friend `MakeUnique` to work around constructor access restrictions. It + will allow anyone to construct the class. Use `WrapUnique` in this case. + + DON'T: + ```cpp + class Bad { + public: + std::unique_ptr<Bad> Create() { return base::MakeUnique<Bad>(); } + // ... + private: + Bad(); + // ... + friend std::unique_ptr<Bad> base::MakeUnique<Bad>(); // Lost access control + }; + ``` + + DO: + ```cpp + class Okay { + public: + // For explanatory purposes. If Create() adds no value, it is better just + // to have a public constructor instead. + std::unique_ptr<Okay> Create() { return base::WrapUnique(new Okay()); } + // ... + private: + Okay(); + // ... + }; + ``` + +2. `WrapUnique(new Foo)` and `WrapUnique(new Foo())` mean something different if + `Foo` does not have a user-defined constructor. Don't make future maintainers + guess whether you left off the '()' on purpose. Use `MakeUnique<Foo>()` + instead. If you're intentionally leaving off the "()" as an optimisation, + please leave a comment. + + ```cpp + auto a = base::WrapUnique(new A); // BAD: "()" omitted intentionally? + auto a = base::MakeUnique<A>(); // GOOD + // "()" intentionally omitted to avoid unnecessary zero-initialisation. + // WrapUnique() does the wrong thing for array pointers. + auto array = std::unique_ptr<A[]>(new A[size]); + ``` + +## Do not use `auto` to deduce a raw pointer + +The use of the `auto` keyword to deduce the type from the initializing +expression is encouraged when it improves readability. However, do not use +`auto` when the type would be deduced to be a pointer type. This can cause +confusion. Instead, prefer specifying the "pointer" part outside of `auto`: + +```cpp +auto item = new Item(); // BAD: auto deduces to Item*, type of |item| is Item* +auto* item = new Item(); // GOOD: auto deduces to Item, type of |item| is Item* +``` + +## Use `const` correctly + +*** promo +**TLDR:** For safety and simplicity, **don't return pointers or references to +non-const objects from const methods**. Within that constraint, **mark methods +as const where possible**. **Avoid `const_cast` to remove const**, except when +implementing non-const getters in terms of const getters. +*** + +### A brief primer on const + +To the compiler, the `const` qualifier on a method refers to _physical +constness_: calling this method does not change the bits in this object. What +we want is _logical constness_, which is only partly overlapping: calling this +method does not affect the object in ways callers will notice, nor does it give +you a handle with the ability to do so. + +Mismatches between these concepts can occur in both directions. When something +is logically but not physically const, C++ provides the `mutable` keyword to +silence compiler complaints. This is valuable for e.g. cached calculations, +where the cache is an implementation detail callers do not care about. When +something is physically but not logically const, however, the compiler will +happily accept it, and there are no tools that will automatically save you. +This discrepancy usually involves pointers. For example, + +```cpp +void T::Cleanup() const { delete pointer_member_; } +``` + +Deleting a member is a change callers are likely to care about, so this is +probably not logically const. But because `delete` does not affect the pointer +itself, but only the memory it points to, this code is physically const, so it +will compile. + +Or, more subtly, consider this pseudocode from a node in a tree: + +```cpp +class Node { + public: + void RemoveSelf() { parent_->RemoveChild(this); } + void RemoveChild(Node* node) { + if (node == left_child_) + left_child_ = nullptr; + else if (node == right_child_) + right_child_ = nullptr; + } + Node* left_child() const { return left_child_; } + Node* right_child() const { return right_child_; } + + private: + Node* parent_; + Node* left_child_; + Node* right_child_; +}; +``` + +The `left_child()` and `right_child()` methods don't change anything about +`|this|`, so making them `const` seems fine. But they allow code like this: + +```cpp +void SignatureAppearsHarmlessToCallers(const Node& node) { + node.left_child()->RemoveSelf(); + // Now |node| has no |left_child_|, despite having been passed in by const ref. +} +``` + +The original class definition compiles, and looks locally fine, but it's a +timebomb: a const method returning a handle that can be used to change the +system in ways that affect the original object. Eventually, someone will +actually modify the object, potentially far away from where the handle is +obtained. + +These modifications can be difficult to spot in practice. As we see in the +previous example, splitting related concepts or state (like "a tree") across +several objects means a change to one object affects the behavior of others. +And if this tree is in turn referred to by yet more objects (e.g. the DOM of a +web page, which influences all sorts of other data structures relating to the +page), then small changes can have visible ripples across the entire system. In +a codebase as complex as Chromium, it can be almost impossible to reason about +what sorts of local changes could ultimately impact the behavior of distant +objects, and vice versa. + +"Logically const correct" code assures readers that const methods will not +change the system, directly or indirectly, nor allow callers to easily do so. +They make it easier to reason about large-scale behavior. But since the +compiler verifies physical constness, it will not guarantee that code is +actually logically const. Hence the recommendations here. + +### Classes of const (in)correctness + +In a +[larger discussion of this issue](https://groups.google.com/a/chromium.org/d/topic/platform-architecture-dev/C2Szi07dyQo/discussion), +Matt Giuca +[postulated three classes of const(in)correctness](https://groups.google.com/a/chromium.org/d/msg/platform-architecture-dev/C2Szi07dyQo/lbHMUQHMAgAJ): + +* **Const correct:** All code marked "const" is logically const; all code that + is logically const is marked "const". +* **Const okay:** All code marked "const" is logically const, but not all code + that is logically const is marked "const". (Basically, if you see "const" you + can trust it, but sometimes it's missing.) +* **Const broken:** Some code marked "const" is not logically const. + +The Chromium codebase currently varies. A significant amount of Blink code is +"const broken". A great deal of Chromium code is "const okay". A minority of +code is "const correct". + +While "const correct" is ideal, it can take a great deal of work to achieve. +Const (in)correctness is viral, so fixing one API often requires a yak shave. +(On the plus side, this same property helps prevent regressions when people +actually use const objects to access the const APIs.) + +At the least, strive to convert code that is "const broken" to be "const okay". +A simple rule of thumb that will prevent most cases of "const brokenness" is for +const methods to never return pointers to non-const objects. This is overly +conservative, but less than you might think, due to how objects can transitively +affect distant, seemingly-unrelated parts of the system. The discussion thread +linked above has more detail, but in short, it's hard for readers and reviewers +to prove that returning pointers-to-non-const is truly safe, and will stay safe +through later refactorings and modifications. Following this rule is easier +than debating about whether individual cases are exceptions. + +One way to ensure code is "const okay" would be to never mark anything const. +This is suboptimal for the same reason we don't choose to "never write comments, +so they can never be wrong". Marking a method "const" provides the reader +useful information about the system behavior. Also, despite physical constness +being different than logical constness, using "const" correctly still does catch +certain classes of errors at compile time. Accordingly, the +[Google style guide requests the use of const where possible](http://google.github.io/styleguide/cppguide.html#Use_of_const), +so mark methods const when they are logically const. + +Making code more const correct leads to cases where duplicate const and non-const getters are required: + +```cpp +const T* Foo::GetT() const { return t_; } +T* Foo::GetT() { return t_; } +``` + +If the implementation of GetT() is complex, there's a +[trick to implement the non-const getter in terms of the const one](https://stackoverflow.com/questions/123758/how-do-i-remove-code-duplication-between-similar-const-and-non-const-member-func/123995#123995), +courtesy of _Effective C++_: + +```cpp +T* Foo::GetT() { return const_cast<T*>(static_cast<const Foo*>(this)->GetT()); } +``` + +While this is a mouthful, it does guarantee the implementations won't get out of +sync and no const-incorrectness will occur. And once you've seen it a few times, +it's a recognizable pattern. + +This is probably the only case where you should see `const_cast` used to remove +constness. Its use anywhere else is generally indicative of either "const +broken" code, or a boundary between "const correct" and "const okay" code that +could change to "const broken" at any future time without warning from the +compiler. Both cases should be fixed. + + +## Prefer to use `=default` + +Use `=default` to define special member functions where possible, even if the +default implementation is just {}. Be careful when defaulting move operations. +Moved-from objects must be in a valid but unspecified state, i.e., they must +satisfy the class invariants, and the default implementations may not achieve +this. + +```cpp +class Good { + public: + // We can, and usually should, provide the default implementation separately + // from the declaration. + Good(); + + // Use =default here for consistency, even though the implementation is {}. + ~Good() = default; + Good(const Good& other) = default; + + private: + std::vector<int> v_; +}; + +Good::Good() = default; +``` + +### What are the advantages of `=default?`? + +* Compiler-defined copy and move operations don't need maintenance every time + members are added or removed. +* Compiler-provided special member functions can be "trivial" (if defaulted in + the class), and can be better optimized by the compiler and library. +* Types with defaulted constructors can be aggregates (if defaulted in the + class), and hence support aggregate initialization. User provided constructors + disqualify a class from being an aggregate. +* Defaulted functions are constexpr if the implicit version would have been (and + if defaulted in the class). +* Using `=default` consistently helps readers identify customized operations.
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 0934855f..0b8aae1b 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -4,11 +4,6 @@ "all" ] }, - "Android Builder Goma Canary (dbg)": { - "additional_compile_targets": [ - "all" - ] - }, "Android VR Tests": { "gtest_tests": [ { @@ -1148,68 +1143,6 @@ } ] }, - "ChromeOS amd64 Chromium Goma Canary": { - "additional_compile_targets": [ - "chromiumos_preflight" - ] - }, - "Chromium Linux Goma Canary": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "Chromium Linux Goma Canary (clobber)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "Chromium Linux Goma Canary LocalOutputCache": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, "Chromium Mac 10.10 MacViews": { "gtest_tests": [ { @@ -2360,101 +2293,6 @@ } ] }, - "Chromium Mac 10.9 Goma Canary": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "Chromium Mac 10.9 Goma Canary (clobber)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "Chromium Mac 10.9 Goma Canary (dbg)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "Chromium Mac 10.9 Goma Canary (dbg)(clobber)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "Chromium Mac Goma Canary LocalOutputCache": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, "Chromium Win 10 GCE Tests": { "gtest_tests": [ { @@ -2936,63 +2774,6 @@ } ] }, - "CrWin7Goma": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "CrWin7Goma(dbg)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "CrWin7Goma(dll)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, "CrWinAsan tester": { "gtest_tests": [ { @@ -3772,101 +3553,6 @@ } ] }, - "CrWinClangGoma": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "CrWinClexeGoma": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "CrWinGoma": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "CrWinGoma(dll)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, - "CrWinGoma(loc)": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, "Fuchsia": { "additional_compile_targets": [ "gn_all" @@ -7058,25 +6744,6 @@ } ] }, - "ToTWin Goma Canary": { - "additional_compile_targets": [ - "all" - ], - "gtest_tests": [ - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "base_unittests" - }, - { - "swarming": { - "can_use_on_swarming_builders": true - }, - "test": "content_unittests" - } - ] - }, "UBSanVptr Linux": { "gtest_tests": [ {
diff --git a/testing/buildbot/filters/fuchsia.net_unittests.filter b/testing/buildbot/filters/fuchsia.net_unittests.filter index 74794b81..9f37d9c 100644 --- a/testing/buildbot/filters/fuchsia.net_unittests.filter +++ b/testing/buildbot/filters/fuchsia.net_unittests.filter
@@ -17,3 +17,6 @@ # Flaky, https://crbug.com/784448. -DiskCacheBackendTest.InvalidEntry5 + +# New test, which fails under Fuchsia. http://crbug.com/792300 +-HTTPSCRLSetTest.CRLSetRevokedBySubject
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/delete-temp-file.cgi b/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/delete-temp-file.cgi deleted file mode 100755 index 1b49eaf..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/delete-temp-file.cgi +++ /dev/null
@@ -1,141 +0,0 @@ -#!/usr/bin/perl -wT -# -# delete-temp-file.cgi - deletes a file and its temporary subdirectory -# -# The file's fully-qualified file path is passed in the filename query -# parameter. -# -# The file must have been previously created using -# write-temp-file.cgi, which creates files with test-chosen basenames -# inside random-named subdirectories of a system temporary directory, -# e.g. /tmp/LayoutTests_cgiXXXXX/name-chosen-by-test.txt or -# %LOCALAPPDATA%\Temp\cgiXXXXX\name-chosen-by-test.txt where XXXXX are -# random characters varying per write-temp-file.cgi run. -# -# Must be called using the HTTP POST method. -# -# Any output other than the string "OK" is an error message and -# indicates failure. -# -# Errors are redirected to stdout and UTF-8 encoded to aid diagnostics -# in the calling test suite. -# -# NOTE: "ACP" in this CGI refers to the Windows concept of "ANSI" -# Codepage, a (not actually ANSI-standardized) single- or double-byte -# non-Unicode ASCII-compatible character encoding used for some -# narrow-character Win32 APIs. It should not be confused with UTF-8 -# (used for similar purposes on Linux, OS X, and other modern -# POSIX-like systems), nor with the usually-distinct OEM codepage -# used for other narrow-character Win32 APIs (for instance, console -# I/O and some filesystem data storage.) - -use strict; -use warnings FATAL => 'all'; -use CGI qw(-oldstyle_urls); -use Encode qw(encode decode); -use File::Basename qw(basename dirname); -use File::Spec::Functions qw(tmpdir); -use utf8; - -my $win32 = eval 'use Win32; 1' ? 1 : 0; - -open STDERR, '>&STDOUT'; # let the test see die() output -binmode STDOUT, ':encoding(utf-8)'; -autoflush STDOUT 1; -autoflush STDERR 1; -print "content-type: text/plain; charset=utf-8\n\n"; - -# tmpdir() does not read environment variables in taint mode. -my $system_tmpdir = $ENV{TMPDIR} || $ENV{TEMP} || tmpdir(); -$system_tmpdir =~ /\A([^\0- ]*)\z/s - or die "untaint failed: $!"; -$system_tmpdir = $1; -if ($win32) { - $system_tmpdir = Win32::GetANSIPathName($system_tmpdir); - # Drive+directory path equality checks are performed in the 8.3 - # "shortname" space (and case-insensitively) to decrease the - # likelihood of a false negative. - # - # ACP APIs return 8.3 names for some of the inputs currently used in - # tests. - $system_tmpdir = Win32::GetShortPathName($system_tmpdir); -} - -my $req = CGI->new; -if (uc 'post' ne $req->request_method) { - die 'Wrong method: ' . $req->request_method; -} - -# $file_path is a UTF-8-encoded representation of the "ACP" -# file path. $file_path_acp is a logically-equivalent ACP-encoded -# bytestring suitable for use in a (narrow-character) system -# call. These are only distinct on Win32. -my $file_path = decode utf8 => $req->url_param('filename'); -my $file_path_acp = $file_path; -if ($win32) { - $file_path_acp = Win32::GetFullPathName(Win32::GetANSIPathName($file_path)); -} -$file_path_acp =~ /\A([^\0- ]*)\z/s - or die "untaint failed: $!"; -$file_path_acp = $1; - -# This should be a random-named subdirectory of the system temporary -# directory holding the test file to be deleted. -my $temp_cgi_subdir = dirname($file_path_acp); -if ($win32) { - # Drive+directory path equality checks are performed in the 8.3 - # "shortname" space (and case-insensitively) to decrease the - # likelihood of a false negative. - # - # ACP APIs return 8.3 names for some of the inputs currently used in - # tests. - $temp_cgi_subdir = Win32::GetShortPathName($temp_cgi_subdir); -} - -# If the passed-in file path is actually one created by -# write-temp-file.cgi this will match $system_tmpdir computed from the -# environment. -my $file_path_implied_system_tmpdir = dirname($temp_cgi_subdir); - -# This is the random-suffixed (LayoutTests_)?cgiXXXXX component. -my $temp_cgi_subdir_basename = basename($temp_cgi_subdir); - -# The selected file must actually exist. -if (!-f $file_path_acp) { - die(encode utf8 => "Can't reset $file_path: missing file"); -} - -# Security check: ensure the supplied fully-qualified file path is in a -# subdirectory of the system temporary directory. -if (uc($file_path_implied_system_tmpdir) ne uc($system_tmpdir)) { - die(encode utf8 => ("Can't reset $file_path: " . - "$file_path_implied_system_tmpdir is not " . - "$system_tmpdir")); -} - -# The system temporary directory must already exist. -if (!-d $system_tmpdir) { - die(encode utf8 => "Can't reset $file_path: missing $system_tmpdir"); -} - -# Ensure the random-named subdirectory matches write-temp-file.cgi -# naming conventions. -if (!($temp_cgi_subdir_basename =~ /\A(LayoutTests_)?cgi\w+\z/i)) { - die(encode utf8 => ("Can't reset $file_path: " . - "$temp_cgi_subdir_basename is not cgi*")); -} - -# The random-named subdirectory must also already exist. -if (!-d $temp_cgi_subdir) { - die(encode utf8 => ("Can't reset $file_path: " . - "missing $temp_cgi_subdir")); -} - -# Delete the selected file. -unlink($file_path_acp) - or die(encode utf8 => "unlink $file_path: $!"); - -# Delete its containing (LayoutTests_)?cgiXXXXX directory. -rmdir($temp_cgi_subdir) - or die(encode utf8 => "rmdir $temp_cgi_subdir: $!"); -print 'OK';
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/write-temp-file.cgi b/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/write-temp-file.cgi deleted file mode 100755 index 9a19517..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/write-temp-file.cgi +++ /dev/null
@@ -1,173 +0,0 @@ -#!/usr/bin/perl -wT -# -# write-temp-file.cgi - creates a file and its temporary subdirectory -# -# The file's desired basename is passed in the filename query parameter. -# The file's desired contents are passed in the data query parameter. -# -# The newly created temporary file will be inside a uniquely-named -# subdirectory to prevent crosstalk between parallel test runs. Once -# the test is done with the temporary file its <file_path> should be -# passed to delete-temp-file.cgi for cleanup. -# -# Must be called using the HTTP POST method. -# -# On success, outputs the following three-line plaintext UTF-8 -# response: -# -# OK -# <file_path> -# -# Where <file_path> is the full file_path of the just-written -# temporary file suitable for use with wide-character Unicode APIs -# after UTF-8 decoding and UTF-16 reencoding. -# -# Any other output is an error message and indicates failure. -# -# Errors are redirected to stdout and UTF-8 encoded to aid diagnostics -# in the calling test suite. -# -# NOTE: This CGI allows writing files with filenames including -# non-ASCII Unicode characters, but note that Blink renderer crashes -# are expected on non-Windows hosts using such filenames when a -# non-UTF-8 locale is used. Use a UTF-8 locale to prevent this, -# e.g. with: -# -# bash$ export LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 -# -# Any other locale should work too provided it uses UTF-8 character -# encoding. -# -# Test failures are expected when relying on this CGI on Windows when -# using any system "ANSI" codepage ("ACP" below) other than -# windows-1252. To fix this, upgrade your system's Win32.pm Perl -# module to the latest version. Any version of Win32.pm since -# Win32-0.45 (released in 2012) should have the needed method: -# https://rt.cpan.org/Public/Bug/Display.html?id=78820 -# -# NOTE: "ACP" in this CGI refers to the Windows concept of "ANSI" -# Codepage, a (not actually ANSI-standardized) single- or double-byte -# non-Unicode ASCII-compatible character encoding used for some -# narrow-character Win32 APIs. It should not be confused with UTF-8 -# (used for similar purposes on Linux, OS X, and other modern -# POSIX-like systems), nor with the usually-distinct OEM codepage -# used for other narrow-character Win32 APIs (for instance, console -# I/O and some filesystem data storage.) - -use strict; -use warnings FATAL => 'all'; -use CGI qw(-oldstyle_urls); -use Encode qw(encode decode is_utf8); -use File::Basename qw(dirname); -use File::Spec::Functions qw(catfile tmpdir); -use File::Temp qw(tempdir tempfile); -use utf8; - -my $win32 = eval 'use Win32; 1' ? 1 : 0; - -open STDERR, '>&STDOUT'; # let the test see die() output -binmode STDOUT, ':encoding(utf-8)'; -autoflush STDOUT 1; -autoflush STDERR 1; -print "content-type: text/plain; charset=utf-8\n\n"; - -# tmpdir() does not read environment variables in taint mode. -my $system_tmpdir = $ENV{TMPDIR} || $ENV{TEMP} || tmpdir(); -$system_tmpdir =~ /\A([^\0- ]*)\z/s - or die "untaint failed: $!"; -$system_tmpdir = $1; -if ($win32) { - $system_tmpdir = - Win32::GetFullPathName(Win32::GetANSIPathName($system_tmpdir)); -} - -my $req = CGI->new; -if (uc 'post' ne $req->request_method) { - die 'Wrong method: ' . $req->request_method; -} -my $basename = decode utf8 => $req->url_param('filename'); -$basename =~ /\A([^\0- ]*)\z/s - or die "untaint failed: $!"; -$basename = $1; -my $data = decode utf8 => $req->url_param('data'); - -# The system temporary directory must already exist. -if (!-d $system_tmpdir) { - die(encode utf8 => "Can't create $basename: missing $system_tmpdir"); -} - -# Create a random-named subdirectory of the system temporary directory -# to hold the newly-created test file. The X's will be replaced with -# random printable characters by tempdir. -my $temp_cgi_subdir_template = 'LayoutTests_cgiXXXXX'; -if ($win32) { - # On win32 this name needs to remain unique even after 8.3 shortname - # conversion so we drop the LayoutTests_ prefix. - $temp_cgi_subdir_template = 'cgiXXXXX'; -} -my $temp_cgi_subdir = - tempdir($temp_cgi_subdir_template, DIR => $system_tmpdir); -my $file_path = catfile($temp_cgi_subdir, $basename); -if (dirname($file_path) ne $temp_cgi_subdir) { - die(encode utf8 => "$file_path not in $temp_cgi_subdir"); -} -my $tempfile_contents_write_handle; -my $tempfile; - -# $file_path_acp_utf8 is a UTF-8-encoded representation of the -# fully-qualified "ACP" file file_path. $file_path_acp is a -# logically-equivalent ACP-encoded bytestring suitable for use in a -# (narrow-character) system call. These are only distinct on Win32. -my $file_path_acp = $file_path; -my $file_path_acp_utf8 = $file_path; -if ($win32) { - - # Win32::GetACP is a recently-added method and not yet available in - # some installations. Fall back to windows-1252 when GetACP is - # missing as that matches the ACP used by our Windows bots. - my $win32_ansi_codepage = 'windows-1252'; - eval '$win32_ansi_codepage = "cp" . Win32::GetACP();'; - - Win32::CreateFile($file_path) - or die(encode utf8 => "CreateFile $file_path: $^E"); - $file_path_acp = Win32::GetFullPathName(Win32::GetANSIPathName($file_path)); - $file_path = Win32::GetLongPathName($file_path_acp); - $file_path_acp_utf8 = $file_path_acp; - if (!is_utf8($file_path_acp_utf8)) { - $file_path_acp_utf8 = decode($win32_ansi_codepage, $file_path_acp_utf8); - } - if (!is_utf8($file_path)) { - $file_path = decode($win32_ansi_codepage, $file_path); - } - open($tempfile_contents_write_handle, '>>', $file_path_acp) - or die(encode utf8 => "open >> $file_path_acp_utf8: $!"); - $tempfile = $file_path_acp_utf8; -} else { - ($tempfile_contents_write_handle, $tempfile) = - tempfile(DIR => $temp_cgi_subdir); -} -binmode $tempfile_contents_write_handle, ':encoding(utf-8)'; -print $tempfile_contents_write_handle $data; -close $tempfile_contents_write_handle - or die(encode utf8 => "close $tempfile: $!"); -if (!$win32) { - rename($tempfile, $file_path) - or die(encode utf8 => "rename $tempfile, $file_path: $!"); -} - -# Fail early to aid debugging when the newly-created file does not -# actually work with system calls or does not contain the correct -# bytes. -local $/ = undef; -my $tempfile_verification_read_handle; -open($tempfile_verification_read_handle, '<', $file_path_acp) - or die(encode utf8 => "open $file_path_acp_utf8: $!"); -binmode $tempfile_verification_read_handle, ':encoding(utf-8)'; -my $data2 = <$tempfile_verification_read_handle>; -close($tempfile_verification_read_handle) - or die(encode utf8 => "close $file_path_acp_utf8: $!"); -if ($data ne $data2) { - die(encode utf8 => "Expected $data but got $data2"); -} - -print "OK\n$file_path";
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-iso-2022-jp-part2.html b/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-iso-2022-jp-part2.html deleted file mode 100644 index 206053e..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-iso-2022-jp-part2.html +++ /dev/null
@@ -1,53 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<title>Upload files in ISO-2022-JP form (part 2)</title> -<link rel="help" - href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> -<link rel="author" title="Benjamin C. Wiley Sittler" - href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="resources/send-dragged-file-form-helper.js"></script> -<!-- - - NOTE: Blink renderer crashes are expected on non-Windows hosts using - filenames containing characters from outside ASCII. Use a UTF-8 - locale to prevent this, e.g. with: - - bash$ export LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 - - Any other locale should work too provided it uses UTF-8 character - encoding. - - Test failures are expected on Windows when using any system "ANSI" - codepage other than windows-1252. To fix this, upgrade your system's - Win32.pm Perl module to the latest version. - - --> -<script> -'use strict'; - -formPostFileUploadTest({ - fileNameSource: 'JIS X 0201 and JIS X 0208', - fileBaseName: 'file-for-drag-to-send3-★星★.txt', - formEncoding: 'ISO-2022-JP', - expectedEncodedBaseName: 'file-for-drag-to-send3-\x1B$B!z@1!z\x1B(B.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'Unicode', - fileBaseName: 'file-for-drag-to-send3-☺😂.txt', - formEncoding: 'ISO-2022-JP', - expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'Unicode', - fileBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, - formEncoding: 'ISO-2022-JP', - expectedEncodedBaseName: `file-for-drag-to-send3-${ - kTestFallbackIso2022jp - }.txt`, -}); - -</script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-utf-8-part2.html b/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-utf-8-part2.html deleted file mode 100644 index 6da4d9c..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-utf-8-part2.html +++ /dev/null
@@ -1,51 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<title>Upload files in UTF-8 form (part 2)</title> -<link rel="help" - href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> -<link rel="author" title="Benjamin C. Wiley Sittler" - href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="resources/send-dragged-file-form-helper.js"></script> -<!-- - - NOTE: Blink renderer crashes are expected on non-Windows hosts using - filenames containing characters from outside ASCII. Use a UTF-8 - locale to prevent this, e.g. with: - - bash$ export LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 - - Any other locale should work too provided it uses UTF-8 character - encoding. - - Test failures are expected on Windows when using any system "ANSI" - codepage other than windows-1252. To fix this, upgrade your system's - Win32.pm Perl module to the latest version. - - --> -<script> -'use strict'; - -formPostFileUploadTest({ - fileNameSource: 'JIS X 0201 and JIS X 0208', - fileBaseName: 'file-for-drag-to-send3-★星★.txt', - formEncoding: 'UTF-8', - expectedEncodedBaseName: 'file-for-drag-to-send3-★星★.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'Unicode', - fileBaseName: 'file-for-drag-to-send3-☺😂.txt', - formEncoding: 'UTF-8', - expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'Unicode', - fileBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, - formEncoding: 'UTF-8', - expectedEncodedBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, -}); - -</script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-windows-1252-part1.html b/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-windows-1252-part1.html deleted file mode 100644 index 94e7f4d..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-windows-1252-part1.html +++ /dev/null
@@ -1,52 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<title>Upload files in Windows-1252 form (part 1)</title> -<link rel="help" - href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> -<link rel="author" title="Benjamin C. Wiley Sittler" - href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="resources/send-dragged-file-form-helper.js"></script> -<!-- - - NOTE: Blink renderer crashes are expected on non-Windows hosts using - filenames containing characters from outside ASCII. Use a UTF-8 - locale to prevent this, e.g. with: - - bash$ export LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 - - Any other locale should work too provided it uses UTF-8 character - encoding. - - Test failures are expected on Windows when using any system "ANSI" - codepage other than windows-1252. To fix this, upgrade your system's - Win32.pm Perl module to the latest version. - - --> -<script> -'use strict'; - -formPostFileUploadTest({ - fileNameSource: 'ASCII', - fileBaseName: 'file-for-drag-to-send3.txt', - formEncoding: 'windows-1252', - expectedEncodedBaseName: 'file-for-drag-to-send3.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'x-user-defined', - fileBaseName: 'file-for-drag-to-send3-\uF7F0\uF793\uF783\uF7A0.txt', - formEncoding: 'windows-1252', - expectedEncodedBaseName: ( - 'file-for-drag-to-send3-.txt'), -}); - -formPostFileUploadTest({ - fileNameSource: 'windows-1252', - fileBaseName: 'file-for-drag-to-send3-☺😂.txt', - formEncoding: 'windows-1252', - expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', -}); - -</script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-x-user-defined-part2.html b/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-x-user-defined-part2.html deleted file mode 100644 index ed1b6a66..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-x-user-defined-part2.html +++ /dev/null
@@ -1,53 +0,0 @@ -<!DOCTYPE html> -<meta charset="utf-8"> -<title>Upload files in x-user-defined form (part 2)</title> -<link rel="help" - href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> -<link rel="author" title="Benjamin C. Wiley Sittler" - href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="resources/send-dragged-file-form-helper.js"></script> -<!-- - - NOTE: Blink renderer crashes are expected on non-Windows hosts using - filenames containing characters from outside ASCII. Use a UTF-8 - locale to prevent this, e.g. with: - - bash$ export LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 - - Any other locale should work too provided it uses UTF-8 character - encoding. - - Test failures are expected on Windows when using any system "ANSI" - codepage other than windows-1252. To fix this, upgrade your system's - Win32.pm Perl module to the latest version. - - --> -<script> -'use strict'; - -formPostFileUploadTest({ - fileNameSource: 'JIS X 0201 and JIS X 0208', - fileBaseName: 'file-for-drag-to-send3-★星★.txt', - formEncoding: 'x-user-defined', - expectedEncodedBaseName: 'file-for-drag-to-send3-★星★.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'Unicode', - fileBaseName: 'file-for-drag-to-send3-☺😂.txt', - formEncoding: 'x-user-defined', - expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', -}); - -formPostFileUploadTest({ - fileNameSource: 'Unicode', - fileBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, - formEncoding: 'x-user-defined', - expectedEncodedBaseName: `file-for-drag-to-send3-${ - kTestFallbackXUserDefined - }.txt`, -}); - -</script>
diff --git "a/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-ABC~\342\200\276\302\245\342\211\210\302\244\357\275\245\343\203\273\342\200\242\342\210\231\302\267\342\230\274\342\230\205\346\230\237\360\237\214\237\346\230\237\342\230\205\342\230\274\302\267\342\210\231\342\200\242\343\203\273\357\275\245\302\244\342\211\210\302\245\342\200\276~XYZ.txt" "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-ABC~\342\200\276\302\245\342\211\210\302\244\357\275\245\343\203\273\342\200\242\342\210\231\302\267\342\230\274\342\230\205\346\230\237\360\237\214\237\346\230\237\342\230\205\342\230\274\302\267\342\210\231\342\200\242\343\203\273\357\275\245\302\244\342\211\210\302\245\342\200\276~XYZ.txt" new file mode 100644 index 0000000..5471fb5 --- /dev/null +++ "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-ABC~\342\200\276\302\245\342\211\210\302\244\357\275\245\343\203\273\342\200\242\342\210\231\302\267\342\230\274\342\230\205\346\230\237\360\237\214\237\346\230\237\342\230\205\342\230\274\302\267\342\210\231\342\200\242\343\203\273\357\275\245\302\244\342\211\210\302\245\342\200\276~XYZ.txt"
@@ -0,0 +1 @@ +ABC~‾¥≈¤ï½¥ãƒ»•∙·â˜¼â˜…星🌟星★☼·âˆ™•・・¤≈¥‾~XYZ \ No newline at end of file
diff --git "a/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\303\242\313\234\302\272\303\260\305\270\313\234\342\200\232.txt" "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\303\242\313\234\302\272\303\260\305\270\313\234\342\200\232.txt" new file mode 100644 index 0000000..5471fb5 --- /dev/null +++ "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\303\242\313\234\302\272\303\260\305\270\313\234\342\200\232.txt"
@@ -0,0 +1 @@ +ABC~‾¥≈¤ï½¥ãƒ»•∙·â˜¼â˜…星🌟星★☼·âˆ™•・・¤≈¥‾~XYZ \ No newline at end of file
diff --git "a/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\342\230\205\346\230\237\342\230\205.txt" "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\342\230\205\346\230\237\342\230\205.txt" new file mode 100644 index 0000000..5471fb5 --- /dev/null +++ "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\342\230\205\346\230\237\342\230\205.txt"
@@ -0,0 +1 @@ +ABC~‾¥≈¤ï½¥ãƒ»•∙·â˜¼â˜…星🌟星★☼·âˆ™•・・¤≈¥‾~XYZ \ No newline at end of file
diff --git "a/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\342\230\272\360\237\230\202.txt" "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\342\230\272\360\237\230\202.txt" new file mode 100644 index 0000000..5471fb5 --- /dev/null +++ "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\342\230\272\360\237\230\202.txt"
@@ -0,0 +1 @@ +ABC~‾¥≈¤ï½¥ãƒ»•∙·â˜¼â˜…星🌟星★☼·âˆ™•・・¤≈¥‾~XYZ \ No newline at end of file
diff --git "a/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\357\237\260\357\236\223\357\236\203\357\236\240.txt" "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\357\237\260\357\236\223\357\236\203\357\236\240.txt" new file mode 100644 index 0000000..5471fb5 --- /dev/null +++ "b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3-\357\237\260\357\236\223\357\236\203\357\236\240.txt"
@@ -0,0 +1 @@ +ABC~‾¥≈¤ï½¥ãƒ»•∙·â˜¼â˜…星🌟星★☼·âˆ™•・・¤≈¥‾~XYZ \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3.txt b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3.txt new file mode 100644 index 0000000..5471fb5 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/file-for-drag-to-send3.txt
@@ -0,0 +1 @@ +ABC~‾¥≈¤ï½¥ãƒ»•∙·â˜¼â˜…星🌟星★☼·âˆ™•・・¤≈¥‾~XYZ \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/send-dragged-file-form-helper.js b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/send-dragged-file-form-helper.js similarity index 84% rename from third_party/WebKit/LayoutTests/http/tests/fileapi/resources/send-dragged-file-form-helper.js rename to third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/send-dragged-file-form-helper.js index cfde8d5..2caf7480 100644 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/resources/send-dragged-file-form-helper.js +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/resources/send-dragged-file-form-helper.js
@@ -93,17 +93,13 @@ const kTestFallbackXUserDefined = kTestChars.replace(/[^\0-\x7F]/gu, x => `&#${x.codePointAt(0)};`); -// Web server hosting helper CGIs +// Web server hosting helper CGI const kWebServer = 'http://127.0.0.1:8000'; // formPostFileUploadTest - verifies multipart upload structure and // numeric character reference replacement for filenames, field names, // and field values. // -// Uses /fileapi/resources/write-temp-file.cgi to create the -// test file and /fileapi/resources/delete-temp-file.cgi to -// remove it at the end of the test. -// // Uses /xmlhttprequest/resources/post-echo.cgi to echo the upload // POST with UTF-8 byte interpretation, leading to the "UTF-8 goggles" // behavior documented below for expectedEncodedBaseName when non- @@ -123,8 +119,7 @@ // the fileBaseName, or Unicode if no smaller-than-Unicode source // contains all the characters. Used in the test name. // - fileBaseName: the not-necessarily-just-7-bit-ASCII file basename -// used to create and then upload the test file. Used in the test -// name. +// for the test file. Used in the test name. // - formEncoding: the acceptCharset of the form used to submit the // test file. Used in the test name. // - expectedEncodedBaseName: the expected formEncoding-encoded @@ -133,12 +128,6 @@ // through UTF-8 goggles; subsequences not interpretable as UTF-8 // have each byte represented here by \uFFFD REPLACEMENT CHARACTER. // -// Only a subset of functionality representable in the active "ANSI" -// codepage is actually testable for filenames on Win32 at the moment -// due to Blink and test suite limitations. Elsewhere (Linux, OS X, -// etc.) full functionality is testable provided a UTF-8 locale is -// used to run the test. -// // NOTE: This does not correctly account for varying representation of // combining characters across platforms and filesystems due to // Unicode normalization or similar platform-specific normalization @@ -211,29 +200,11 @@ }); form.appendChild(fileInput); - const fileToDropLines = (await (await fetch( - `${kWebServer}/fileapi/resources/write-temp-file.cgi` + - `?filename=${ - encodeURIComponent(fileBaseName) - }&data=${encodeURIComponent(kTestChars)}`, - { method: 'post' })).text()).split('\n'); - assert_equals( - fileToDropLines.length, - 2, - `CGI response should have two lines but got ${fileToDropLines}`); - const [shouldBeOk, fileToDrop] = fileToDropLines; - assert_equals( - shouldBeOk, - 'OK', - `CGI response should begin with OK but got ${fileToDropLines}`); + const fileToDrop = `resources/${fileBaseName}`; // Removes c:\fakepath\ or other pseudofolder and returns just the // final component of filePath; allows both / and \ as segment // delimiters. const baseNameOfFilePath = filePath => filePath.split(/[\/\\]/).pop(); - assert_equals( - baseNameOfFilePath(fileToDrop), - fileBaseName, - `Unicode ${fileToDrop} basename should be ${fileBaseName}`); fileInput.onchange = event => { assert_equals( fileInput.files[0].name, @@ -249,22 +220,14 @@ `The basename of the field's value should match its files[0].name`); form.submit(); }; - try { - await new Promise(resolve => { - formTargetFrame.onload = resolve; - eventSender.beginDragWithFiles([fileToDrop]); - const centerX = fileInput.offsetLeft + fileInput.offsetWidth / 2; - const centerY = fileInput.offsetTop + fileInput.offsetHeight / 2; - eventSender.mouseMoveTo(centerX, centerY); - eventSender.mouseUp(); - }); - } finally { - const cleanupErrors = await (await fetch( - `${kWebServer}/fileapi/resources/delete-temp-file.cgi` + - `?filename=${encodeURIComponent(fileToDrop)}`, - { method: 'post' })).text(); - assert_equals(cleanupErrors, 'OK', 'Temp file cleanup should not fail'); - } + await new Promise(resolve => { + formTargetFrame.onload = resolve; + eventSender.beginDragWithFiles([fileToDrop]); + const centerX = fileInput.offsetLeft + fileInput.offsetWidth / 2; + const centerY = fileInput.offsetTop + fileInput.offsetHeight / 2; + eventSender.mouseMoveTo(centerX, centerY); + eventSender.mouseUp(); + }); const formDataText = formTargetFrame.contentDocument.body.textContent; const formDataLines = formDataText.split('\n');
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-iso-2022-jp-part1.html b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-iso-2022-jp.html similarity index 64% rename from third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-iso-2022-jp-part1.html rename to third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-iso-2022-jp.html index 0ad22d6..16875156 100644 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-iso-2022-jp-part1.html +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-iso-2022-jp.html
@@ -1,12 +1,12 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Upload files in ISO-2022-JP form (part 1)</title> +<title>Upload files in ISO-2022-JP form</title> <link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> <link rel="author" title="Benjamin C. Wiley Sittler" href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> +<script src="../../../../resources/testharness.js"></script> +<script src="../../../../resources/testharnessreport.js"></script> <script src="resources/send-dragged-file-form-helper.js"></script> <!-- @@ -50,4 +50,27 @@ 'file-for-drag-to-send3-☺😂.txt'), }); +formPostFileUploadTest({ + fileNameSource: 'JIS X 0201 and JIS X 0208', + fileBaseName: 'file-for-drag-to-send3-★星★.txt', + formEncoding: 'ISO-2022-JP', + expectedEncodedBaseName: 'file-for-drag-to-send3-\x1B$B!z@1!z\x1B(B.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'Unicode', + fileBaseName: 'file-for-drag-to-send3-☺😂.txt', + formEncoding: 'ISO-2022-JP', + expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'Unicode', + fileBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, + formEncoding: 'ISO-2022-JP', + expectedEncodedBaseName: `file-for-drag-to-send3-${ + kTestFallbackIso2022jp + }.txt`, +}); + </script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-utf-8-part1.html b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-utf-8.html similarity index 65% rename from third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-utf-8-part1.html rename to third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-utf-8.html index 78926c0..41ed0055 100644 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-utf-8-part1.html +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-utf-8.html
@@ -1,12 +1,12 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Upload files in UTF-8 form (part 1)</title> +<title>Upload files in UTF-8 form</title> <link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> <link rel="author" title="Benjamin C. Wiley Sittler" href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> +<script src="../../../../resources/testharness.js"></script> +<script src="../../../../resources/testharnessreport.js"></script> <script src="resources/send-dragged-file-form-helper.js"></script> <!-- @@ -49,4 +49,25 @@ expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', }); +formPostFileUploadTest({ + fileNameSource: 'JIS X 0201 and JIS X 0208', + fileBaseName: 'file-for-drag-to-send3-★星★.txt', + formEncoding: 'UTF-8', + expectedEncodedBaseName: 'file-for-drag-to-send3-★星★.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'Unicode', + fileBaseName: 'file-for-drag-to-send3-☺😂.txt', + formEncoding: 'UTF-8', + expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'Unicode', + fileBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, + formEncoding: 'UTF-8', + expectedEncodedBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, +}); + </script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-windows-1252-part2.html b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-windows-1252.html similarity index 64% rename from third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-windows-1252-part2.html rename to third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-windows-1252.html index c6ca25d..3b73040 100644 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-windows-1252-part2.html +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-windows-1252.html
@@ -1,12 +1,12 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Upload files in Windows-1252 form (part 2)</title> +<title>Upload files in Windows-1252 form</title> <link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> <link rel="author" title="Benjamin C. Wiley Sittler" href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> +<script src="../../../../resources/testharness.js"></script> +<script src="../../../../resources/testharnessreport.js"></script> <script src="resources/send-dragged-file-form-helper.js"></script> <!-- @@ -28,6 +28,28 @@ 'use strict'; formPostFileUploadTest({ + fileNameSource: 'ASCII', + fileBaseName: 'file-for-drag-to-send3.txt', + formEncoding: 'windows-1252', + expectedEncodedBaseName: 'file-for-drag-to-send3.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'x-user-defined', + fileBaseName: 'file-for-drag-to-send3-\uF7F0\uF793\uF783\uF7A0.txt', + formEncoding: 'windows-1252', + expectedEncodedBaseName: ( + 'file-for-drag-to-send3-.txt'), +}); + +formPostFileUploadTest({ + fileNameSource: 'windows-1252', + fileBaseName: 'file-for-drag-to-send3-☺😂.txt', + formEncoding: 'windows-1252', + expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', +}); + +formPostFileUploadTest({ fileNameSource: 'JIS X 0201 and JIS X 0208', fileBaseName: 'file-for-drag-to-send3-★星★.txt', formEncoding: 'windows-1252',
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-x-user-defined-part1.html b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-x-user-defined.html similarity index 63% rename from third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-x-user-defined-part1.html rename to third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-x-user-defined.html index edc24cd9..0f7d3c52 100644 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form-x-user-defined-part1.html +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form-x-user-defined.html
@@ -1,12 +1,12 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Upload files in x-user-defined form (part 1)</title> +<title>Upload files in x-user-defined form</title> <link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> <link rel="author" title="Benjamin C. Wiley Sittler" href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> +<script src="../../../../resources/testharness.js"></script> +<script src="../../../../resources/testharnessreport.js"></script> <script src="resources/send-dragged-file-form-helper.js"></script> <!-- @@ -49,4 +49,27 @@ '☺😂.txt'), }); +formPostFileUploadTest({ + fileNameSource: 'JIS X 0201 and JIS X 0208', + fileBaseName: 'file-for-drag-to-send3-★星★.txt', + formEncoding: 'x-user-defined', + expectedEncodedBaseName: 'file-for-drag-to-send3-★星★.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'Unicode', + fileBaseName: 'file-for-drag-to-send3-☺😂.txt', + formEncoding: 'x-user-defined', + expectedEncodedBaseName: 'file-for-drag-to-send3-☺😂.txt', +}); + +formPostFileUploadTest({ + fileNameSource: 'Unicode', + fileBaseName: `file-for-drag-to-send3-${kTestChars}.txt`, + formEncoding: 'x-user-defined', + expectedEncodedBaseName: `file-for-drag-to-send3-${ + kTestFallbackXUserDefined + }.txt`, +}); + </script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form.html b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form.html similarity index 82% rename from third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form.html rename to third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form.html index 456d058d..d517c73 100644 --- a/third_party/WebKit/LayoutTests/http/tests/fileapi/send-dragged-file-form.html +++ b/third_party/WebKit/LayoutTests/http/tests/local/fileapi/send-dragged-file-form.html
@@ -5,8 +5,8 @@ href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"> <link rel="author" title="Benjamin C. Wiley Sittler" href="mailto:bsittler@chromium.org"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> +<script src="../../../../resources/testharness.js"></script> +<script src="../../../../resources/testharnessreport.js"></script> <script src="resources/send-dragged-file-form-helper.js"></script> <script> 'use strict';
diff --git a/third_party/WebKit/LayoutTests/http/tests/worklet/webexposed/global-interface-listing-paint-worklet-expected.txt b/third_party/WebKit/LayoutTests/http/tests/worklet/webexposed/global-interface-listing-paint-worklet-expected.txt index 68ff65d..f7f8621d 100644 --- a/third_party/WebKit/LayoutTests/http/tests/worklet/webexposed/global-interface-listing-paint-worklet-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/worklet/webexposed/global-interface-listing-paint-worklet-expected.txt
@@ -139,6 +139,8 @@ CONSOLE MESSAGE: line 147: getter fallback CONSOLE MESSAGE: line 147: getter variable CONSOLE MESSAGE: line 147: method constructor +CONSOLE MESSAGE: line 147: setter fallback +CONSOLE MESSAGE: line 147: setter variable CONSOLE MESSAGE: line 147: interface CountQueuingStrategy CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method size @@ -434,6 +436,8 @@ CONSOLE MESSAGE: line 147: getter fallback CONSOLE MESSAGE: line 147: getter variable CONSOLE MESSAGE: line 147: method constructor +CONSOLE MESSAGE: line 147: setter fallback +CONSOLE MESSAGE: line 147: setter variable CONSOLE MESSAGE: line 147: interface CountQueuingStrategy CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method size
diff --git a/third_party/WebKit/LayoutTests/typedcssom/resources/testhelper.js b/third_party/WebKit/LayoutTests/typedcssom/resources/testhelper.js index 20129c2..811dc752 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/resources/testhelper.js +++ b/third_party/WebKit/LayoutTests/typedcssom/resources/testhelper.js
@@ -1,6 +1,11 @@ // Compares two CSSStyleValues to check if they're the same type // and have the same attributes. function assert_style_value_equals(a, b) { + if (a == null || b == null) { + assert_equals(a, b); + return; + } + assert_equals(a.constructor.name, b.constructor.name); const className = a.constructor.name; switch (className) { @@ -21,6 +26,13 @@ case 'CSSMathNegate': assert_style_value_equals(a.value, b.value); break; + case 'CSSUnparsedValue': + assert_style_value_array_equals(a, b); + break; + case 'CSSVariableReferenceValue': + assert_equals(a.variable, b.variable); + assert_style_value_equals(a.fallback, b.fallback); + break; } } @@ -52,10 +64,9 @@ // Hacky way of creating a CSSVariableReferenceValue // since it doesn't expose a constructor. function createReferenceValue(variable, fallback) { - const varExpr = fallback ? - 'var(' + variable + ', ' + fallback + ')' : - 'var(' + variable + ')'; - + const varExpr = 'var(' + variable + ')'; const unparsedValue = newDivWithStyle('color:' + varExpr).attributeStyleMap.get('color'); - return unparsedValue[0]; + let referenceValue = unparsedValue[0]; + referenceValue.fallback = fallback; + return referenceValue; }
diff --git a/third_party/WebKit/LayoutTests/typedcssom/stylevalue-normalization/normalize-tokens.html b/third_party/WebKit/LayoutTests/typedcssom/stylevalue-normalization/normalize-tokens.html new file mode 100644 index 0000000..26bbee6 --- /dev/null +++ b/third_party/WebKit/LayoutTests/typedcssom/stylevalue-normalization/normalize-tokens.html
@@ -0,0 +1,55 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Normalization of raw CSS tokens tests</title> +<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#normalize-tokens"> +<script src="../..//resources/testharness.js"></script> +<script src="../..//resources/testharnessreport.js"></script> +<script src="../resources/testhelper.js"></script> +<script> +'use strict'; + +const gTestCases = [ + { + value: 'var(--A)', + expectedResult: [ + createReferenceValue('--A', null), + ] + }, + { + value: 'var(--A, 1em)', + expectedResult: [ + createReferenceValue('--A', new CSSUnparsedValue(' 1em')), + ] + }, + { + value: 'var(--A, var(--B))', + expectedResult: [ + createReferenceValue('--A', new CSSUnparsedValue(' ', createReferenceValue('--B', null))), + ] + }, + { + value: 'calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))', + expectedResult: [ + 'calc(42px +', + createReferenceValue('--foo', new CSSUnparsedValue(' 15em')), + ' + ', + createReferenceValue('--bar', new CSSUnparsedValue(' ', createReferenceValue('--far', null), ' + 15px')), + ')', + ] + }, +]; + +for (const {value, expectedResult} of gTestCases) { + // TODO(788570): Add similar tests using a custom property instead of 'color' + test(() => { + const result = CSSStyleValue.parse('color', value); + assert_style_value_equals(result, new CSSUnparsedValue(...expectedResult)); + }, 'Normalizing "' + value + '" from String returns correct CSSUnparsedValue'); + + test(() => { + const result = newDivWithStyle('color:' + value).attributeStyleMap.get('color'); + assert_style_value_equals(result, new CSSUnparsedValue(...expectedResult)); + }, 'Normalizing "' + value + '" from CSSOM returns correct CSSUnparsedValue'); +} + +</script>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/stylevalue-subclasses/cssVariableReferenceValue-expected.txt b/third_party/WebKit/LayoutTests/typedcssom/stylevalue-subclasses/cssVariableReferenceValue-expected.txt new file mode 100644 index 0000000..965f8ea --- /dev/null +++ b/third_party/WebKit/LayoutTests/typedcssom/stylevalue-subclasses/cssVariableReferenceValue-expected.txt
@@ -0,0 +1,7 @@ +This is a testharness.js-based test. +FAIL Setting CSSVariableReferenceValue.variable to an invalid variable name throws SyntaxError assert_throws: function "() => result.variable = 'bar'" did not throw +PASS CSSVariableReferenceValue.variable can updated to a valid variable name +PASS CSSVariableReferenceValue.fallback can updated to null +PASS CSSVariableReferenceValue.fallback can updated to a CSSUnparsedValue +Harness: the test ran to completion. +
diff --git a/third_party/WebKit/LayoutTests/typedcssom/stylevalue-subclasses/cssVariableReferenceValue.html b/third_party/WebKit/LayoutTests/typedcssom/stylevalue-subclasses/cssVariableReferenceValue.html new file mode 100644 index 0000000..ebbdefe2 --- /dev/null +++ b/third_party/WebKit/LayoutTests/typedcssom/stylevalue-subclasses/cssVariableReferenceValue.html
@@ -0,0 +1,37 @@ +<!doctype html> +<meta charset="utf-8"> +<title>CSSVariableReferenceValue tests</title> +<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#cssvariablereferencevalue"> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<script src="../resources/testhelper.js"></script> +<script> +'use strict'; + +test(() => { + let result = createReferenceValue('--foo', null); + assert_throws(new SyntaxError(), () => result.variable = 'bar'); + assert_equals(result.variable, '--foo'); + assert_throws(new SyntaxError(), () => result.variable = ''); + assert_equals(result.variable, '--foo'); +}, 'Setting CSSVariableReferenceValue.variable to an invalid variable name throws SyntaxError'); + +test(() => { + let result = createReferenceValue('--foo', null); + result.variable = '--bar'; + assert_equals(result.variable, '--bar'); +}, 'CSSVariableReferenceValue.variable can updated to a valid variable name'); + +test(() => { + let result = createReferenceValue('--foo', new CSSUnparsedValue()); + result.fallback = null; + assert_equals(result.fallback, null); +}, 'CSSVariableReferenceValue.fallback can updated to null'); + +test(() => { + let result = createReferenceValue('--foo', null); + result.fallback = new CSSUnparsedValue('foo'); + assert_style_value_equals(result.fallback, new CSSUnparsedValue('foo')); +}, 'CSSVariableReferenceValue.fallback can updated to a CSSUnparsedValue'); + +</script>
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 7ddac99..4d3e3e5 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -874,6 +874,8 @@ getter fallback getter variable method constructor + setter fallback + setter variable interface CSSViewportRule : CSSRule attribute @@toStringTag getter style
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h b/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h index aea156f..32572534 100644 --- a/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h +++ b/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h
@@ -21,17 +21,16 @@ public: virtual ~CSSStyleVariableReferenceValue() = default; - static CSSStyleVariableReferenceValue* Create( - const String& variable, - const CSSUnparsedValue* fallback) { + static CSSStyleVariableReferenceValue* Create(const String& variable, + CSSUnparsedValue* fallback) { return new CSSStyleVariableReferenceValue(variable, fallback); } const String& variable() const { return variable_; } + void setVariable(const String& value) { variable_ = value; } - CSSUnparsedValue* fallback() { - return const_cast<CSSUnparsedValue*>(fallback_.Get()); - } + CSSUnparsedValue* fallback() { return fallback_.Get(); } + void setFallback(CSSUnparsedValue* value) { fallback_ = value; } void Trace(blink::Visitor* visitor) override { visitor->Trace(fallback_); @@ -40,11 +39,11 @@ protected: CSSStyleVariableReferenceValue(const String& variable, - const CSSUnparsedValue* fallback) + CSSUnparsedValue* fallback) : variable_(variable), fallback_(fallback) {} String variable_; - Member<const CSSUnparsedValue> fallback_; + Member<CSSUnparsedValue> fallback_; private: DISALLOW_COPY_AND_ASSIGN(CSSStyleVariableReferenceValue);
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl b/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl index 4135a61..62004e5 100644 --- a/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl +++ b/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl
@@ -9,6 +9,6 @@ RuntimeEnabled=CSSTypedOM, ImplementedAs=CSSStyleVariableReferenceValue ] interface CSSVariableReferenceValue { - readonly attribute DOMString variable; - readonly attribute CSSUnparsedValue fallback; + attribute DOMString variable; + attribute CSSUnparsedValue? fallback; };
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp index e957cca4..ea86274 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp +++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -15,7 +15,9 @@ #include "core/css/cssom/CSSURLImageValue.h" #include "core/css/cssom/CSSUnparsedValue.h" #include "core/css/cssom/CSSUnsupportedStyleValue.h" -#include "core/css/parser/CSSParser.h" +#include "core/css/parser/CSSPropertyParser.h" +#include "core/css/parser/CSSTokenizer.h" +#include "core/css/parser/CSSVariableParser.h" #include "core/css/properties/CSSProperty.h" namespace blink { @@ -64,11 +66,33 @@ return style_value_vector; } +const CSSValue* ParseProperty(CSSPropertyID property_id, + const String& css_text, + const CSSParserContext* context) { + CSSTokenizer tokenizer(css_text); + const auto tokens = tokenizer.TokenizeToEOF(); + const CSSParserTokenRange range(tokens); + + if (const CSSValue* value = + CSSPropertyParser::ParseSingleValue(property_id, range, context)) { + return value; + } + + if (CSSVariableParser::ContainsValidVariableReferences(range)) { + return CSSVariableReferenceValue::Create( + CSSVariableData::Create(range, false /* is_animation_tainted */, + false /* needs variable resolution */), + *context); + } + + return nullptr; +} + } // namespace CSSStyleValueVector StyleValueFactory::FromString( CSSPropertyID property_id, - const String& value, + const String& css_text, const CSSParserContext* parser_context) { DCHECK_NE(property_id, CSSPropertyInvalid); DCHECK(!CSSProperty::Get(property_id).IsShorthand()); @@ -78,13 +102,12 @@ return CSSStyleValueVector(); } - const CSSValue* css_value = - CSSParser::ParseSingleValue(property_id, value, parser_context); - if (!css_value) + const CSSValue* value = ParseProperty(property_id, css_text, parser_context); + if (!value) return CSSStyleValueVector(); CSSStyleValueVector style_value_vector = - StyleValueFactory::CssValueToStyleValueVector(property_id, *css_value); + StyleValueFactory::CssValueToStyleValueVector(property_id, *value); DCHECK(!style_value_vector.IsEmpty()); return style_value_vector; }
diff --git a/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.cpp index ace1b24..14a2f20 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.cpp
@@ -62,6 +62,7 @@ Maybe<String> options, Maybe<double> buffer_usage_reporting_interval, Maybe<String> transfer_mode, + Maybe<String> transfer_compression, Maybe<protocol::Tracing::TraceConfig> config, std::unique_ptr<StartCallback> callback) { DCHECK(!IsStarted());
diff --git a/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.h b/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.h index 792271f..ade5f89 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorTracingAgent.h
@@ -53,6 +53,7 @@ protocol::Maybe<String> options, protocol::Maybe<double> buffer_usage_reporting_interval, protocol::Maybe<String> transfer_mode, + protocol::Maybe<String> transfer_compression, protocol::Maybe<protocol::Tracing::TraceConfig>, std::unique_ptr<StartCallback>) override; void end(std::unique_ptr<EndCallback>) override;
diff --git a/third_party/WebKit/Source/core/inspector/browser_protocol.json b/third_party/WebKit/Source/core/inspector/browser_protocol.json index d8679a79..6a2f89d 100644 --- a/third_party/WebKit/Source/core/inspector/browser_protocol.json +++ b/third_party/WebKit/Source/core/inspector/browser_protocol.json
@@ -11866,6 +11866,15 @@ "$ref": "MemoryDumpConfig" } ] + }, + { + "id": "StreamCompression", + "description": "Compression type to use for traces returned via streams.", + "type": "string", + "enum": [ + "none", + "gzip" + ] } ], "commands": [ @@ -11949,6 +11958,12 @@ ] }, { + "name": "streamCompression", + "description": "Compression format to use. This only applies when using `ReturnAsStream` transfer mode (defaults to `none`)", + "optional": true, + "$ref": "StreamCompression" + }, + { "name": "traceConfig", "optional": true, "$ref": "TraceConfig" @@ -12002,6 +12017,12 @@ "description": "A handle of the stream that holds resulting trace data.", "optional": true, "$ref": "IO.StreamHandle" + }, + { + "name": "streamCompression", + "description": "Compression format of returned stream.", + "optional": true, + "$ref": "StreamCompression" } ] }
diff --git a/third_party/WebKit/Source/core/inspector/browser_protocol.pdl b/third_party/WebKit/Source/core/inspector/browser_protocol.pdl index b64209e..abe4414 100644 --- a/third_party/WebKit/Source/core/inspector/browser_protocol.pdl +++ b/third_party/WebKit/Source/core/inspector/browser_protocol.pdl
@@ -5432,6 +5432,12 @@ # Configuration for memory dump triggers. Used only when "memory-infra" category is enabled. optional MemoryDumpConfig memoryDumpConfig + # Compression type to use for traces returned via streams. + type StreamCompression extends string + enum + none + gzip + # Stop trace events collection. command end @@ -5469,6 +5475,9 @@ optional enum transferMode ReportEvents ReturnAsStream + # Compression format to use. This only applies when using `ReturnAsStream` + # transfer mode (defaults to `none`) + optional StreamCompression streamCompression optional TraceConfig traceConfig event bufferUsage @@ -5494,3 +5503,5 @@ parameters # A handle of the stream that holds resulting trace data. optional IO.StreamHandle stream + # Compression format of returned stream. + optional StreamCompression streamCompression
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp index 09b2b68..01e647c4 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -277,6 +277,7 @@ ALWAYS_INLINE void UpdateFragmentClip(const PaintLayer&); ALWAYS_INLINE void UpdateCssClip(); ALWAYS_INLINE void UpdateLocalBorderBoxContext(); + ALWAYS_INLINE void UpdateInnerBorderRadiusClip(); ALWAYS_INLINE void UpdateOverflowClip(); ALWAYS_INLINE void UpdatePerspective(); ALWAYS_INLINE void UpdateSvgLocalToBorderBoxTransform(); @@ -941,6 +942,12 @@ return object.IsBox() && ToLayoutBox(object).ShouldClipOverflow(); } +static bool NeedsInnerBorderRadiusClip(const LayoutObject& object) { + return object.StyleRef().HasBorderRadius() && + // IsLayoutEmbeddedContent() is for iframes with border-radius. + (object.IsLayoutEmbeddedContent() || NeedsOverflowClip(object)); +} + static bool NeedsControlClipFragmentationAdjustment(const LayoutBox& box) { return box.HasControlClip() && !box.Layer() && box.PaintingLayer()->EnclosingPaginationLayer(); @@ -964,52 +971,64 @@ return result; } +void FragmentPaintPropertyTreeBuilder::UpdateInnerBorderRadiusClip() { + DCHECK(properties_); + + if (object_.NeedsPaintPropertyUpdate() || + full_context_.force_subtree_update) { + bool clip_added_or_removed; + if (NeedsInnerBorderRadiusClip(object_)) { + const LayoutBox& box = ToLayoutBox(object_); + auto inner_border = box.StyleRef().GetRoundedInnerBorderFor( + LayoutRect(context_.current.paint_offset, box.Size())); + auto result = properties_->UpdateInnerBorderRadiusClip( + context_.current.clip, context_.current.transform, inner_border); + + if (!full_context_.clip_changed && properties_->InnerBorderRadiusClip() && + inner_border != properties_->InnerBorderRadiusClip()->ClipRect()) + full_context_.clip_changed = true; + clip_added_or_removed = result.NewNodeCreated(); + } else { + clip_added_or_removed = properties_->ClearInnerBorderRadiusClip(); + } + + full_context_.force_subtree_update |= clip_added_or_removed; + full_context_.clip_changed |= clip_added_or_removed; + } + + if (auto* border_radius_clip = properties_->InnerBorderRadiusClip()) + context_.current.clip = border_radius_clip; +} + void FragmentPaintPropertyTreeBuilder::UpdateOverflowClip() { DCHECK(properties_); if (object_.NeedsPaintPropertyUpdate() || full_context_.force_subtree_update) { - bool local_clip_added_or_removed = false; - bool local_clip_changed = false; + bool clip_added_or_removed; if (NeedsOverflowClip(object_)) { const LayoutBox& box = ToLayoutBox(object_); LayoutRect clip_rect; clip_rect = box.OverflowClipRect(context_.current.paint_offset); - - const auto* current_clip = context_.current.clip; - if (box.StyleRef().HasBorderRadius()) { - auto inner_border = box.StyleRef().GetRoundedInnerBorderFor( - LayoutRect(context_.current.paint_offset, box.Size())); - auto result = properties_->UpdateInnerBorderRadiusClip( - context_.current.clip, context_.current.transform, inner_border); - local_clip_added_or_removed |= result.NewNodeCreated(); - current_clip = properties_->InnerBorderRadiusClip(); - } else { - local_clip_added_or_removed |= - properties_->ClearInnerBorderRadiusClip(); - } - FloatRoundedRect clipping_rect((FloatRect(clip_rect))); - if (properties_->OverflowClip() && - clipping_rect != properties_->OverflowClip()->ClipRect()) { - local_clip_changed = true; - } + if (!full_context_.clip_changed && properties_->OverflowClip() && + clipping_rect != properties_->OverflowClip()->ClipRect()) + full_context_.clip_changed = true; auto result = properties_->UpdateOverflowClip( - current_clip, context_.current.transform, + context_.current.clip, context_.current.transform, FloatRoundedRect(FloatRect(clip_rect))); - local_clip_added_or_removed |= result.NewNodeCreated(); + clip_added_or_removed = result.NewNodeCreated(); } else { - local_clip_added_or_removed |= properties_->ClearInnerBorderRadiusClip(); - local_clip_added_or_removed |= properties_->ClearOverflowClip(); + clip_added_or_removed = properties_->ClearOverflowClip(); } - full_context_.force_subtree_update |= local_clip_added_or_removed; - full_context_.clip_changed |= - local_clip_changed || local_clip_added_or_removed; + + full_context_.force_subtree_update |= clip_added_or_removed; + full_context_.clip_changed |= clip_added_or_removed; } - if (properties_->OverflowClip()) - context_.current.clip = properties_->OverflowClip(); + if (auto* overflow_clip = properties_->OverflowClip()) + context_.current.clip = overflow_clip; } static FloatPoint PerspectiveOrigin(const LayoutBox& box) { @@ -1422,15 +1441,15 @@ // The overflow clip paint property depends on the border box rect through // overflowClipRect(). The border box rect's size equals the frame rect's // size so we trigger a paint property update when the frame rect changes. - if (box.ShouldClipOverflow() || + if (NeedsOverflowClip(box) || NeedsInnerBorderRadiusClip(box) || // The used value of CSS clip may depend on size of the box, e.g. for // clip: rect(auto auto auto -5px). - box.HasClip() || + NeedsCssClip(box) || // Relative lengths (e.g., percentage values) in transform, perspective, // transform-origin, and perspective-origin can depend on the size of the // frame rect, so force a property update if it changes. TODO(pdr): We // only need to update properties if there are relative lengths. - box.StyleRef().HasTransform() || box.StyleRef().HasPerspective() || + box.StyleRef().HasTransform() || NeedsPerspective(box) || box_generates_property_nodes_for_mask_and_clip_path) box.GetMutableForPainting().SetNeedsPaintPropertyUpdate(); } @@ -1497,6 +1516,7 @@ #endif if (properties_) { + UpdateInnerBorderRadiusClip(); UpdateOverflowClip(); UpdatePerspective(); UpdateSvgLocalToBorderBoxTransform(); @@ -1557,8 +1577,8 @@ NeedsPaintOffsetTranslation(object_) || NeedsTransform(object_) || NeedsEffect(object_) || NeedsTransformForNonRootSVG(object_) || NeedsFilter(object_) || NeedsCssClip(object_) || - NeedsOverflowClip(object_) || NeedsPerspective(object_) || - NeedsSVGLocalToBorderBoxTransform(object_) || + NeedsInnerBorderRadiusClip(object_) || NeedsOverflowClip(object_) || + NeedsPerspective(object_) || NeedsSVGLocalToBorderBoxTransform(object_) || NeedsScrollOrScrollTranslation(object_) || NeedsFragmentationClip(object_, *context_.painting_layer);
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp index 4c22152..a007cc4 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -4187,4 +4187,29 @@ EXPECT_EQ(nullptr, target->FirstFragment().PaintProperties()); } +TEST_P(PaintPropertyTreeBuilderTest, FrameBorderRadius) { + SetBodyInnerHTML(R"HTML( + <style> + #iframe { + width: 200px; + height: 200px; + border: 10px solid blue; + border-radius: 50px; + } + </style> + <iframe id='iframe'></iframe> + )HTML"); + + const auto* properties = PaintPropertiesForElement("iframe"); + const auto* border_radius_clip = properties->InnerBorderRadiusClip(); + ASSERT_NE(nullptr, border_radius_clip); + FloatSize radius(40, 40); + EXPECT_EQ(FloatRoundedRect(FloatRect(18, 18, 200, 200), radius, radius, + radius, radius), + border_radius_clip->ClipRect()); + EXPECT_EQ(FrameContentClip(), border_radius_clip->Parent()); + EXPECT_EQ(FramePreTranslation(), border_radius_clip->LocalTransformSpace()); + EXPECT_EQ(nullptr, properties->OverflowClip()); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/paint/RarePaintData.cpp b/third_party/WebKit/Source/core/paint/RarePaintData.cpp index 154252d..aa3beb7 100644 --- a/third_party/WebKit/Source/core/paint/RarePaintData.cpp +++ b/third_party/WebKit/Source/core/paint/RarePaintData.cpp
@@ -61,6 +61,8 @@ return local_border_box_properties_->Clip(); if (paint_properties_->OverflowClip()) return paint_properties_->OverflowClip(); + if (paint_properties_->InnerBorderRadiusClip()) + return paint_properties_->InnerBorderRadiusClip(); return local_border_box_properties_->Clip(); } @@ -87,6 +89,8 @@ contents.SetTransform(properties->ScrollTranslation()); if (properties->OverflowClip()) contents.SetClip(properties->OverflowClip()); + if (properties->InnerBorderRadiusClip()) + contents.SetClip(properties->InnerBorderRadiusClip()); else if (properties->CssClip()) contents.SetClip(properties->CssClip()); }
diff --git a/third_party/WebKit/Source/modules/payments/AbortPaymentRespondWithObserver.h b/third_party/WebKit/Source/modules/payments/AbortPaymentRespondWithObserver.h index c7eed1d..2b12f6c4 100644 --- a/third_party/WebKit/Source/modules/payments/AbortPaymentRespondWithObserver.h +++ b/third_party/WebKit/Source/modules/payments/AbortPaymentRespondWithObserver.h
@@ -7,7 +7,7 @@ #include "modules/ModulesExport.h" #include "modules/serviceworkers/RespondWithObserver.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/payments/CanMakePaymentRespondWithObserver.h b/third_party/WebKit/Source/modules/payments/CanMakePaymentRespondWithObserver.h index e45862a..9ed05876 100644 --- a/third_party/WebKit/Source/modules/payments/CanMakePaymentRespondWithObserver.h +++ b/third_party/WebKit/Source/modules/payments/CanMakePaymentRespondWithObserver.h
@@ -7,7 +7,7 @@ #include "modules/ModulesExport.h" #include "modules/serviceworkers/RespondWithObserver.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.cpp b/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.cpp index a556ab4..7912776 100644 --- a/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.cpp +++ b/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.cpp
@@ -6,7 +6,6 @@ #include "core/dom/ExecutionContext.h" #include "core/inspector/ConsoleMessage.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" using blink::mojom::ServiceWorkerResponseError;
diff --git a/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.h b/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.h index 090f13f..37484cde 100644 --- a/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.h +++ b/third_party/WebKit/Source/modules/payments/PaymentHandlerUtils.h
@@ -7,7 +7,7 @@ #include "platform/wtf/Allocator.h" #include "platform/wtf/text/WTFString.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestRespondWithObserver.h b/third_party/WebKit/Source/modules/payments/PaymentRequestRespondWithObserver.h index 3c902a7..877dcb21 100644 --- a/third_party/WebKit/Source/modules/payments/PaymentRequestRespondWithObserver.h +++ b/third_party/WebKit/Source/modules/payments/PaymentRequestRespondWithObserver.h
@@ -7,7 +7,7 @@ #include "modules/ModulesExport.h" #include "modules/serviceworkers/RespondWithObserver.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h b/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h index 5ecab2ea..393e66cd 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h +++ b/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h
@@ -9,7 +9,7 @@ #include "core/dom/events/EventTarget.h" #include "modules/ModulesExport.h" #include "platform/heap/Handle.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-shared.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp index b9a01a38..6f0e833 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
@@ -41,7 +41,7 @@ #include "platform/bindings/ScriptState.h" #include "public/platform/WebSecurityOrigin.h" #include "public/platform/WebString.h" -#include "public/platform/modules/serviceworker/service_worker_state.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_state.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp index 9aad60b..e0a50e4 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -61,7 +61,7 @@ #include "public/platform/modules/serviceworker/WebServiceWorker.h" #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.h b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.h index c9569e5f..0762b2ee 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.h +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.h
@@ -45,7 +45,7 @@ #include "platform/wtf/Forward.h" #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" #include "public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h" -#include "public/platform/modules/serviceworker/service_worker_registration.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerError.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerError.cpp index a948d79..8509185 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerError.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerError.cpp
@@ -29,7 +29,7 @@ */ #include "modules/serviceworkers/ServiceWorkerError.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" #include "bindings/core/v8/ScriptPromiseResolver.h" #include "bindings/core/v8/ToV8ForCore.h"
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h index 5260f4cd..fa56c3d 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h
@@ -41,7 +41,7 @@ #include "public/platform/modules/serviceworker/WebServiceWorkerClientsInfo.h" #include "public/platform/modules/serviceworker/WebServiceWorkerSkipWaitingCallbacks.h" #include "public/platform/modules/serviceworker/WebServiceWorkerStreamHandle.h" -#include "public/platform/modules/serviceworker/service_worker_event_status.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.cpp index 6b0b641d..838290c 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.cpp
@@ -84,10 +84,10 @@ #include "platform/wtf/PtrUtil.h" #include "public/platform/modules/notifications/WebNotificationData.h" #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" -#include "public/platform/modules/serviceworker/service_worker_event_status.mojom-blink.h" #include "public/web/WebSerializedScriptValue.h" #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" #include "third_party/WebKit/common/service_worker/service_worker_client.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp index 8147926..7667126 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
@@ -18,7 +18,7 @@ #include "platform/bindings/ScriptState.h" #include "platform/wtf/PtrUtil.h" #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" -#include "public/platform/modules/serviceworker/service_worker_registration.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp index d539d1b..77c64ac5 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp
@@ -10,7 +10,7 @@ #include "modules/serviceworkers/ServiceWorkerWindowClient.h" #include "platform/bindings/V8ThrowException.h" #include "platform/wtf/PtrUtil.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-blink.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp b/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp index e249025..519ee03 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp
@@ -15,7 +15,7 @@ #include "platform/bindings/Microtask.h" #include "platform/wtf/Assertions.h" #include "public/platform/Platform.h" -#include "public/platform/modules/serviceworker/service_worker_event_status.mojom-blink.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom-blink.h" #include "v8/include/v8.h" namespace blink {
diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp index 012640c5..41077348 100644 --- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp +++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
@@ -151,7 +151,11 @@ if (OriginTrials::audioWorkletEnabled(GetExecutionContext()) || RuntimeEnabledFeatures::AudioWorkletEnabled()) { - audio_worklet_ = AudioWorklet::Create(this); + // Worklet requires a valid Frame object, but GetFrame() from the window + // can be nullptr. Block out such case. See: crbug.com/792108 + if (GetExecutionContext()->ExecutingWindow()->GetFrame()) { + audio_worklet_ = AudioWorklet::Create(this); + } } if (destination_node_) {
diff --git a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.cpp index f23e91a..1957834 100644 --- a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.cpp +++ b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.cpp
@@ -162,7 +162,7 @@ gpu::gles2::GLES2Interface* dest_gl = dest_provider->ContextGL(); dest_gl->WaitSyncTokenCHROMIUM(texture_holder_->GetSyncToken().GetData()); GLuint source_texture_id = dest_gl->CreateAndConsumeTextureCHROMIUM( - GL_TEXTURE_2D, texture_holder_->GetMailbox().name); + texture_holder_->GetMailbox().name); dest_gl->CopySubTextureCHROMIUM( source_texture_id, 0, dest_target, dest_texture_id, 0, dest_point.X(), dest_point.Y(), source_sub_rectangle.X(), source_sub_rectangle.Y(),
diff --git a/third_party/WebKit/Source/platform/graphics/CanvasResource.cpp b/third_party/WebKit/Source/platform/graphics/CanvasResource.cpp index ba7e707..8997c15 100644 --- a/third_party/WebKit/Source/platform/graphics/CanvasResource.cpp +++ b/third_party/WebKit/Source/platform/graphics/CanvasResource.cpp
@@ -101,7 +101,7 @@ gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - gl->ProduceTextureDirectCHROMIUM(texture_id, target, GpuMailbox().name); + gl->ProduceTextureDirectCHROMIUM(texture_id, GpuMailbox().name); const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); gl->ShallowFlushCHROMIUM(); gpu::SyncToken sync_token; @@ -174,7 +174,7 @@ DCHECK(image_->isTextureBacked()); // To avoid leaking Mailbox records, we must disassociate the mailbox // before image_ goes out of scope because skia might recycle the texture. - gl->ProduceTextureDirectCHROMIUM(0, GL_TEXTURE_2D, GpuMailbox().name); + gl->ProduceTextureDirectCHROMIUM(0, GpuMailbox().name); } image_ = nullptr; context_provider_wrapper_ = nullptr;
diff --git a/third_party/WebKit/Source/platform/graphics/CanvasResourceTest.cpp b/third_party/WebKit/Source/platform/graphics/CanvasResourceTest.cpp index 0354ba1..96cdb55 100644 --- a/third_party/WebKit/Source/platform/graphics/CanvasResourceTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/CanvasResourceTest.cpp
@@ -20,8 +20,7 @@ class MockGLES2InterfaceWithMailboxSupport : public FakeGLES2Interface { public: - MOCK_METHOD3(ProduceTextureDirectCHROMIUM, - void(GLuint, GLenum, const GLbyte*)); + MOCK_METHOD2(ProduceTextureDirectCHROMIUM, void(GLuint, const GLbyte*)); MOCK_METHOD1(GenMailboxCHROMIUM, void(GLbyte*)); }; @@ -75,8 +74,8 @@ ::testing::Mock::VerifyAndClearExpectations(&gl_); // No expected call to DeleteTextures becaus skia recycles - EXPECT_CALL(gl_, ProduceTextureDirectCHROMIUM(0, GL_TEXTURE_2D, - Pointee(test_mailbox.name[0]))) + EXPECT_CALL(gl_, + ProduceTextureDirectCHROMIUM(0, Pointee(test_mailbox.name[0]))) .Times(1); resource = nullptr;
diff --git a/third_party/WebKit/Source/platform/graphics/GpuMemoryBufferImageCopy.cpp b/third_party/WebKit/Source/platform/graphics/GpuMemoryBufferImageCopy.cpp index 6861ad56..5a492af 100644 --- a/third_party/WebKit/Source/platform/graphics/GpuMemoryBufferImageCopy.cpp +++ b/third_party/WebKit/Source/platform/graphics/GpuMemoryBufferImageCopy.cpp
@@ -84,8 +84,7 @@ // Not strictly necessary since we are on the same context, but keeping // for cleanliness and in case we ever move off the same context. gl_->WaitSyncTokenCHROMIUM(sync_token.GetData()); - GLuint source_texture_id = - gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + GLuint source_texture_id = gl_->CreateAndConsumeTextureCHROMIUM(mailbox.name); gl_->BindTexture(GL_TEXTURE_2D, 0); GLuint read_frame_buffer; gl_->GenFramebuffers(1, &read_frame_buffer);
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp index 11fce0a3..7c97ea52 100644 --- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -189,8 +189,7 @@ // Contexts may be in a different share group. We must transfer the texture // through a mailbox first. source_gl->GenMailboxCHROMIUM(mailbox.name); - source_gl->ProduceTextureDirectCHROMIUM(texture_info->fID, - texture_info->fTarget, mailbox.name); + source_gl->ProduceTextureDirectCHROMIUM(texture_info->fID, mailbox.name); const GLuint64 shared_fence_sync = source_gl->InsertFenceSyncCHROMIUM(); source_gl->Flush(); @@ -199,8 +198,7 @@ produce_sync_token.GetData()); gl->WaitSyncTokenCHROMIUM(produce_sync_token.GetConstData()); - GLuint source_texture = - gl->CreateAndConsumeTextureCHROMIUM(texture_info->fTarget, mailbox.name); + GLuint source_texture = gl->CreateAndConsumeTextureCHROMIUM(mailbox.name); // The canvas is stored in a premultiplied format, so unpremultiply if // necessary. The canvas is also stored in an inverted position, so the flip @@ -225,8 +223,7 @@ source_gl->WaitSyncTokenCHROMIUM(copy_sync_token.GetConstData()); // This disassociates the texture from the mailbox to avoid leaking the // mapping between the two in cases where the texture is recycled by skia. - source_gl->ProduceTextureDirectCHROMIUM(0, texture_info->fTarget, - mailbox.name); + source_gl->ProduceTextureDirectCHROMIUM(0, mailbox.name); // Undo grContext texture binding changes introduced in this function. GrContext* gr_context = provider->GetGrContext();
diff --git a/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.cpp b/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.cpp index 384d868a..266a797 100644 --- a/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.cpp +++ b/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.cpp
@@ -44,7 +44,7 @@ shared_gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); GLuint shared_context_texture_id = - shared_gl->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + shared_gl->CreateAndConsumeTextureCHROMIUM(mailbox.name); GrGLTextureInfo texture_info; texture_info.fTarget = GL_TEXTURE_2D; texture_info.fID = shared_context_texture_id;
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp index 8bbae7c..d19c4ecb 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -391,7 +391,6 @@ // produceSyncToken with that point. { gl_->ProduceTextureDirectCHROMIUM(color_buffer_for_mailbox->texture_id, - texture_target_, color_buffer_for_mailbox->mailbox.name); const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); // It's critical to order the execution of this context's work relative @@ -519,7 +518,8 @@ // could just use the actual texture id and avoid needing to produce/consume a // mailbox. GLuint texture_id = gl_->CreateAndConsumeTextureCHROMIUM( - GL_TEXTURE_2D, transferable_resource.mailbox_holder.mailbox.name); + transferable_resource.mailbox_holder.mailbox.name); + // Return the mailbox but report that the resource is lost to prevent trying // to use the backing for future frames. We keep it alive with our own // reference to the backing via our |textureId|. @@ -771,7 +771,6 @@ // Contexts may be in a different share group. We must transfer the texture // through a mailbox first. - GLenum src_texture_target = texture_target_; gpu::Mailbox mailbox; gpu::SyncToken produce_sync_token; if (src_buffer == kFrontBuffer && front_color_buffer_) { @@ -780,7 +779,7 @@ } else { src_gl->GenMailboxCHROMIUM(mailbox.name); src_gl->ProduceTextureDirectCHROMIUM(back_color_buffer_->texture_id, - src_texture_target, mailbox.name); + mailbox.name); const GLuint64 fence_sync = src_gl->InsertFenceSyncCHROMIUM(); src_gl->OrderingBarrierCHROMIUM(); src_gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, @@ -793,8 +792,7 @@ } dst_gl->WaitSyncTokenCHROMIUM(produce_sync_token.GetConstData()); - GLuint src_texture = - dst_gl->CreateAndConsumeTextureCHROMIUM(src_texture_target, mailbox.name); + GLuint src_texture = dst_gl->CreateAndConsumeTextureCHROMIUM(mailbox.name); GLboolean unpack_premultiply_alpha_needed = GL_FALSE; GLboolean unpack_unpremultiply_alpha_needed = GL_FALSE;
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTestHelpers.h b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTestHelpers.h index 5238dc2..cff2518 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTestHelpers.h +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTestHelpers.h
@@ -204,10 +204,7 @@ } void ProduceTextureDirectCHROMIUM(GLuint texture, - GLenum target, const GLbyte* mailbox) override { - ASSERT_EQ(target, DrawingBufferTextureTarget()); - if (!create_image_chromium_fail_) { ASSERT_TRUE(texture_sizes_.Contains(texture)); most_recently_produced_size_ = texture_sizes_.at(texture);
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/GraphicsContext3DUtils.cpp b/third_party/WebKit/Source/platform/graphics/gpu/GraphicsContext3DUtils.cpp index 1c567d44..0de4ace 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/GraphicsContext3DUtils.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/GraphicsContext3DUtils.cpp
@@ -65,7 +65,7 @@ GLuint texture_id = skia::GrBackendObjectToGrGLTextureInfo(image->getTextureHandle(true)) ->fID; - gl->ProduceTextureDirectCHROMIUM(texture_id, GL_TEXTURE_2D, out_mailbox.name); + gl->ProduceTextureDirectCHROMIUM(texture_id, out_mailbox.name); // We changed bound textures in ProduceTextureDirectCHROMIUM, so reset the // GrContext.
diff --git a/third_party/WebKit/common/BUILD.gn b/third_party/WebKit/common/BUILD.gn index 900946fc..07c734b 100644 --- a/third_party/WebKit/common/BUILD.gn +++ b/third_party/WebKit/common/BUILD.gn
@@ -112,8 +112,16 @@ "blob/blob_registry.mojom", "clipboard/clipboard.mojom", "page/page_visibility_state.mojom", + "service_worker/navigation_preload_state.mojom", + "service_worker/service_worker.mojom", "service_worker/service_worker_client.mojom", + "service_worker/service_worker_error_type.mojom", + "service_worker/service_worker_event_status.mojom", + "service_worker/service_worker_object.mojom", "service_worker/service_worker_provider_type.mojom", + "service_worker/service_worker_registration.mojom", + "service_worker/service_worker_state.mojom", + "service_worker/service_worker_stream_handle.mojom", ] public_deps = [
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/navigation_preload_state.mojom b/third_party/WebKit/common/service_worker/navigation_preload_state.mojom similarity index 100% rename from third_party/WebKit/public/platform/modules/serviceworker/navigation_preload_state.mojom rename to third_party/WebKit/common/service_worker/navigation_preload_state.mojom
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom b/third_party/WebKit/common/service_worker/service_worker.mojom similarity index 100% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom rename to third_party/WebKit/common/service_worker/service_worker.mojom
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom b/third_party/WebKit/common/service_worker/service_worker_error_type.mojom similarity index 100% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom rename to third_party/WebKit/common/service_worker/service_worker_error_type.mojom
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom b/third_party/WebKit/common/service_worker/service_worker_event_status.mojom similarity index 100% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom rename to third_party/WebKit/common/service_worker/service_worker_event_status.mojom
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom b/third_party/WebKit/common/service_worker/service_worker_object.mojom similarity index 91% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom rename to third_party/WebKit/common/service_worker/service_worker_object.mojom index 143253b..c16be3e 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom +++ b/third_party/WebKit/common/service_worker/service_worker_object.mojom
@@ -4,7 +4,7 @@ module blink.mojom; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_state.mojom"; import "url/mojo/url.mojom"; const int32 kInvalidServiceWorkerHandleId = -1;
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom b/third_party/WebKit/common/service_worker/service_worker_registration.mojom similarity index 93% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom rename to third_party/WebKit/common/service_worker/service_worker_registration.mojom index 491afce6..34eb9215 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom +++ b/third_party/WebKit/common/service_worker/service_worker_registration.mojom
@@ -4,9 +4,9 @@ module blink.mojom; -import "third_party/WebKit/public/platform/modules/serviceworker/navigation_preload_state.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom"; -import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom"; +import "third_party/WebKit/common/service_worker/navigation_preload_state.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_error_type.mojom"; +import "third_party/WebKit/common/service_worker/service_worker_object.mojom"; import "url/mojo/url.mojom"; const int64 kInvalidServiceWorkerRegistrationId = -1;
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom b/third_party/WebKit/common/service_worker/service_worker_state.mojom similarity index 100% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom rename to third_party/WebKit/common/service_worker/service_worker_state.mojom
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom b/third_party/WebKit/common/service_worker/service_worker_stream_handle.mojom similarity index 100% rename from third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom rename to third_party/WebKit/common/service_worker/service_worker_stream_handle.mojom
diff --git a/third_party/WebKit/public/BUILD.gn b/third_party/WebKit/public/BUILD.gn index 4372199..990e7e6a 100644 --- a/third_party/WebKit/public/BUILD.gn +++ b/third_party/WebKit/public/BUILD.gn
@@ -791,14 +791,6 @@ "platform/modules/permissions/permission.mojom", "platform/modules/permissions/permission_status.mojom", "platform/modules/presentation/presentation.mojom", - "platform/modules/serviceworker/navigation_preload_state.mojom", - "platform/modules/serviceworker/service_worker.mojom", - "platform/modules/serviceworker/service_worker_error_type.mojom", - "platform/modules/serviceworker/service_worker_event_status.mojom", - "platform/modules/serviceworker/service_worker_object.mojom", - "platform/modules/serviceworker/service_worker_registration.mojom", - "platform/modules/serviceworker/service_worker_state.mojom", - "platform/modules/serviceworker/service_worker_stream_handle.mojom", "platform/modules/webauth/authenticator.mojom", "platform/modules/webdatabase/web_database.mojom", "platform/modules/websockets/websocket.mojom",
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/OWNERS b/third_party/WebKit/public/platform/modules/serviceworker/OWNERS index 4a73d48..299b6b92 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/OWNERS +++ b/third_party/WebKit/public/platform/modules/serviceworker/OWNERS
@@ -1,7 +1,4 @@ file://content/browser/service_worker/OWNERS -per-file *.mojom=set noparent -per-file *.mojom=file://ipc/SECURITY_OWNERS - # TEAM: worker-dev@chromium.org # COMPONENT: Blink>ServiceWorker
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorker.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorker.h index 44c30e7..de071679 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorker.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorker.h
@@ -35,7 +35,7 @@ #include "public/platform/WebString.h" #include "public/platform/WebURL.h" #include "public/platform/WebVector.h" -#include "public/platform/modules/serviceworker/service_worker_state.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_state.mojom-shared.h" namespace blink {
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h index 8a27a76..cf26deb 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h
@@ -32,7 +32,7 @@ #define WebServiceWorkerError_h #include "public/platform/WebString.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-shared.h" namespace blink {
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h index 0e09a96..3e6bd9b 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProvider.h
@@ -34,7 +34,7 @@ #include "public/platform/WebCallbacks.h" #include "public/platform/WebVector.h" #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" -#include "public/platform/modules/serviceworker/service_worker_registration.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom-shared.h" #include <memory>
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h index 9e45794e8..019d3ba 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h
@@ -10,7 +10,7 @@ #include "public/platform/WebCallbacks.h" #include "public/platform/WebURL.h" #include "public/platform/modules/serviceworker/WebServiceWorkerError.h" -#include "public/platform/modules/serviceworker/service_worker_registration.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_registration.mojom-shared.h" namespace blink {
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h index d4d7a821..f2482c8 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h
@@ -13,8 +13,8 @@ #include "public/platform/WebURL.h" #include "public/platform/WebVector.h" #include "public/platform/modules/fetch/fetch_api_request.mojom-shared.h" -#include "public/platform/modules/serviceworker/service_worker_error_type.mojom-shared.h" #include "services/network/public/interfaces/fetch_api.mojom-shared.h" +#include "third_party/WebKit/common/service_worker/service_worker_error_type.mojom-shared.h" #if INSIDE_BLINK #include "platform/wtf/Forward.h"
diff --git a/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h b/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h index 37ceacc..2fffffe 100644 --- a/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h +++ b/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h
@@ -39,8 +39,8 @@ #include "public/platform/modules/serviceworker/WebServiceWorkerClientsInfo.h" #include "public/platform/modules/serviceworker/WebServiceWorkerSkipWaitingCallbacks.h" #include "public/platform/modules/serviceworker/WebServiceWorkerStreamHandle.h" -#include "public/platform/modules/serviceworker/service_worker_event_status.mojom-shared.h" #include "public/web/WebDevToolsAgentClient.h" +#include "third_party/WebKit/common/service_worker/service_worker_event_status.mojom-shared.h" #include "v8/include/v8.h" namespace blink {
diff --git a/third_party/libwebp/BUILD.gn b/third_party/libwebp/BUILD.gn index c643e48..7c4bab0 100644 --- a/third_party/libwebp/BUILD.gn +++ b/third_party/libwebp/BUILD.gn
@@ -15,6 +15,7 @@ defines = [ "WEBP_NEAR_LOSSLESS=0", "WEBP_DISABLE_STATS", + "WEBP_REDUCE_SIZE", ] if (!is_ios) { defines += [ "WEBP_REDUCE_CSP" ]
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index a0a10a4e..86382df 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -164,7 +164,6 @@ 'Afl Upload Linux ASan': 'release_afl_asan', 'Android Builder (dbg)': 'android_debug_static_bot_vrdata', - 'Android Builder Goma Canary (dbg)': 'android_debug_static_bot_vrdata', 'Android Builder (dbg) Goma Canary': 'android_debug_static_bot_vrdata', 'Android deterministic': 'android_without_codecs_release_bot_minimal_symbols', @@ -173,16 +172,10 @@ 'CFI Linux CF': 'cfi_full_cfi_diag_recover_release_static', 'CFI Linux ToT': 'clang_tot_cfi_full_cfi_diag_thin_lto_release_static_dcheck_always_on', 'CFI Linux (icall)': 'cfi_full_diag_icall_release_static_dcheck_always_on', - 'ChromeOS amd64 Chromium Goma Canary': 'cros_chrome_sdk', 'chromeos-amd64-generic-rel-goma-canary': 'cros_chrome_sdk', - 'Chromium Linux Goma Canary': 'release_trybot', 'Linux Builder Goma Canary': 'release_bot', - - 'Chromium Linux Goma Canary (clobber)': 'release_bot', 'Linux x64 Goma Canary (clobber)': 'release_bot', - - 'Chromium Linux Goma Canary LocalOutputCache': 'release_bot', 'Linux x64 Goma Canary LocalOutputCache': 'release_bot', 'Chromium Mac 10.10 MacViews': 'mac_views_browser_release_bot', @@ -190,19 +183,10 @@ 'Chromium Mac 10.11 Force Mac Toolchain': 'release_bot_mac_new_sdk', 'Chromium Mac 10.13': 'release_bot', - 'Chromium Mac 10.9 Goma Canary': 'gpu_tests_release_trybot', 'Mac Builder Goma Canary': 'gpu_tests_release_bot', - - 'Chromium Mac 10.9 Goma Canary (clobber)': 'release_bot_mac_strip', 'Mac Goma Canary (clobber)': 'release_bot_mac_strip', - - 'Chromium Mac 10.9 Goma Canary (dbg)': 'debug_trybot', 'Mac Builder (dbg) Goma Canary': 'debug_bot', - - 'Chromium Mac 10.9 Goma Canary (dbg)(clobber)': 'debug_trybot', 'Mac Builder (dbg) Goma Canary (clobber)': 'debug_bot', - - 'Chromium Mac Goma Canary LocalOutputCache': 'release_bot_mac_strip', 'Mac Goma Canary LocalOutputCache': 'release_bot_mac_strip', 'Chromium Win 10 GCE Tests': 'release_bot_minimal_symbols', @@ -216,37 +200,20 @@ }, 'Chromium Windows Analyze': 'windows_analyze', - 'CrWin7Goma': 'gpu_tests_release_trybot_x86_minimal_symbols', 'Win7 Builder Goma Canary': 'release_bot_x86_minimal_symbols', - - 'CrWin7Goma(dbg)': 'debug_trybot_x86_minimal_symbols', 'Win7 Builder (dbg) Goma Canary': 'debug_trybot_x86_minimal_symbols', - - 'CrWin7Goma(dll)': 'gpu_tests_release_trybot_x86_shared_minimal_symbols', 'Win cl.exe Goma Canary LocalOutputCache': 'release_bot_x86_minimal_symbols_no_clang', - - 'CrWinGoma': 'gpu_tests_release_trybot_x86_minimal_symbols', 'Win Builder Goma Canary': 'release_bot_x86_minimal_symbols', - - 'CrWinGoma(dll)': 'gpu_tests_release_trybot_x86_shared_minimal_symbols', 'Win Builder (dbg) Goma Canary': 'debug_bot_x86_minimal_symbols', - - 'CrWinGoma(loc)': 'release_bot_x86_minimal_symbols', 'Win Goma Canary LocalOutputCache': 'release_bot_x86_minimal_symbols', - - 'CrWinClexeGoma': 'release_bot_x86_minimal_symbols_no_clang', 'WinMSVC64 Goma Canary': 'win_msvc_release_bot', - 'CrWinClangGoma': 'clang_official_release_bot_minimal_symbols_x86_clang', - 'ToTWin Goma Canary': 'clang_tot_official_minimal_symbols_static_release_x86', - 'EarlGreyiOS': 'ios', 'Fuchsia (dbg)': 'debug_bot_fuchsia', 'Fuchsia ARM64': 'release_bot_fuchsia_arm64', 'Fuchsia x64': 'release_bot_fuchsia', 'Fuchsia': 'release_bot_fuchsia', - 'GomaCanaryiOS': 'ios', 'ios-device-goma-canary-clobber': 'ios', 'ios-simulator': 'ios', @@ -1167,12 +1134,6 @@ 'clang', 'release_bot', 'minimal_symbols', 'x86', ], - 'clang_official_release_bot_minimal_symbols_x86_clang': [ - # force clang enabled for clang_official_release_bot_minimal_symbols_x86 - # for CrWinClangGoma - 'clang', 'official', 'release_bot', 'minimal_symbols', 'x86', - ], - 'clang_official_release_trybot': [ 'clang', 'official', 'release_trybot', @@ -1425,10 +1386,6 @@ 'gpu_tests', 'release_trybot', 'x86', 'minimal_symbols', ], - 'gpu_tests_release_trybot_x86_shared_minimal_symbols': [ - 'gpu_tests', 'release_trybot', 'x86', 'shared', 'minimal_symbols', - ], - 'gpu_tests_release_bot': [ 'gpu_tests', 'release_bot', ],
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 4d6c2e47..6f07c69 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -13481,6 +13481,15 @@ </summary> </histogram> +<histogram name="DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch" + enum="BooleanSuccess"> + <owner>tbansal@chromium.org</owner> + <summary> + Whether the warmup (or probe) URL was successfully fetched over a data saver + proxy. + </summary> +</histogram> + <histogram name="DataUsage.MatchingRulesCount.Invalid" units="count"> <owner>bengr@chromium.org</owner> <owner>rajendrant@chromium.org</owner> @@ -68866,6 +68875,11 @@ <histogram name="Renderer4.CompositorScrollHitTestResult" enum="CompositorScrollResult"> + <obsolete> + Deprecated in 12/2017. Renderer4.MainThreadGestureScrollReason and + Renderer4.MainThreadWheelScrollReason could track more detailed reasons of + main thread scrolling. + </obsolete> <owner>vollick@chromium.org</owner> <summary> It's possible for compositor hit testing to determine conclusively that @@ -100760,6 +100774,20 @@ <affected-histogram name="Previews.OriginalContentLength"/> </histogram_suffixes> +<histogram_suffixes name="DataSaverProxyTypes" separator="."> + <owner>tbansal@chromium.org</owner> + <suffix name="SecureProxy.Core" + label="Over a secure, core data saver proxy."/> + <suffix name="SecureProxy.NonCore" + label="Over a secure, non-core data saver proxy."/> + <suffix name="InsecureProxy.Core" + label="Over an insecure, core data saver proxy."/> + <suffix name="InsecureProxy.NonCore" + label="Over an insecure, non-core data saver proxy."/> + <affected-histogram + name="DataReductionProxy.WarmupURLFetcherCallback.SuccessfulFetch"/> +</histogram_suffixes> + <histogram_suffixes name="DataUsageReportSubmissionBytes" separator="."> <suffix name="Failed" label="Platform external data use observer reported the submission as
diff --git a/ui/aura/event_injector.cc b/ui/aura/event_injector.cc index ca31c16d..f13e0674 100644 --- a/ui/aura/event_injector.cc +++ b/ui/aura/event_injector.cc
@@ -51,8 +51,8 @@ // root location. The non-ui-service code does this by way of // OnEventFromSource() ending up in LocatedEvent::UpdateForRootTransform(), // which reset the root_location to match the location. - event->AsLocatedEvent()->set_location_f( - event->AsLocatedEvent()->root_location_f()); + event->AsLocatedEvent()->set_root_location_f( + event->AsLocatedEvent()->location_f()); } if (!remote_event_dispatcher_) {
diff --git a/ui/events/blink/input_handler_proxy.cc b/ui/events/blink/input_handler_proxy.cc index b8f266e..d488b872 100644 --- a/ui/events/blink/input_handler_proxy.cc +++ b/ui/events/blink/input_handler_proxy.cc
@@ -797,10 +797,6 @@ scroll_status = input_handler_->ScrollBegin( &scroll_state, GestureScrollInputType(gesture_event.source_device)); } - UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", - scroll_status.thread, - cc::InputHandler::LAST_SCROLL_STATUS + 1); - RecordMainThreadScrollingReasons(gesture_event.source_device, scroll_status.main_thread_scrolling_reasons);
diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc index 0ec1bd1..6ea6b5aa 100644 --- a/ui/ozone/platform/x11/ozone_platform_x11.cc +++ b/ui/ozone/platform/x11/ozone_platform_x11.cc
@@ -114,9 +114,9 @@ if (common_initialized_) return; - // In single process mode XInitThreads() must be the first Xlib call. - if (params.single_process) - XInitThreads(); + // Always initialze in multi-thread mode, since this is used only during + // development. + XInitThreads(); ui::SetDefaultX11ErrorHandlers();