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

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

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

Powered by Google App Engine
This is Rietveld 408576698