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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_port.cc

Issue 1112573002: [chrome/browser/extensions] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolving ng browser unittest issues Created 5 years, 7 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
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h"
9 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" 10 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
14 // Handles jumping between the |host_task_runner| and the 15 // Handles jumping between the |host_task_runner| and the
15 // |message_service_task_runner|. 16 // |message_service_task_runner|.
16 // All methods on the host interface should be called on |host_task_runner|. 17 // All methods on the host interface should be called on |host_task_runner|.
17 // All methods on |port| (that calls into MessageServices) should be called 18 // All methods on |port| (that calls into MessageServices) should be called
18 // on |message_service_task_runner|. 19 // on |message_service_task_runner|.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 NativeMessagePort::NativeMessagePort( 85 NativeMessagePort::NativeMessagePort(
85 base::WeakPtr<MessageService> message_service, 86 base::WeakPtr<MessageService> message_service,
86 int port_id, 87 int port_id,
87 scoped_ptr<NativeMessageHost> native_message_host) 88 scoped_ptr<NativeMessageHost> native_message_host)
88 : weak_message_service_(message_service), 89 : weak_message_service_(message_service),
89 host_task_runner_(native_message_host->task_runner()), 90 host_task_runner_(native_message_host->task_runner()),
90 port_id_(port_id), 91 port_id_(port_id),
91 weak_factory_(this) { 92 weak_factory_(this) {
92 core_.reset(new Core(native_message_host.Pass(), 93 core_.reset(new Core(native_message_host.Pass(),
93 weak_factory_.GetWeakPtr(), 94 weak_factory_.GetWeakPtr(),
94 base::MessageLoopProxy::current())); 95 base::ThreadTaskRunnerHandle::Get()));
95 } 96 }
96 97
97 NativeMessagePort::~NativeMessagePort() { 98 NativeMessagePort::~NativeMessagePort() {
98 DCHECK(thread_checker_.CalledOnValidThread()); 99 DCHECK(thread_checker_.CalledOnValidThread());
99 host_task_runner_->DeleteSoon(FROM_HERE, core_.release()); 100 host_task_runner_->DeleteSoon(FROM_HERE, core_.release());
100 } 101 }
101 102
102 void NativeMessagePort::DispatchOnMessage( 103 void NativeMessagePort::DispatchOnMessage(
103 const Message& message, 104 const Message& message,
104 int target_port_id) { 105 int target_port_id) {
(...skipping 10 matching lines...) Expand all
115 } 116 }
116 117
117 void NativeMessagePort::CloseChannel(const std::string& error_message) { 118 void NativeMessagePort::CloseChannel(const std::string& error_message) {
118 DCHECK(thread_checker_.CalledOnValidThread()); 119 DCHECK(thread_checker_.CalledOnValidThread());
119 if (weak_message_service_) { 120 if (weak_message_service_) {
120 weak_message_service_->CloseChannel(port_id_, error_message); 121 weak_message_service_->CloseChannel(port_id_, error_message);
121 } 122 }
122 } 123 }
123 124
124 } // namespace extensions 125 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698