OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/messaging/native_message_port.h" | 5 #include "chrome/browser/extensions/api/messaging/native_message_port.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 void NativeMessagePort::Core::CloseChannel(const std::string& error_message) { | 80 void NativeMessagePort::Core::CloseChannel(const std::string& error_message) { |
81 DCHECK(host_task_runner_->BelongsToCurrentThread()); | 81 DCHECK(host_task_runner_->BelongsToCurrentThread()); |
82 message_service_task_runner_->PostTask( | 82 message_service_task_runner_->PostTask( |
83 FROM_HERE, | 83 FROM_HERE, |
84 base::Bind(&NativeMessagePort::CloseChannel, port_, error_message)); | 84 base::Bind(&NativeMessagePort::CloseChannel, port_, error_message)); |
85 } | 85 } |
86 | 86 |
87 NativeMessagePort::NativeMessagePort( | 87 NativeMessagePort::NativeMessagePort( |
88 base::WeakPtr<MessageService> message_service, | 88 base::WeakPtr<MessageService> message_service, |
89 int port_id, | 89 const PortId& port_id, |
90 std::unique_ptr<NativeMessageHost> native_message_host) | 90 std::unique_ptr<NativeMessageHost> native_message_host) |
91 : weak_message_service_(message_service), | 91 : weak_message_service_(message_service), |
92 host_task_runner_(native_message_host->task_runner()), | 92 host_task_runner_(native_message_host->task_runner()), |
93 port_id_(port_id), | 93 port_id_(port_id), |
94 weak_factory_(this) { | 94 weak_factory_(this) { |
95 core_.reset(new Core(std::move(native_message_host), | 95 core_.reset(new Core(std::move(native_message_host), |
96 weak_factory_.GetWeakPtr(), | 96 weak_factory_.GetWeakPtr(), |
97 base::ThreadTaskRunnerHandle::Get())); | 97 base::ThreadTaskRunnerHandle::Get())); |
98 } | 98 } |
99 | 99 |
(...skipping 25 matching lines...) Expand all Loading... |
125 } | 125 } |
126 | 126 |
127 void NativeMessagePort::CloseChannel(const std::string& error_message) { | 127 void NativeMessagePort::CloseChannel(const std::string& error_message) { |
128 DCHECK(thread_checker_.CalledOnValidThread()); | 128 DCHECK(thread_checker_.CalledOnValidThread()); |
129 if (weak_message_service_) { | 129 if (weak_message_service_) { |
130 weak_message_service_->CloseChannel(port_id_, error_message); | 130 weak_message_service_->CloseChannel(port_id_, error_message); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 } // namespace extensions | 134 } // namespace extensions |
OLD | NEW |