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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Add missing ScopedAsyncTaskScheduler instance for the new unit tests; required by a recent change t… 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 /* 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 ServiceWorkerContainerClient* client = 56 ServiceWorkerContainerClient* client =
57 ServiceWorkerContainerClient::from(getExecutionContext()); 57 ServiceWorkerContainerClient::from(getExecutionContext());
58 if (!client || !client->provider()) { 58 if (!client || !client->provider()) {
59 exceptionState.throwDOMException( 59 exceptionState.throwDOMException(
60 InvalidStateError, 60 InvalidStateError,
61 "Failed to post a message: No associated provider is available."); 61 "Failed to post a message: No associated provider is available.");
62 return; 62 return;
63 } 63 }
64 64
65 // Disentangle the port in preparation for sending it to the remote context. 65 // Disentangle the port in preparation for sending it to the remote context.
66 std::unique_ptr<MessagePortChannelArray> channels = 66 MessagePortChannelArray channels =
67 MessagePort::disentanglePorts(scriptState->getExecutionContext(), ports, 67 MessagePort::disentanglePorts(scriptState->getExecutionContext(), ports,
68 exceptionState); 68 exceptionState);
69 if (exceptionState.hadException()) 69 if (exceptionState.hadException())
70 return; 70 return;
71 if (m_handle->serviceWorker()->state() == WebServiceWorkerStateRedundant) { 71 if (m_handle->serviceWorker()->state() == WebServiceWorkerStateRedundant) {
72 exceptionState.throwDOMException(InvalidStateError, 72 exceptionState.throwDOMException(InvalidStateError,
73 "ServiceWorker is in redundant state."); 73 "ServiceWorker is in redundant state.");
74 return; 74 return;
75 } 75 }
76 76
77 WebString messageString = message->toWireString(); 77 WebString messageString = message->toWireString();
78 std::unique_ptr<WebMessagePortChannelArray> webChannels = 78 WebMessagePortChannelArray webChannels =
79 MessagePort::toWebMessagePortChannelArray(std::move(channels)); 79 MessagePort::toWebMessagePortChannelArray(std::move(channels));
80 m_handle->serviceWorker()->postMessage( 80 m_handle->serviceWorker()->postMessage(
81 client->provider(), messageString, 81 client->provider(), messageString,
82 WebSecurityOrigin(getExecutionContext()->getSecurityOrigin()), 82 WebSecurityOrigin(getExecutionContext()->getSecurityOrigin()),
83 webChannels.release()); 83 std::move(webChannels));
84 } 84 }
85 85
86 void ServiceWorker::internalsTerminate() { 86 void ServiceWorker::internalsTerminate() {
87 m_handle->serviceWorker()->terminate(); 87 m_handle->serviceWorker()->terminate();
88 } 88 }
89 89
90 void ServiceWorker::dispatchStateChangeEvent() { 90 void ServiceWorker::dispatchStateChangeEvent() {
91 this->dispatchEvent(Event::create(EventTypeNames::statechange)); 91 this->dispatchEvent(Event::create(EventTypeNames::statechange));
92 } 92 }
93 93
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 m_handle->serviceWorker()->setProxy(this); 158 m_handle->serviceWorker()->setProxy(this);
159 } 159 }
160 160
161 ServiceWorker::~ServiceWorker() {} 161 ServiceWorker::~ServiceWorker() {}
162 162
163 DEFINE_TRACE(ServiceWorker) { 163 DEFINE_TRACE(ServiceWorker) {
164 AbstractWorker::trace(visitor); 164 AbstractWorker::trace(visitor);
165 } 165 }
166 166
167 } // namespace blink 167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698