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

Side by Side Diff: webkit/tools/test_shell/test_worker/test_webworker.cc

Issue 173193: Updating Worker.postMessage(), DOMWindow.postMessage(), and... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « webkit/tools/test_shell/test_worker/test_webworker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #if ENABLE(WORKERS) 7 #if ENABLE(WORKERS)
8 8
9 #include "webkit/tools/test_shell/test_worker/test_webworker.h" 9 #include "webkit/tools/test_shell/test_worker/test_webworker.h"
10 10
(...skipping 22 matching lines...) Expand all
33 webworker_helper_->Unload(); 33 webworker_helper_->Unload();
34 } 34 }
35 35
36 void TestWebWorker::startWorkerContext(const WebURL& script_url, 36 void TestWebWorker::startWorkerContext(const WebURL& script_url,
37 const WebString& user_agent, 37 const WebString& user_agent,
38 const WebString& source_code) { 38 const WebString& source_code) {
39 webworker_impl_ = new WebWorkerImpl(this); 39 webworker_impl_ = new WebWorkerImpl(this);
40 40
41 webworker_impl_->startWorkerContext(script_url, user_agent, source_code); 41 webworker_impl_->startWorkerContext(script_url, user_agent, source_code);
42 42
43 WebKit::WebMessagePortChannelArray emptyArray;
43 for (size_t i = 0; i < queued_messages_.size(); ++i) 44 for (size_t i = 0; i < queued_messages_.size(); ++i)
44 webworker_impl_->postMessageToWorkerContext(queued_messages_[i], NULL); 45 webworker_impl_->postMessageToWorkerContext(queued_messages_[i], emptyArray) ;
45 queued_messages_.clear(); 46 queued_messages_.clear();
46 } 47 }
47 48
48 void TestWebWorker::terminateWorkerContext() { 49 void TestWebWorker::terminateWorkerContext() {
49 if (webworker_impl_) 50 if (webworker_impl_)
50 webworker_impl_->terminateWorkerContext(); 51 webworker_impl_->terminateWorkerContext();
51 } 52 }
52 53
53 void TestWebWorker::postMessageToWorkerContext(const WebString& message, 54 void TestWebWorker::postMessageToWorkerContext(
54 WebKit::WebMessagePortChannel*) { 55 const WebString& message,
56 const WebKit::WebMessagePortChannelArray& channels) {
55 if (webworker_impl_) 57 if (webworker_impl_)
56 webworker_impl_->postMessageToWorkerContext(message, NULL); 58 webworker_impl_->postMessageToWorkerContext(message, channels);
57 else 59 else
58 queued_messages_.push_back(message); 60 queued_messages_.push_back(message);
59 } 61 }
60 62
61 void TestWebWorker::workerObjectDestroyed() { 63 void TestWebWorker::workerObjectDestroyed() {
62 if (webworker_impl_) 64 if (webworker_impl_)
63 webworker_impl_->workerObjectDestroyed(); 65 webworker_impl_->workerObjectDestroyed();
64 66
65 webworkerclient_delegate_ = NULL; 67 webworkerclient_delegate_ = NULL;
66 Release(); // Releases the reference held for worker object. 68 Release(); // Releases the reference held for worker object.
67 } 69 }
68 70
69 void TestWebWorker::postMessageToWorkerObject(const WebString& message, 71 void TestWebWorker::postMessageToWorkerObject(
70 WebKit::WebMessagePortChannel*) { 72 const WebString& message,
73 const WebKit::WebMessagePortChannelArray& channels) {
71 if (!webworkerclient_delegate_) 74 if (!webworkerclient_delegate_)
72 return; 75 return;
73 // The string was created in the dll's memory space as a result of a postTask. 76 // The string was created in the dll's memory space as a result of a postTask.
74 // If we pass it to test shell's memory space, it'll cause problems when GC 77 // If we pass it to test shell's memory space, it'll cause problems when GC
75 // occurs. So duplicate it from the test shell's memory space first. 78 // occurs. So duplicate it from the test shell's memory space first.
76 webworkerclient_delegate_->postMessageToWorkerObject( 79 webworkerclient_delegate_->postMessageToWorkerObject(
77 webworker_helper_->DuplicateString(message), NULL); 80 webworker_helper_->DuplicateString(message), channels);
78 } 81 }
79 82
80 void TestWebWorker::postExceptionToWorkerObject(const WebString& error_message, 83 void TestWebWorker::postExceptionToWorkerObject(const WebString& error_message,
81 int line_number, 84 int line_number,
82 const WebString& source_url) { 85 const WebString& source_url) {
83 if (webworkerclient_delegate_) 86 if (webworkerclient_delegate_)
84 webworkerclient_delegate_->postExceptionToWorkerObject(error_message, 87 webworkerclient_delegate_->postExceptionToWorkerObject(error_message,
85 line_number, 88 line_number,
86 source_url); 89 source_url);
87 } 90 }
(...skipping 24 matching lines...) Expand all
112 } 115 }
113 116
114 void TestWebWorker::workerContextDestroyed() { 117 void TestWebWorker::workerContextDestroyed() {
115 webworker_impl_ = NULL; 118 webworker_impl_ = NULL;
116 if (webworkerclient_delegate_) 119 if (webworkerclient_delegate_)
117 webworkerclient_delegate_->workerContextDestroyed(); 120 webworkerclient_delegate_->workerContextDestroyed();
118 Release(); // Releases the reference held for worker context object. 121 Release(); // Releases the reference held for worker context object.
119 } 122 }
120 123
121 #endif 124 #endif
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_worker/test_webworker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698