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

Side by Side Diff: third_party/WebKit/Source/core/dom/MessagePort.cpp

Issue 2583093002: Reduce SuspendableObjects (Closed)
Patch Set: Created 4 years 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 28 matching lines...) Expand all
39 #include "core/workers/WorkerGlobalScope.h" 39 #include "core/workers/WorkerGlobalScope.h"
40 #include "public/platform/WebString.h" 40 #include "public/platform/WebString.h"
41 #include "wtf/Functional.h" 41 #include "wtf/Functional.h"
42 #include "wtf/PtrUtil.h" 42 #include "wtf/PtrUtil.h"
43 #include "wtf/text/AtomicString.h" 43 #include "wtf/text/AtomicString.h"
44 #include <memory> 44 #include <memory>
45 45
46 namespace blink { 46 namespace blink {
47 47
48 MessagePort* MessagePort::create(ExecutionContext& executionContext) { 48 MessagePort* MessagePort::create(ExecutionContext& executionContext) {
49 MessagePort* port = new MessagePort(executionContext); 49 return new MessagePort(executionContext);
50 port->suspendIfNeeded();
51 return port;
52 } 50 }
53 51
54 MessagePort::MessagePort(ExecutionContext& executionContext) 52 MessagePort::MessagePort(ExecutionContext& executionContext)
55 : SuspendableObject(&executionContext), m_started(false), m_closed(false) {} 53 : ContextLifecycleObserver(&executionContext),
54 m_started(false),
55 m_closed(false) {}
56 56
57 MessagePort::~MessagePort() { 57 MessagePort::~MessagePort() {
58 DCHECK(!m_started || !isEntangled()); 58 DCHECK(!m_started || !isEntangled());
59 } 59 }
60 60
61 void MessagePort::postMessage(ExecutionContext* context, 61 void MessagePort::postMessage(ExecutionContext* context,
62 PassRefPtr<SerializedScriptValue> message, 62 PassRefPtr<SerializedScriptValue> message,
63 const MessagePortArray& ports, 63 const MessagePortArray& ports,
64 ExceptionState& exceptionState) { 64 ExceptionState& exceptionState) {
65 if (!isEntangled()) 65 if (!isEntangled())
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 MessagePortArray* portArray = new MessagePortArray(channels->size()); 284 MessagePortArray* portArray = new MessagePortArray(channels->size());
285 for (unsigned i = 0; i < channels->size(); ++i) { 285 for (unsigned i = 0; i < channels->size(); ++i) {
286 MessagePort* port = MessagePort::create(context); 286 MessagePort* port = MessagePort::create(context);
287 port->entangle(std::move((*channels)[i])); 287 port->entangle(std::move((*channels)[i]));
288 (*portArray)[i] = port; 288 (*portArray)[i] = port;
289 } 289 }
290 return portArray; 290 return portArray;
291 } 291 }
292 292
293 DEFINE_TRACE(MessagePort) { 293 DEFINE_TRACE(MessagePort) {
294 SuspendableObject::trace(visitor); 294 ContextLifecycleObserver::trace(visitor);
295 EventTargetWithInlineData::trace(visitor); 295 EventTargetWithInlineData::trace(visitor);
296 } 296 }
297 297
298 } // namespace blink 298 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/MessagePort.h ('k') | third_party/WebKit/Source/core/fileapi/FileReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698