| 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_process_host.h" | 5 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 DoWrite(); | 184 DoWrite(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void NativeMessageProcessHost::Start(Client* client) { | 187 void NativeMessageProcessHost::Start(Client* client) { |
| 188 DCHECK(task_runner_->BelongsToCurrentThread()); | 188 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 189 DCHECK(!client_); | 189 DCHECK(!client_); |
| 190 client_ = client; | 190 client_ = client; |
| 191 // It's safe to use base::Unretained() here because NativeMessagePort always | 191 // It's safe to use base::Unretained() here because NativeMessagePort always |
| 192 // deletes us on the IO thread. | 192 // deletes us on the IO thread. |
| 193 task_runner_->PostTask( | 193 task_runner_->PostTask( |
| 194 FROM_HERE, | 194 FROM_HERE, base::BindOnce(&NativeMessageProcessHost::LaunchHostProcess, |
| 195 base::Bind(&NativeMessageProcessHost::LaunchHostProcess, | 195 weak_factory_.GetWeakPtr())); |
| 196 weak_factory_.GetWeakPtr())); | |
| 197 } | 196 } |
| 198 | 197 |
| 199 scoped_refptr<base::SingleThreadTaskRunner> | 198 scoped_refptr<base::SingleThreadTaskRunner> |
| 200 NativeMessageProcessHost::task_runner() const { | 199 NativeMessageProcessHost::task_runner() const { |
| 201 return task_runner_; | 200 return task_runner_; |
| 202 } | 201 } |
| 203 | 202 |
| 204 void NativeMessageProcessHost::ReadNowForTesting() { | 203 void NativeMessageProcessHost::ReadNowForTesting() { |
| 205 DoRead(); | 204 DoRead(); |
| 206 } | 205 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 352 |
| 354 if (!closed_) { | 353 if (!closed_) { |
| 355 closed_ = true; | 354 closed_ = true; |
| 356 read_stream_.reset(); | 355 read_stream_.reset(); |
| 357 write_stream_.reset(); | 356 write_stream_.reset(); |
| 358 client_->CloseChannel(error_message); | 357 client_->CloseChannel(error_message); |
| 359 } | 358 } |
| 360 } | 359 } |
| 361 | 360 |
| 362 } // namespace extensions | 361 } // namespace extensions |
| OLD | NEW |