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

Side by Side Diff: Source/core/dom/MessagePortChannel.cpp

Issue 61773005: Rename WebKit namespace to blink (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/MessagePortChannel.h ('k') | Source/core/dom/VisitedLinkState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 21 matching lines...) Expand all
32 #include "core/dom/MessagePortChannel.h" 32 #include "core/dom/MessagePortChannel.h"
33 33
34 #include "core/dom/MessagePort.h" 34 #include "core/dom/MessagePort.h"
35 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
36 #include "public/platform/WebMessagePortChannel.h" 36 #include "public/platform/WebMessagePortChannel.h"
37 #include "public/platform/WebString.h" 37 #include "public/platform/WebString.h"
38 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 PassOwnPtr<MessagePortChannel> MessagePortChannel::create(WebKit::WebMessagePort Channel* channel) 42 PassOwnPtr<MessagePortChannel> MessagePortChannel::create(blink::WebMessagePortC hannel* channel)
43 { 43 {
44 return adoptPtr(new MessagePortChannel(channel)); 44 return adoptPtr(new MessagePortChannel(channel));
45 } 45 }
46 46
47 void MessagePortChannel::createChannel(MessagePort* port1, MessagePort* port2) 47 void MessagePortChannel::createChannel(MessagePort* port1, MessagePort* port2)
48 { 48 {
49 // Create proxies for each endpoint. 49 // Create proxies for each endpoint.
50 OwnPtr<MessagePortChannel> channel1 = create(WebKit::Platform::current()->cr eateMessagePortChannel()); 50 OwnPtr<MessagePortChannel> channel1 = create(blink::Platform::current()->cre ateMessagePortChannel());
51 OwnPtr<MessagePortChannel> channel2 = create(WebKit::Platform::current()->cr eateMessagePortChannel()); 51 OwnPtr<MessagePortChannel> channel2 = create(blink::Platform::current()->cre ateMessagePortChannel());
52 52
53 // Entangle the two endpoints. 53 // Entangle the two endpoints.
54 channel1->m_webChannel->entangle(channel2->m_webChannel); 54 channel1->m_webChannel->entangle(channel2->m_webChannel);
55 channel2->m_webChannel->entangle(channel1->m_webChannel); 55 channel2->m_webChannel->entangle(channel1->m_webChannel);
56 56
57 // Now entangle the proxies with the appropriate local ports. 57 // Now entangle the proxies with the appropriate local ports.
58 port1->entangle(channel2.release()); 58 port1->entangle(channel2.release());
59 port2->entangle(channel1.release()); 59 port2->entangle(channel1.release());
60 } 60 }
61 61
62 MessagePortChannel::MessagePortChannel(WebKit::WebMessagePortChannel* channel) 62 MessagePortChannel::MessagePortChannel(blink::WebMessagePortChannel* channel)
63 : m_localPort(0) 63 : m_localPort(0)
64 , m_webChannel(channel) 64 , m_webChannel(channel)
65 { 65 {
66 ASSERT(m_webChannel); 66 ASSERT(m_webChannel);
67 m_webChannel->setClient(this); 67 m_webChannel->setClient(this);
68 } 68 }
69 69
70 MessagePortChannel::~MessagePortChannel() 70 MessagePortChannel::~MessagePortChannel()
71 { 71 {
72 if (m_webChannel) 72 if (m_webChannel)
(...skipping 10 matching lines...) Expand all
83 { 83 {
84 MutexLocker lock(m_mutex); 84 MutexLocker lock(m_mutex);
85 m_localPort = 0; 85 m_localPort = 0;
86 } 86 }
87 87
88 void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> m essage, PassOwnPtr<MessagePortChannelArray> channels) 88 void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> m essage, PassOwnPtr<MessagePortChannelArray> channels)
89 { 89 {
90 if (!m_localPort || !m_webChannel) 90 if (!m_localPort || !m_webChannel)
91 return; 91 return;
92 92
93 WebKit::WebString messageString = message->toWireString(); 93 blink::WebString messageString = message->toWireString();
94 WebKit::WebMessagePortChannelArray* webChannels = 0; 94 blink::WebMessagePortChannelArray* webChannels = 0;
95 if (channels && channels->size()) { 95 if (channels && channels->size()) {
96 webChannels = new WebKit::WebMessagePortChannelArray(channels->size()); 96 webChannels = new blink::WebMessagePortChannelArray(channels->size());
97 for (size_t i = 0; i < channels->size(); ++i) 97 for (size_t i = 0; i < channels->size(); ++i)
98 (*webChannels)[i] = (*channels)[i]->webChannelRelease(); 98 (*webChannels)[i] = (*channels)[i]->webChannelRelease();
99 } 99 }
100 m_webChannel->postMessage(messageString, webChannels); 100 m_webChannel->postMessage(messageString, webChannels);
101 } 101 }
102 102
103 bool MessagePortChannel::tryGetMessageFromRemote(RefPtr<SerializedScriptValue>& serializedMessage, OwnPtr<MessagePortChannelArray>& channels) 103 bool MessagePortChannel::tryGetMessageFromRemote(RefPtr<SerializedScriptValue>& serializedMessage, OwnPtr<MessagePortChannelArray>& channels)
104 { 104 {
105 if (!m_webChannel) 105 if (!m_webChannel)
106 return false; 106 return false;
107 107
108 WebKit::WebString message; 108 blink::WebString message;
109 WebKit::WebMessagePortChannelArray webChannels; 109 blink::WebMessagePortChannelArray webChannels;
110 bool rv = m_webChannel->tryGetMessage(&message, webChannels); 110 bool rv = m_webChannel->tryGetMessage(&message, webChannels);
111 if (rv) { 111 if (rv) {
112 if (webChannels.size()) { 112 if (webChannels.size()) {
113 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())) ; 113 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())) ;
114 for (size_t i = 0; i < webChannels.size(); ++i) 114 for (size_t i = 0; i < webChannels.size(); ++i)
115 (*channels)[i] = MessagePortChannel::create(webChannels[i]); 115 (*channels)[i] = MessagePortChannel::create(webChannels[i]);
116 } 116 }
117 serializedMessage = SerializedScriptValue::createFromWire(message); 117 serializedMessage = SerializedScriptValue::createFromWire(message);
118 } 118 }
119 119
(...skipping 14 matching lines...) Expand all
134 return m_localPort; 134 return m_localPort;
135 } 135 }
136 136
137 void MessagePortChannel::messageAvailable() 137 void MessagePortChannel::messageAvailable()
138 { 138 {
139 MutexLocker lock(m_mutex); 139 MutexLocker lock(m_mutex);
140 if (m_localPort) 140 if (m_localPort)
141 m_localPort->messageAvailable(); 141 m_localPort->messageAvailable();
142 } 142 }
143 143
144 WebKit::WebMessagePortChannel* MessagePortChannel::webChannelRelease() 144 blink::WebMessagePortChannel* MessagePortChannel::webChannelRelease()
145 { 145 {
146 ASSERT(m_webChannel); 146 ASSERT(m_webChannel);
147 WebKit::WebMessagePortChannel* webChannel = m_webChannel; 147 blink::WebMessagePortChannel* webChannel = m_webChannel;
148 m_webChannel = 0; 148 m_webChannel = 0;
149 webChannel->setClient(0); 149 webChannel->setClient(0);
150 return webChannel; 150 return webChannel;
151 } 151 }
152 152
153 } // namespace WebCore 153 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/MessagePortChannel.h ('k') | Source/core/dom/VisitedLinkState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698