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

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

Issue 1413543005: Use FrameTreeNode ID as frameId in extension APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/:/ / Created 4 years, 11 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 <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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
100 NativeMessagePort::~NativeMessagePort() { 100 NativeMessagePort::~NativeMessagePort() {
101 DCHECK(thread_checker_.CalledOnValidThread()); 101 DCHECK(thread_checker_.CalledOnValidThread());
102 host_task_runner_->DeleteSoon(FROM_HERE, core_.release()); 102 host_task_runner_->DeleteSoon(FROM_HERE, core_.release());
103 } 103 }
104 104
105 void NativeMessagePort::DispatchOnMessage( 105 bool NativeMessagePort::IsValidPort() {
106 const Message& message, 106 // The native message port is immediately connected after construction, so it
107 int target_port_id) { 107 // is not possible to invalidate the port between construction and connection.
108 // The return value doesn't matter since native messaging follows a code path
109 // where IsValidPort() is never called.
110 NOTREACHED();
111 return true;
112 }
113
114 void NativeMessagePort::DispatchOnMessage(const Message& message) {
108 DCHECK(thread_checker_.CalledOnValidThread()); 115 DCHECK(thread_checker_.CalledOnValidThread());
109 core_->OnMessageFromChrome(message.data); 116 core_->OnMessageFromChrome(message.data);
110 } 117 }
111 118
112 void NativeMessagePort::PostMessageFromNativeHost(const std::string& message) { 119 void NativeMessagePort::PostMessageFromNativeHost(const std::string& message) {
113 DCHECK(thread_checker_.CalledOnValidThread()); 120 DCHECK(thread_checker_.CalledOnValidThread());
114 if (weak_message_service_) { 121 if (weak_message_service_) {
115 weak_message_service_->PostMessage( 122 weak_message_service_->PostMessage(
116 port_id_, Message(message, false /* user_gesture */)); 123 port_id_, Message(message, false /* user_gesture */));
117 } 124 }
118 } 125 }
119 126
120 void NativeMessagePort::CloseChannel(const std::string& error_message) { 127 void NativeMessagePort::CloseChannel(const std::string& error_message) {
121 DCHECK(thread_checker_.CalledOnValidThread()); 128 DCHECK(thread_checker_.CalledOnValidThread());
122 if (weak_message_service_) { 129 if (weak_message_service_) {
123 weak_message_service_->CloseChannel(port_id_, error_message); 130 weak_message_service_->CloseChannel(port_id_, error_message);
124 } 131 }
125 } 132 }
126 133
127 } // namespace extensions 134 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698