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

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

Issue 440403002: Don't share ServiceWorkerHandle between provider hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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_handle.h" 5 #include "content/browser/service_worker/service_worker_handle.h"
6 6
7 #include "content/browser/service_worker/service_worker_context_core.h" 7 #include "content/browser/service_worker/service_worker_context_core.h"
8 #include "content/browser/service_worker/service_worker_registration.h" 8 #include "content/browser/service_worker/service_worker_registration.h"
9 #include "content/common/service_worker/service_worker_messages.h" 9 #include "content/common/service_worker/service_worker_messages.h"
10 #include "ipc/ipc_sender.h" 10 #include "ipc/ipc_sender.h"
(...skipping 25 matching lines...) Expand all
36 NOTREACHED() << version->status(); 36 NOTREACHED() << version->status();
37 return blink::WebServiceWorkerStateUnknown; 37 return blink::WebServiceWorkerStateUnknown;
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 scoped_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create( 42 scoped_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create(
43 base::WeakPtr<ServiceWorkerContextCore> context, 43 base::WeakPtr<ServiceWorkerContextCore> context,
44 IPC::Sender* sender, 44 IPC::Sender* sender,
45 int thread_id, 45 int thread_id,
46 int provider_id,
46 ServiceWorkerVersion* version) { 47 ServiceWorkerVersion* version) {
47 if (!context || !version) 48 if (!context || !version)
48 return scoped_ptr<ServiceWorkerHandle>(); 49 return scoped_ptr<ServiceWorkerHandle>();
49 ServiceWorkerRegistration* registration = 50 ServiceWorkerRegistration* registration =
50 context->GetLiveRegistration(version->registration_id()); 51 context->GetLiveRegistration(version->registration_id());
51 return make_scoped_ptr( 52 return make_scoped_ptr(new ServiceWorkerHandle(
52 new ServiceWorkerHandle(context, sender, thread_id, 53 context, sender, thread_id, provider_id, registration, version));
53 registration, version));
54 } 54 }
55 55
56 ServiceWorkerHandle::ServiceWorkerHandle( 56 ServiceWorkerHandle::ServiceWorkerHandle(
57 base::WeakPtr<ServiceWorkerContextCore> context, 57 base::WeakPtr<ServiceWorkerContextCore> context,
58 IPC::Sender* sender, 58 IPC::Sender* sender,
59 int thread_id, 59 int thread_id,
60 int provider_id,
60 ServiceWorkerRegistration* registration, 61 ServiceWorkerRegistration* registration,
61 ServiceWorkerVersion* version) 62 ServiceWorkerVersion* version)
62 : context_(context), 63 : context_(context),
63 sender_(sender), 64 sender_(sender),
64 thread_id_(thread_id), 65 thread_id_(thread_id),
66 provider_id_(provider_id),
65 handle_id_(context.get() ? context->GetNewServiceWorkerHandleId() : -1), 67 handle_id_(context.get() ? context->GetNewServiceWorkerHandleId() : -1),
66 ref_count_(1), 68 ref_count_(1),
67 registration_(registration), 69 registration_(registration),
68 version_(version) { 70 version_(version) {
69 version_->AddListener(this); 71 version_->AddListener(this);
70 } 72 }
71 73
72 ServiceWorkerHandle::~ServiceWorkerHandle() { 74 ServiceWorkerHandle::~ServiceWorkerHandle() {
73 version_->RemoveListener(this); 75 version_->RemoveListener(this);
74 // TODO(kinuko): At this point we can discard the registration if 76 // TODO(kinuko): At this point we can discard the registration if
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 DCHECK_GT(ref_count_, 0); 119 DCHECK_GT(ref_count_, 0);
118 ++ref_count_; 120 ++ref_count_;
119 } 121 }
120 122
121 void ServiceWorkerHandle::DecrementRefCount() { 123 void ServiceWorkerHandle::DecrementRefCount() {
122 DCHECK_GE(ref_count_, 0); 124 DCHECK_GE(ref_count_, 0);
123 --ref_count_; 125 --ref_count_;
124 } 126 }
125 127
126 } // namespace content 128 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698