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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 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 17 matching lines...) Expand all
28 #define MessagePort_h 28 #define MessagePort_h
29 29
30 #include "bindings/core/v8/ActiveScriptWrappable.h" 30 #include "bindings/core/v8/ActiveScriptWrappable.h"
31 #include "bindings/core/v8/SerializedScriptValue.h" 31 #include "bindings/core/v8/SerializedScriptValue.h"
32 #include "core/CoreExport.h" 32 #include "core/CoreExport.h"
33 #include "core/dom/ActiveDOMObject.h" 33 #include "core/dom/ActiveDOMObject.h"
34 #include "core/events/EventListener.h" 34 #include "core/events/EventListener.h"
35 #include "core/events/EventTarget.h" 35 #include "core/events/EventTarget.h"
36 #include "public/platform/WebMessagePortChannel.h" 36 #include "public/platform/WebMessagePortChannel.h"
37 #include "public/platform/WebMessagePortChannelClient.h" 37 #include "public/platform/WebMessagePortChannelClient.h"
38 #include "wtf/OwnPtr.h"
39 #include "wtf/PassOwnPtr.h"
38 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
40 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
41 #include <memory> 43 #include <memory>
42 44
43 namespace blink { 45 namespace blink {
44 46
45 class ExceptionState; 47 class ExceptionState;
46 class ExecutionContext; 48 class ExecutionContext;
47 class MessagePort; 49 class MessagePort;
(...skipping 16 matching lines...) Expand all
64 66
65 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray&, ExceptionState&); 67 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray&, ExceptionState&);
66 68
67 void start(); 69 void start();
68 void close(); 70 void close();
69 71
70 void entangle(WebMessagePortChannelUniquePtr); 72 void entangle(WebMessagePortChannelUniquePtr);
71 WebMessagePortChannelUniquePtr disentangle(); 73 WebMessagePortChannelUniquePtr disentangle();
72 74
73 // Returns nullptr if the passed-in array is nullptr/empty. 75 // Returns nullptr if the passed-in array is nullptr/empty.
74 static std::unique_ptr<WebMessagePortChannelArray> toWebMessagePortChannelAr ray(std::unique_ptr<MessagePortChannelArray>); 76 static PassOwnPtr<WebMessagePortChannelArray> toWebMessagePortChannelArray(P assOwnPtr<MessagePortChannelArray>);
75 77
76 // Returns an empty array if the passed array is empty. 78 // Returns an empty array if the passed array is empty.
77 static MessagePortArray* toMessagePortArray(ExecutionContext*, const WebMess agePortChannelArray&); 79 static MessagePortArray* toMessagePortArray(ExecutionContext*, const WebMess agePortChannelArray&);
78 80
79 // Returns nullptr if there is an exception, or if the passed-in array is nu llptr/empty. 81 // Returns nullptr if there is an exception, or if the passed-in array is nu llptr/empty.
80 static std::unique_ptr<MessagePortChannelArray> disentanglePorts(ExecutionCo ntext*, const MessagePortArray&, ExceptionState&); 82 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(ExecutionContext *, const MessagePortArray&, ExceptionState&);
81 83
82 // Returns an empty array if the passed array is nullptr/empty. 84 // Returns an empty array if the passed array is nullptr/empty.
83 static MessagePortArray* entanglePorts(ExecutionContext&, std::unique_ptr<Me ssagePortChannelArray>); 85 static MessagePortArray* entanglePorts(ExecutionContext&, PassOwnPtr<Message PortChannelArray>);
84 86
85 bool started() const { return m_started; } 87 bool started() const { return m_started; }
86 88
87 const AtomicString& interfaceName() const override; 89 const AtomicString& interfaceName() const override;
88 ExecutionContext* getExecutionContext() const override { return ActiveDOMObj ect::getExecutionContext(); } 90 ExecutionContext* getExecutionContext() const override { return ActiveDOMObj ect::getExecutionContext(); }
89 MessagePort* toMessagePort() override { return this; } 91 MessagePort* toMessagePort() override { return this; }
90 92
91 // ActiveScriptWrappable implementation. 93 // ActiveScriptWrappable implementation.
92 bool hasPendingActivity() const final; 94 bool hasPendingActivity() const final;
93 95
(...skipping 10 matching lines...) Expand all
104 // A port starts out its life entangled, and remains entangled until it is c losed or is cloned. 106 // A port starts out its life entangled, and remains entangled until it is c losed or is cloned.
105 bool isEntangled() const { return !m_closed && !isNeutered(); } 107 bool isEntangled() const { return !m_closed && !isNeutered(); }
106 108
107 // A port gets neutered when it is transferred to a new owner via postMessag e(). 109 // A port gets neutered when it is transferred to a new owner via postMessag e().
108 bool isNeutered() const { return !m_entangledChannel; } 110 bool isNeutered() const { return !m_entangledChannel; }
109 111
110 DECLARE_VIRTUAL_TRACE(); 112 DECLARE_VIRTUAL_TRACE();
111 113
112 protected: 114 protected:
113 explicit MessagePort(ExecutionContext&); 115 explicit MessagePort(ExecutionContext&);
114 bool tryGetMessage(RefPtr<SerializedScriptValue>& message, std::unique_ptr<M essagePortChannelArray>& channels); 116 bool tryGetMessage(RefPtr<SerializedScriptValue>& message, OwnPtr<MessagePor tChannelArray>& channels);
115 117
116 private: 118 private:
117 // WebMessagePortChannelClient implementation. 119 // WebMessagePortChannelClient implementation.
118 void messageAvailable() override; 120 void messageAvailable() override;
119 void dispatchMessages(); 121 void dispatchMessages();
120 122
121 WebMessagePortChannelUniquePtr m_entangledChannel; 123 WebMessagePortChannelUniquePtr m_entangledChannel;
122 124
123 bool m_started; 125 bool m_started;
124 bool m_closed; 126 bool m_closed;
125 127
126 RefPtr<ScriptState> m_scriptStateForConversion; 128 RefPtr<ScriptState> m_scriptStateForConversion;
127 }; 129 };
128 130
129 } // namespace blink 131 } // namespace blink
130 132
131 #endif // MessagePort_h 133 #endif // MessagePort_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/MainThreadTaskRunnerTest.cpp ('k') | third_party/WebKit/Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698