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

Side by Side Diff: chrome/browser/extensions/extension_message_service.cc

Issue 147033: Refactor extension bindings to share code, avoid exposing hidden variables (Closed)
Patch Set: at head Created 11 years, 5 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
« no previous file with comments | « no previous file | chrome/renderer/extensions/bindings_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extension_message_service.h" 5 #include "chrome/browser/extensions/extension_message_service.h"
6 6
7 #include "base/json_writer.h" 7 #include "base/json_writer.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 // Since ExtensionMessageService is a collection of Singletons, we don't need to 83 // Since ExtensionMessageService is a collection of Singletons, we don't need to
84 // grab a reference to it when creating Tasks involving it. 84 // grab a reference to it when creating Tasks involving it.
85 template <> struct RunnableMethodTraits<ExtensionMessageService> { 85 template <> struct RunnableMethodTraits<ExtensionMessageService> {
86 static void RetainCallee(ExtensionMessageService*) {} 86 static void RetainCallee(ExtensionMessageService*) {}
87 static void ReleaseCallee(ExtensionMessageService*) {} 87 static void ReleaseCallee(ExtensionMessageService*) {}
88 }; 88 };
89 89
90 90
91 const char ExtensionMessageService::kDispatchOnConnect[] = 91 const char ExtensionMessageService::kDispatchOnConnect[] =
92 "chrome.Port.dispatchOnConnect_"; 92 "Port.dispatchOnConnect";
93 const char ExtensionMessageService::kDispatchOnDisconnect[] = 93 const char ExtensionMessageService::kDispatchOnDisconnect[] =
94 "chrome.Port.dispatchOnDisconnect_"; 94 "Port.dispatchOnDisconnect";
95 const char ExtensionMessageService::kDispatchOnMessage[] = 95 const char ExtensionMessageService::kDispatchOnMessage[] =
96 "chrome.Port.dispatchOnMessage_"; 96 "Port.dispatchOnMessage";
97 const char ExtensionMessageService::kDispatchEvent[] = 97 const char ExtensionMessageService::kDispatchEvent[] =
98 "chrome.Event.dispatchJSON_"; 98 "Event.dispatchJSON";
99 99
100 // static 100 // static
101 ExtensionMessageService* ExtensionMessageService::GetInstance( 101 ExtensionMessageService* ExtensionMessageService::GetInstance(
102 URLRequestContext* context) { 102 URLRequestContext* context) {
103 SingletonData* data = Singleton<SingletonData>::get(); 103 SingletonData* data = Singleton<SingletonData>::get();
104 AutoLock lock(data->lock); 104 AutoLock lock(data->lock);
105 105
106 ExtensionMessageService* instance = data->map[context]; 106 ExtensionMessageService* instance = data->map[context];
107 if (!instance) { 107 if (!instance) {
108 instance = new ExtensionMessageService(); 108 instance = new ExtensionMessageService();
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 DispatchOnDisconnect(current->second.port2, 368 DispatchOnDisconnect(current->second.port2,
369 GET_CHANNEL_PORT1(current->first)); 369 GET_CHANNEL_PORT1(current->first));
370 channels_.erase(current); 370 channels_.erase(current);
371 } else if (current->second.port2 == renderer) { 371 } else if (current->second.port2 == renderer) {
372 DispatchOnDisconnect(current->second.port1, 372 DispatchOnDisconnect(current->second.port1,
373 GET_CHANNEL_PORT2(current->first)); 373 GET_CHANNEL_PORT2(current->first));
374 channels_.erase(current); 374 channels_.erase(current);
375 } 375 }
376 } 376 }
377 } 377 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/extensions/bindings_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698