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

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

Issue 1149383004: [3/5 chromium] Shows the clients which are controlled by ServiceWorker in DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "content/browser/service_worker/embedded_worker_test_helper.h" 8 #include "content/browser/service_worker/embedded_worker_test_helper.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_provider_host.h" 10 #include "content/browser/service_worker/service_worker_provider_host.h"
(...skipping 18 matching lines...) Expand all
29 new EmbeddedWorkerTestHelper(base::FilePath(), kRenderProcessId)); 29 new EmbeddedWorkerTestHelper(base::FilePath(), kRenderProcessId));
30 context_ = helper_->context(); 30 context_ = helper_->context();
31 script_url_ = GURL("http://www.example.com/service_worker.js"); 31 script_url_ = GURL("http://www.example.com/service_worker.js");
32 registration1_ = new ServiceWorkerRegistration( 32 registration1_ = new ServiceWorkerRegistration(
33 GURL("http://www.example.com/"), 1L, context_->AsWeakPtr()); 33 GURL("http://www.example.com/"), 1L, context_->AsWeakPtr());
34 registration2_ = new ServiceWorkerRegistration( 34 registration2_ = new ServiceWorkerRegistration(
35 GURL("http://www.example.com/example"), 2L, context_->AsWeakPtr()); 35 GURL("http://www.example.com/example"), 2L, context_->AsWeakPtr());
36 36
37 // Prepare provider hosts (for the same process). 37 // Prepare provider hosts (for the same process).
38 scoped_ptr<ServiceWorkerProviderHost> host1(new ServiceWorkerProviderHost( 38 scoped_ptr<ServiceWorkerProviderHost> host1(new ServiceWorkerProviderHost(
39 kRenderProcessId, MSG_ROUTING_NONE, 1 /* provider_id */, 39 kRenderProcessId, 1 /* render_frame_id */, MSG_ROUTING_NONE,
40 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context_->AsWeakPtr(), NULL)); 40 1 /* provider_id */, context_->AsWeakPtr(), NULL));
41 host1->SetDocumentUrl(GURL("http://www.example.com/example1.html")); 41 host1->SetDocumentUrl(GURL("http://www.example.com/example1.html"));
42 scoped_ptr<ServiceWorkerProviderHost> host2(new ServiceWorkerProviderHost( 42 scoped_ptr<ServiceWorkerProviderHost> host2(new ServiceWorkerProviderHost(
43 kRenderProcessId, MSG_ROUTING_NONE, 2 /* provider_id */, 43 kRenderProcessId, 2 /* render_frame_id */, MSG_ROUTING_NONE,
44 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context_->AsWeakPtr(), NULL)); 44 2 /* provider_id */, context_->AsWeakPtr(), NULL));
45 host2->SetDocumentUrl(GURL("http://www.example.com/example2.html")); 45 host2->SetDocumentUrl(GURL("http://www.example.com/example2.html"));
46 provider_host1_ = host1->AsWeakPtr(); 46 provider_host1_ = host1->AsWeakPtr();
47 provider_host2_ = host2->AsWeakPtr(); 47 provider_host2_ = host2->AsWeakPtr();
48 context_->AddProviderHost(make_scoped_ptr(host1.release())); 48 context_->AddProviderHost(make_scoped_ptr(host1.release()));
49 context_->AddProviderHost(make_scoped_ptr(host2.release())); 49 context_->AddProviderHost(make_scoped_ptr(host2.release()));
50 } 50 }
51 51
52 void TearDown() override { 52 void TearDown() override {
53 registration1_ = 0; 53 registration1_ = 0;
54 registration2_ = 0; 54 registration2_ = 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ASSERT_EQ(provider_host1_->MatchRegistration(), registration2_); 119 ASSERT_EQ(provider_host1_->MatchRegistration(), registration2_);
120 provider_host1_->RemoveMatchingRegistration(registration2_.get()); 120 provider_host1_->RemoveMatchingRegistration(registration2_.get());
121 ASSERT_EQ(provider_host1_->MatchRegistration(), registration1_); 121 ASSERT_EQ(provider_host1_->MatchRegistration(), registration1_);
122 122
123 // Should return nullptr after removing all matching registrations. 123 // Should return nullptr after removing all matching registrations.
124 provider_host1_->RemoveMatchingRegistration(registration1_.get()); 124 provider_host1_->RemoveMatchingRegistration(registration1_.get());
125 ASSERT_EQ(provider_host1_->MatchRegistration(), nullptr); 125 ASSERT_EQ(provider_host1_->MatchRegistration(), nullptr);
126 } 126 }
127 127
128 } // namespace content 128 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698