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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
15 #include "base/task_scheduler/post_task.h" | 15 #include "base/task_scheduler/post_task.h" |
16 #include "base/threading/sequenced_worker_pool.h" | |
17 #include "build/build_config.h" | 16 #include "build/build_config.h" |
18 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h" | 17 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h" |
19 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" | 18 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
21 #include "extensions/common/constants.h" | 20 #include "extensions/common/constants.h" |
22 #include "extensions/common/features/feature.h" | 21 #include "extensions/common/features/feature.h" |
23 #include "net/base/file_stream.h" | 22 #include "net/base/file_stream.h" |
24 #include "net/base/io_buffer.h" | 23 #include "net/base/io_buffer.h" |
25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
26 #include "url/gurl.h" | 25 #include "url/gurl.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 case NativeProcessLauncher::RESULT_SUCCESS: | 138 case NativeProcessLauncher::RESULT_SUCCESS: |
140 break; | 139 break; |
141 } | 140 } |
142 | 141 |
143 process_ = std::move(process); | 142 process_ = std::move(process); |
144 #if defined(OS_POSIX) | 143 #if defined(OS_POSIX) |
145 // This object is not the owner of the file so it should not keep an fd. | 144 // This object is not the owner of the file so it should not keep an fd. |
146 read_file_ = read_file.GetPlatformFile(); | 145 read_file_ = read_file.GetPlatformFile(); |
147 #endif | 146 #endif |
148 | 147 |
149 scoped_refptr<base::TaskRunner> task_runner( | 148 scoped_refptr<base::TaskRunner> task_runner(base::CreateTaskRunnerWithTraits( |
150 content::BrowserThread::GetBlockingPool()-> | 149 base::TaskTraits() |
151 GetTaskRunnerWithShutdownBehavior( | 150 .MayBlock() |
152 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 151 .WithPriority(base::TaskPriority::BACKGROUND) |
Devlin
2017/04/24 20:22:11
This task can spawn a new process, which seems lik
Sergey Ulanov
2017/04/24 21:24:17
Yes, this should be USER_VISIBLE. Depending on app
fdoray
2017/04/27 13:06:39
Done.
| |
152 .WithShutdownBehavior(base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
153 | 153 |
154 read_stream_.reset(new net::FileStream(std::move(read_file), task_runner)); | 154 read_stream_.reset(new net::FileStream(std::move(read_file), task_runner)); |
155 write_stream_.reset(new net::FileStream(std::move(write_file), task_runner)); | 155 write_stream_.reset(new net::FileStream(std::move(write_file), task_runner)); |
156 | 156 |
157 WaitRead(); | 157 WaitRead(); |
158 DoWrite(); | 158 DoWrite(); |
159 } | 159 } |
160 | 160 |
161 void NativeMessageProcessHost::OnMessage(const std::string& json) { | 161 void NativeMessageProcessHost::OnMessage(const std::string& json) { |
162 DCHECK(task_runner_->BelongsToCurrentThread()); | 162 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 | 352 |
353 if (!closed_) { | 353 if (!closed_) { |
354 closed_ = true; | 354 closed_ = true; |
355 read_stream_.reset(); | 355 read_stream_.reset(); |
356 write_stream_.reset(); | 356 write_stream_.reset(); |
357 client_->CloseChannel(error_message); | 357 client_->CloseChannel(error_message); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 } // namespace extensions | 361 } // namespace extensions |
OLD | NEW |