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

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

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Add a newline Created 3 years, 10 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 "content/browser/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 648 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
649 CreateReceiverOnCurrentThread(&status)); 649 CreateReceiverOnCurrentThread(&status));
650 base::RunLoop().RunUntilIdle(); 650 base::RunLoop().RunUntilIdle();
651 EXPECT_EQ(SERVICE_WORKER_OK, status); 651 EXPECT_EQ(SERVICE_WORKER_OK, status);
652 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 652 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
653 EXPECT_LT(idle_time, version_->idle_time_); 653 EXPECT_LT(idle_time, version_->idle_time_);
654 654
655 // Adding a controllee resets the idle time. 655 // Adding a controllee resets the idle time.
656 version_->idle_time_ -= kOneSecond; 656 version_->idle_time_ -= kOneSecond;
657 idle_time = version_->idle_time_; 657 idle_time = version_->idle_time_;
658 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 658 std::unique_ptr<ServiceWorkerProviderHost> host =
659 33 /* dummy render process id */, MSG_ROUTING_NONE /* render_frame_id */, 659 ServiceWorkerProviderHost::CreateForTesting(
660 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 660 33 /* dummy render process id */, 1 /* dummy provider_id */,
661 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, 661 SERVICE_WORKER_PROVIDER_FOR_WINDOW, helper_->context()->AsWeakPtr());
662 helper_->context()->AsWeakPtr(), NULL)); 662 host->set_parent_frame_secure(true);
663 version_->AddControllee(host.get()); 663 version_->AddControllee(host.get());
664 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 664 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
665 EXPECT_LT(idle_time, version_->idle_time_); 665 EXPECT_LT(idle_time, version_->idle_time_);
666 666
667 // Completing an event resets the idle time. 667 // Completing an event resets the idle time.
668 version_->idle_time_ -= kOneSecond; 668 version_->idle_time_ -= kOneSecond;
669 idle_time = version_->idle_time_; 669 idle_time = version_->idle_time_;
670 SimulateDispatchEvent(ServiceWorkerMetrics::EventType::FETCH_MAIN_FRAME); 670 SimulateDispatchEvent(ServiceWorkerMetrics::EventType::FETCH_MAIN_FRAME);
671 EXPECT_LT(idle_time, version_->idle_time_); 671 EXPECT_LT(idle_time, version_->idle_time_);
672 672
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); 1855 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1);
1856 histogram_tester_.ExpectTotalCount(kLinkTapDown, 0); 1856 histogram_tester_.ExpectTotalCount(kLinkTapDown, 0);
1857 EXPECT_EQ(SERVICE_WORKER_OK, status); 1857 EXPECT_EQ(SERVICE_WORKER_OK, status);
1858 StopWorker(); 1858 StopWorker();
1859 // The UMA for kLinkMouseDown must be recorded when the worker stopped. 1859 // The UMA for kLinkMouseDown must be recorded when the worker stopped.
1860 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); 1860 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1);
1861 histogram_tester_.ExpectTotalCount(kLinkTapDown, 1); 1861 histogram_tester_.ExpectTotalCount(kLinkTapDown, 1);
1862 } 1862 }
1863 1863
1864 } // namespace content 1864 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698