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

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

Issue 24649002: Clean up a few more unused globals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: thestig comment Created 7 years, 2 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 | Annotate | Revision Log
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/message_service.h" 5 #include "chrome/browser/extensions/api/messaging/message_service.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #define GET_CHANNEL_RECEIVERS_ID(channel_id) ((channel_id) * 2 + 1) 51 #define GET_CHANNEL_RECEIVERS_ID(channel_id) ((channel_id) * 2 + 1)
52 52
53 // Port1 is always even, port2 is always odd. 53 // Port1 is always even, port2 is always odd.
54 #define IS_OPENER_PORT_ID(port_id) (((port_id) & 1) == 0) 54 #define IS_OPENER_PORT_ID(port_id) (((port_id) & 1) == 0)
55 55
56 // Change even to odd and vice versa, to get the other side of a given channel. 56 // Change even to odd and vice versa, to get the other side of a given channel.
57 #define GET_OPPOSITE_PORT_ID(source_port_id) ((source_port_id) ^ 1) 57 #define GET_OPPOSITE_PORT_ID(source_port_id) ((source_port_id) ^ 1)
58 58
59 namespace extensions { 59 namespace extensions {
60 60
61 namespace {
62 const char kReceivingEndDoesntExistError[] = 61 const char kReceivingEndDoesntExistError[] =
63 "Could not establish connection. Receiving end does not exist."; 62 "Could not establish connection. Receiving end does not exist.";
64 const char kMissingPermissionError[] = 63 const char kMissingPermissionError[] =
65 "Access to native messaging requires nativeMessaging permission."; 64 "Access to native messaging requires nativeMessaging permission.";
66 const char kNativeMessagingNotSupportedError[] =
67 "Native Messaging is not supported on this platform.";
68 }
69 65
70 struct MessageService::MessageChannel { 66 struct MessageService::MessageChannel {
71 scoped_ptr<MessagePort> opener; 67 scoped_ptr<MessagePort> opener;
72 scoped_ptr<MessagePort> receiver; 68 scoped_ptr<MessagePort> receiver;
73 }; 69 };
74 70
75 struct MessageService::OpenChannelParams { 71 struct MessageService::OpenChannelParams {
76 content::RenderProcessHost* source; 72 content::RenderProcessHost* source;
77 base::DictionaryValue source_tab; 73 base::DictionaryValue source_tab;
78 scoped_ptr<MessagePort> receiver; 74 scoped_ptr<MessagePort> receiver;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 source, receiver_port_id, kReceivingEndDoesntExistError); 347 source, receiver_port_id, kReceivingEndDoesntExistError);
352 return; 348 return;
353 } 349 }
354 channel->receiver.reset(new NativeMessagePort(native_process.release())); 350 channel->receiver.reset(new NativeMessagePort(native_process.release()));
355 351
356 // Keep the opener alive until the channel is closed. 352 // Keep the opener alive until the channel is closed.
357 channel->opener->IncrementLazyKeepaliveCount(); 353 channel->opener->IncrementLazyKeepaliveCount();
358 354
359 AddChannel(channel.release(), receiver_port_id); 355 AddChannel(channel.release(), receiver_port_id);
360 #else // !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) 356 #else // !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX))
357 const char kNativeMessagingNotSupportedError[] =
358 "Native Messaging is not supported on this platform.";
361 DispatchOnDisconnect( 359 DispatchOnDisconnect(
362 source, receiver_port_id, kNativeMessagingNotSupportedError); 360 source, receiver_port_id, kNativeMessagingNotSupportedError);
363 #endif // !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) 361 #endif // !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX))
364 } 362 }
365 363
366 void MessageService::OpenChannelToTab( 364 void MessageService::OpenChannelToTab(
367 int source_process_id, int source_routing_id, int receiver_port_id, 365 int source_process_id, int source_routing_id, int receiver_port_id,
368 int tab_id, const std::string& extension_id, 366 int tab_id, const std::string& extension_id,
369 const std::string& channel_name) { 367 const std::string& channel_name) {
370 content::RenderProcessHost* source = 368 content::RenderProcessHost* source =
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 610 }
613 611
614 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, 612 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source,
615 int port_id, 613 int port_id,
616 const std::string& error_message) { 614 const std::string& error_message) {
617 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); 615 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
618 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); 616 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message);
619 } 617 }
620 618
621 } // namespace extensions 619 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698