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

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 1865913005: Nuke WebPassOwnPtr<T> and replace it with std::unique_ptr<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "public/platform/modules/notifications/WebNotificationData.h" 60 #include "public/platform/modules/notifications/WebNotificationData.h"
61 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" 61 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h"
62 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" 62 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
63 #include "public/web/WebSerializedScriptValue.h" 63 #include "public/web/WebSerializedScriptValue.h"
64 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 64 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
65 #include "web/WebEmbeddedWorkerImpl.h" 65 #include "web/WebEmbeddedWorkerImpl.h"
66 #include "wtf/Assertions.h" 66 #include "wtf/Assertions.h"
67 #include "wtf/Functional.h" 67 #include "wtf/Functional.h"
68 #include "wtf/PassOwnPtr.h" 68 #include "wtf/PassOwnPtr.h"
69 69
70 #include <utility>
71
70 namespace blink { 72 namespace blink {
71 73
72 RawPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create(WebE mbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerContextCl ient& client) 74 RawPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create(WebE mbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerContextCl ient& client)
73 { 75 {
74 return new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client); 76 return new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client);
75 } 77 }
76 78
77 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() 79 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy()
78 { 80 {
79 // Verify that the proxy has been detached. 81 // Verify that the proxy has been detached.
80 DCHECK(!m_embeddedWorker); 82 DCHECK(!m_embeddedWorker);
81 } 83 }
82 84
83 DEFINE_TRACE(ServiceWorkerGlobalScopeProxy) 85 DEFINE_TRACE(ServiceWorkerGlobalScopeProxy)
84 { 86 {
85 visitor->trace(m_document); 87 visitor->trace(m_document);
86 visitor->trace(m_workerGlobalScope); 88 visitor->trace(m_workerGlobalScope);
87 } 89 }
88 90
89 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork erRegistration::Handle> handle) 91 void ServiceWorkerGlobalScopeProxy::setRegistration(std::unique_ptr<WebServiceWo rkerRegistration::Handle> handle)
90 { 92 {
91 workerGlobalScope()->setRegistration(handle); 93 workerGlobalScope()->setRegistration(std::move(handle));
92 } 94 }
93 95
94 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) 96 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID)
95 { 97 {
96 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID); 98 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID);
97 RawPtr<Event> event(ExtendableEvent::create(EventTypeNames::activate, Extend ableEventInit(), observer)); 99 RawPtr<Event> event(ExtendableEvent::create(EventTypeNames::activate, Extend ableEventInit(), observer));
98 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 100 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
99 } 101 }
100 102
101 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client) 103 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client)
102 { 104 {
103 DCHECK(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ; 105 DCHECK(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
104 106
105 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 107 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
106 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 108 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
107 String origin; 109 String origin;
108 if (!sourceOrigin.isUnique()) 110 if (!sourceOrigin.isUnique())
109 origin = sourceOrigin.toString(); 111 origin = sourceOrigin.toString();
110 ServiceWorkerClient* source = nullptr; 112 ServiceWorkerClient* source = nullptr;
111 if (client.clientType == WebServiceWorkerClientTypeWindow) 113 if (client.clientType == WebServiceWorkerClientTypeWindow)
112 source = ServiceWorkerWindowClient::create(client); 114 source = ServiceWorkerWindowClient::create(client);
113 else 115 else
114 source = ServiceWorkerClient::create(client); 116 source = ServiceWorkerClient::create(client);
115 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 117 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
116 118
117 RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou rce, observer)); 119 RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou rce, observer));
118 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 120 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
119 } 121 }
120 122
121 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, WebPassOwnPtr<WebServiceWorker::Handle> handle) 123 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, std::unique_ptr<WebServiceWorker::Handle> handle )
122 { 124 {
123 DCHECK(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ; 125 DCHECK(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
124 126
125 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 127 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
126 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 128 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
127 String origin; 129 String origin;
128 if (!sourceOrigin.isUnique()) 130 if (!sourceOrigin.isUnique())
129 origin = sourceOrigin.toString(); 131 origin = sourceOrigin.toString();
130 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio nContext(), handle.release()); 132 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio nContext(), adoptPtr(handle.release()));
131 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 133 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
132 134
133 RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou rce, observer)); 135 RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou rce, observer));
134 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 136 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
135 } 137 }
136 138
137 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) 139 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest)
138 { 140 {
139 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); 141 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch);
140 } 142 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 eventInit.setCancelable(true); 304 eventInit.setCancelable(true);
303 eventInit.setRequest(request); 305 eventInit.setRequest(request);
304 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 306 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
305 eventInit.setIsReload(webRequest.isReload()); 307 eventInit.setIsReload(webRequest.isReload());
306 RawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, o bserver)); 308 RawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, o bserver));
307 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent.release()); 309 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent.release());
308 observer->didDispatchEvent(dispatchResult); 310 observer->didDispatchEvent(dispatchResult);
309 } 311 }
310 312
311 } // namespace blink 313 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698