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

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

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

Powered by Google App Engine
This is Rietveld 408576698