Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2436223004: Use the serviceworker with mojo by default (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 version_id = infos[index].active_version.version_id; 329 version_id = infos[index].active_version.version_id;
330 else 330 else
331 return; 331 return;
332 332
333 ServiceWorkerVersion* version = wrapper->GetLiveVersion(version_id); 333 ServiceWorkerVersion* version = wrapper->GetLiveVersion(version_id);
334 *num_resources = static_cast<int>(version->script_cache_map()->size()); 334 *num_resources = static_cast<int>(version->script_cache_map()->size());
335 } 335 }
336 336
337 } // namespace 337 } // namespace
338 338
339 class ServiceWorkerBrowserTest : public testing::WithParamInterface<bool>, 339 class ServiceWorkerBrowserTest
340 public ContentBrowserTest { 340 : public MojoServiceWorkerTestP<ContentBrowserTest> {
341 protected: 341 protected:
342 using self = ServiceWorkerBrowserTest; 342 using self = ServiceWorkerBrowserTest;
343 343
344 void SetUp() override {
345 is_mojo_enabled_ = GetParam();
346 if (is_mojo_enabled()) {
347 base::CommandLine::ForCurrentProcess()->AppendSwitch(
348 switches::kMojoServiceWorker);
349 }
350 ContentBrowserTest::SetUp();
351 }
352
353 void SetUpOnMainThread() override { 344 void SetUpOnMainThread() override {
354 ASSERT_TRUE(embedded_test_server()->Start()); 345 ASSERT_TRUE(embedded_test_server()->Start());
355 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition( 346 StoragePartition* partition = BrowserContext::GetDefaultStoragePartition(
356 shell()->web_contents()->GetBrowserContext()); 347 shell()->web_contents()->GetBrowserContext());
357 wrapper_ = static_cast<ServiceWorkerContextWrapper*>( 348 wrapper_ = static_cast<ServiceWorkerContextWrapper*>(
358 partition->GetServiceWorkerContext()); 349 partition->GetServiceWorkerContext());
359 350
360 // Navigate to the page to set up a renderer page (where we can embed 351 // Navigate to the page to set up a renderer page (where we can embed
361 // a worker). 352 // a worker).
362 NavigateToURLBlockUntilNavigationsComplete( 353 NavigateToURLBlockUntilNavigationsComplete(
363 shell(), 354 shell(),
364 embedded_test_server()->GetURL("/service_worker/empty.html"), 1); 355 embedded_test_server()->GetURL("/service_worker/empty.html"), 1);
365 356
366 RunOnIOThread(base::Bind(&self::SetUpOnIOThread, base::Unretained(this))); 357 RunOnIOThread(base::Bind(&self::SetUpOnIOThread, base::Unretained(this)));
367 } 358 }
368 359
369 void TearDownOnMainThread() override { 360 void TearDownOnMainThread() override {
370 RunOnIOThread( 361 RunOnIOThread(
371 base::Bind(&self::TearDownOnIOThread, base::Unretained(this))); 362 base::Bind(&self::TearDownOnIOThread, base::Unretained(this)));
372 wrapper_ = NULL; 363 wrapper_ = NULL;
373 } 364 }
374 365
375 virtual void SetUpOnIOThread() {} 366 virtual void SetUpOnIOThread() {}
376 virtual void TearDownOnIOThread() {} 367 virtual void TearDownOnIOThread() {}
377 368
378 ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); } 369 ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); }
379 ServiceWorkerContext* public_context() { return wrapper(); } 370 ServiceWorkerContext* public_context() { return wrapper(); }
380 bool is_mojo_enabled() const { return is_mojo_enabled_; }
381 371
382 void AssociateRendererProcessToPattern(const GURL& pattern) { 372 void AssociateRendererProcessToPattern(const GURL& pattern) {
383 wrapper_->process_manager()->AddProcessReferenceToPattern( 373 wrapper_->process_manager()->AddProcessReferenceToPattern(
384 pattern, shell()->web_contents()->GetRenderProcessHost()->GetID()); 374 pattern, shell()->web_contents()->GetRenderProcessHost()->GetID());
385 } 375 }
386 376
387 private: 377 private:
388 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; 378 scoped_refptr<ServiceWorkerContextWrapper> wrapper_;
389 bool is_mojo_enabled_ = false;
390 }; 379 };
391 380
392 class ConsoleListener : public EmbeddedWorkerInstance::Listener { 381 class ConsoleListener : public EmbeddedWorkerInstance::Listener {
393 public: 382 public:
394 void OnReportConsoleMessage(int source_identifier, 383 void OnReportConsoleMessage(int source_identifier,
395 int message_level, 384 int message_level,
396 const base::string16& message, 385 const base::string16& message,
397 int line_number, 386 int line_number,
398 const GURL& source_url) override { 387 const GURL& source_url) override {
399 DCHECK_CURRENTLY_ON(BrowserThread::IO); 388 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 ServiceWorkerV8CacheStrategiesNormalTest, 2057 ServiceWorkerV8CacheStrategiesNormalTest,
2069 ::testing::Values(true, false)); 2058 ::testing::Values(true, false));
2070 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 2059 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
2071 ServiceWorkerV8CacheStrategiesAggressiveTest, 2060 ServiceWorkerV8CacheStrategiesAggressiveTest,
2072 ::testing::Values(true, false)); 2061 ::testing::Values(true, false));
2073 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest, 2062 INSTANTIATE_TEST_CASE_P(ServiceWorkerBrowserTest,
2074 ServiceWorkerDisableWebSecurityTest, 2063 ServiceWorkerDisableWebSecurityTest,
2075 ::testing::Values(true, false)); 2064 ::testing::Values(true, false));
2076 2065
2077 } // namespace content 2066 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698