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

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

Issue 16226004: Replace JSON (de)serialization of extension messages with direct Value pickling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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/extension_message_port.h" 5 #include "chrome/browser/extensions/api/messaging/extension_message_port.h"
6 6
7 #include "base/values.h"
7 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 9 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/background_info.h" 12 #include "chrome/common/extensions/background_info.h"
12 #include "chrome/common/extensions/extension_messages.h" 13 #include "chrome/common/extensions/extension_messages.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
14 15
15 namespace extensions { 16 namespace extensions {
16 17
(...skipping 21 matching lines...) Expand all
38 routing_id_, dest_port_id, channel_name, source_tab, info)); 39 routing_id_, dest_port_id, channel_name, source_tab, info));
39 } 40 }
40 41
41 void ExtensionMessagePort::DispatchOnDisconnect( 42 void ExtensionMessagePort::DispatchOnDisconnect(
42 int source_port_id, 43 int source_port_id,
43 const std::string& error_message) { 44 const std::string& error_message) {
44 process_->Send(new ExtensionMsg_DispatchOnDisconnect( 45 process_->Send(new ExtensionMsg_DispatchOnDisconnect(
45 routing_id_, source_port_id, error_message)); 46 routing_id_, source_port_id, error_message));
46 } 47 }
47 48
48 void ExtensionMessagePort::DispatchOnMessage(const std::string& message, 49 void ExtensionMessagePort::DispatchOnMessage(
49 int target_port_id) { 50 scoped_ptr<base::ListValue> message,
50 process_->Send(new ExtensionMsg_DeliverMessage( 51 int target_port_id) {
51 routing_id_, target_port_id, message)); 52 process_->Send(new ExtensionMsg_DeliverMessage(
53 routing_id_, target_port_id, *message));
52 } 54 }
53 55
54 void ExtensionMessagePort::IncrementLazyKeepaliveCount() { 56 void ExtensionMessagePort::IncrementLazyKeepaliveCount() {
55 Profile* profile = 57 Profile* profile =
56 Profile::FromBrowserContext(process_->GetBrowserContext()); 58 Profile::FromBrowserContext(process_->GetBrowserContext());
57 ExtensionProcessManager* pm = 59 ExtensionProcessManager* pm =
58 ExtensionSystem::Get(profile)->process_manager(); 60 ExtensionSystem::Get(profile)->process_manager();
59 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); 61 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_);
60 if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension())) 62 if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension()))
61 pm->IncrementLazyKeepaliveCount(host->extension()); 63 pm->IncrementLazyKeepaliveCount(host->extension());
(...skipping 11 matching lines...) Expand all
73 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); 75 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_);
74 if (host && host == background_host_ptr_) 76 if (host && host == background_host_ptr_)
75 pm->DecrementLazyKeepaliveCount(host->extension()); 77 pm->DecrementLazyKeepaliveCount(host->extension());
76 } 78 }
77 79
78 content::RenderProcessHost* ExtensionMessagePort::GetRenderProcessHost() { 80 content::RenderProcessHost* ExtensionMessagePort::GetRenderProcessHost() {
79 return process_; 81 return process_;
80 } 82 }
81 83
82 } // namespace extensions 84 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698