| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/navigator_connect/service_port_provider.h" | 5 #include "content/child/navigator_connect/service_port_provider.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
| 10 #include "content/child/child_thread_impl.h" | 10 #include "content/child/child_thread_impl.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // to make sure all ports have been fully initialized. Actually sending the | 64 // to make sure all ports have been fully initialized. Actually sending the |
| 65 // message can safely be done on this thread, and using mojo, since there | 65 // message can safely be done on this thread, and using mojo, since there |
| 66 // shouldn't be any other IPCs where ordering matters. | 66 // shouldn't be any other IPCs where ordering matters. |
| 67 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); | 67 scoped_ptr<blink::WebMessagePortChannelArray> channel_array(channels); |
| 68 base::PostTaskAndReplyWithResult( | 68 base::PostTaskAndReplyWithResult( |
| 69 main_loop_.get(), FROM_HERE, | 69 main_loop_.get(), FROM_HERE, |
| 70 base::Bind( | 70 base::Bind( |
| 71 &WebMessagePortChannelImpl::ExtractMessagePortIDsWithoutQueueing, | 71 &WebMessagePortChannelImpl::ExtractMessagePortIDsWithoutQueueing, |
| 72 base::Passed(&channel_array)), | 72 base::Passed(&channel_array)), |
| 73 base::Bind(&ServicePortProvider::PostMessageToBrowser, this, port_id, | 73 base::Bind(&ServicePortProvider::PostMessageToBrowser, this, port_id, |
| 74 message)); | 74 // We cast WebString to string16 before crossing threads. |
| 75 // for thread-safety. |
| 76 static_cast<base::string16>(message))); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void ServicePortProvider::closePort(blink::WebServicePortID port_id) { | 79 void ServicePortProvider::closePort(blink::WebServicePortID port_id) { |
| 78 GetServicePortServicePtr()->ClosePort(port_id); | 80 GetServicePortServicePtr()->ClosePort(port_id); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void ServicePortProvider::PostMessage( | 83 void ServicePortProvider::PostMessage( |
| 82 int32_t port_id, | 84 int32_t port_id, |
| 83 const mojo::String& message, | 85 const mojo::String& message, |
| 84 mojo::Array<MojoTransferredMessagePortPtr> ports, | 86 mojo::Array<MojoTransferredMessagePortPtr> ports, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 123 |
| 122 // Setup channel for browser to post events back to this class. | 124 // Setup channel for browser to post events back to this class. |
| 123 ServicePortServiceClientPtr client_ptr; | 125 ServicePortServiceClientPtr client_ptr; |
| 124 binding_.Bind(GetProxy(&client_ptr)); | 126 binding_.Bind(GetProxy(&client_ptr)); |
| 125 service_port_service_->SetClient(client_ptr.Pass()); | 127 service_port_service_->SetClient(client_ptr.Pass()); |
| 126 } | 128 } |
| 127 return service_port_service_; | 129 return service_port_service_; |
| 128 } | 130 } |
| 129 | 131 |
| 130 } // namespace content | 132 } // namespace content |
| OLD | NEW |