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

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

Issue 1549233002: Convert Pass()→std::move() in //chrome/browser/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 12 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/event_router_forwarder.h" 5 #include "chrome/browser/extensions/event_router_forwarder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "extensions/browser/event_router.h" 16 #include "extensions/browser/event_router.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 namespace extensions { 21 namespace extensions {
21 22
22 EventRouterForwarder::EventRouterForwarder() { 23 EventRouterForwarder::EventRouterForwarder() {
23 } 24 }
24 25
25 EventRouterForwarder::~EventRouterForwarder() { 26 EventRouterForwarder::~EventRouterForwarder() {
26 } 27 }
27 28
28 void EventRouterForwarder::BroadcastEventToRenderers( 29 void EventRouterForwarder::BroadcastEventToRenderers(
29 events::HistogramValue histogram_value, 30 events::HistogramValue histogram_value,
30 const std::string& event_name, 31 const std::string& event_name,
31 scoped_ptr<base::ListValue> event_args, 32 scoped_ptr<base::ListValue> event_args,
32 const GURL& event_url) { 33 const GURL& event_url) {
33 HandleEvent(std::string(), histogram_value, event_name, event_args.Pass(), 0, 34 HandleEvent(std::string(), histogram_value, event_name, std::move(event_args),
34 true, event_url); 35 0, true, event_url);
35 } 36 }
36 37
37 void EventRouterForwarder::DispatchEventToRenderers( 38 void EventRouterForwarder::DispatchEventToRenderers(
38 events::HistogramValue histogram_value, 39 events::HistogramValue histogram_value,
39 const std::string& event_name, 40 const std::string& event_name,
40 scoped_ptr<base::ListValue> event_args, 41 scoped_ptr<base::ListValue> event_args,
41 void* profile, 42 void* profile,
42 bool use_profile_to_restrict_events, 43 bool use_profile_to_restrict_events,
43 const GURL& event_url) { 44 const GURL& event_url) {
44 if (!profile) 45 if (!profile)
45 return; 46 return;
46 HandleEvent(std::string(), histogram_value, event_name, event_args.Pass(), 47 HandleEvent(std::string(), histogram_value, event_name, std::move(event_args),
47 profile, use_profile_to_restrict_events, event_url); 48 profile, use_profile_to_restrict_events, event_url);
48 } 49 }
49 50
50 void EventRouterForwarder::BroadcastEventToExtension( 51 void EventRouterForwarder::BroadcastEventToExtension(
51 const std::string& extension_id, 52 const std::string& extension_id,
52 events::HistogramValue histogram_value, 53 events::HistogramValue histogram_value,
53 const std::string& event_name, 54 const std::string& event_name,
54 scoped_ptr<base::ListValue> event_args, 55 scoped_ptr<base::ListValue> event_args,
55 const GURL& event_url) { 56 const GURL& event_url) {
56 HandleEvent(extension_id, histogram_value, event_name, event_args.Pass(), 0, 57 HandleEvent(extension_id, histogram_value, event_name, std::move(event_args),
57 true, event_url); 58 0, true, event_url);
58 } 59 }
59 60
60 void EventRouterForwarder::DispatchEventToExtension( 61 void EventRouterForwarder::DispatchEventToExtension(
61 const std::string& extension_id, 62 const std::string& extension_id,
62 events::HistogramValue histogram_value, 63 events::HistogramValue histogram_value,
63 const std::string& event_name, 64 const std::string& event_name,
64 scoped_ptr<base::ListValue> event_args, 65 scoped_ptr<base::ListValue> event_args,
65 void* profile, 66 void* profile,
66 bool use_profile_to_restrict_events, 67 bool use_profile_to_restrict_events,
67 const GURL& event_url) { 68 const GURL& event_url) {
68 if (!profile) 69 if (!profile)
69 return; 70 return;
70 HandleEvent(extension_id, histogram_value, event_name, event_args.Pass(), 71 HandleEvent(extension_id, histogram_value, event_name, std::move(event_args),
71 profile, use_profile_to_restrict_events, event_url); 72 profile, use_profile_to_restrict_events, event_url);
72 } 73 }
73 74
74 void EventRouterForwarder::HandleEvent(const std::string& extension_id, 75 void EventRouterForwarder::HandleEvent(const std::string& extension_id,
75 events::HistogramValue histogram_value, 76 events::HistogramValue histogram_value,
76 const std::string& event_name, 77 const std::string& event_name,
77 scoped_ptr<base::ListValue> event_args, 78 scoped_ptr<base::ListValue> event_args,
78 void* profile_ptr, 79 void* profile_ptr,
79 bool use_profile_to_restrict_events, 80 bool use_profile_to_restrict_events,
80 const GURL& event_url) { 81 const GURL& event_url) {
(...skipping 11 matching lines...) Expand all
92 93
93 ProfileManager* profile_manager = g_browser_process->profile_manager(); 94 ProfileManager* profile_manager = g_browser_process->profile_manager();
94 Profile* profile = NULL; 95 Profile* profile = NULL;
95 if (profile_ptr) { 96 if (profile_ptr) {
96 if (!profile_manager->IsValidProfile(profile_ptr)) 97 if (!profile_manager->IsValidProfile(profile_ptr))
97 return; 98 return;
98 profile = reinterpret_cast<Profile*>(profile_ptr); 99 profile = reinterpret_cast<Profile*>(profile_ptr);
99 } 100 }
100 if (profile) { 101 if (profile) {
101 CallEventRouter(profile, extension_id, histogram_value, event_name, 102 CallEventRouter(profile, extension_id, histogram_value, event_name,
102 event_args.Pass(), 103 std::move(event_args),
103 use_profile_to_restrict_events ? profile : NULL, event_url); 104 use_profile_to_restrict_events ? profile : NULL, event_url);
104 } else { 105 } else {
105 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); 106 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
106 for (size_t i = 0; i < profiles.size(); ++i) { 107 for (size_t i = 0; i < profiles.size(); ++i) {
107 scoped_ptr<base::ListValue> per_profile_event_args( 108 scoped_ptr<base::ListValue> per_profile_event_args(
108 event_args->DeepCopy()); 109 event_args->DeepCopy());
109 CallEventRouter(profiles[i], extension_id, histogram_value, event_name, 110 CallEventRouter(profiles[i], extension_id, histogram_value, event_name,
110 per_profile_event_args.Pass(), 111 std::move(per_profile_event_args),
111 use_profile_to_restrict_events ? profiles[i] : NULL, 112 use_profile_to_restrict_events ? profiles[i] : NULL,
112 event_url); 113 event_url);
113 } 114 }
114 } 115 }
115 } 116 }
116 117
117 void EventRouterForwarder::CallEventRouter( 118 void EventRouterForwarder::CallEventRouter(
118 Profile* profile, 119 Profile* profile,
119 const std::string& extension_id, 120 const std::string& extension_id,
120 events::HistogramValue histogram_value, 121 events::HistogramValue histogram_value,
121 const std::string& event_name, 122 const std::string& event_name,
122 scoped_ptr<base::ListValue> event_args, 123 scoped_ptr<base::ListValue> event_args,
123 Profile* restrict_to_profile, 124 Profile* restrict_to_profile,
124 const GURL& event_url) { 125 const GURL& event_url) {
125 #if defined(OS_CHROMEOS) 126 #if defined(OS_CHROMEOS)
126 // Extension does not exist for chromeos login. This needs to be 127 // Extension does not exist for chromeos login. This needs to be
127 // removed once we have an extension service for login screen. 128 // removed once we have an extension service for login screen.
128 // crosbug.com/12856. 129 // crosbug.com/12856.
129 if (!extensions::EventRouter::Get(profile)) 130 if (!extensions::EventRouter::Get(profile))
130 return; 131 return;
131 #endif 132 #endif
132 133
133 scoped_ptr<Event> event( 134 scoped_ptr<Event> event(
134 new Event(histogram_value, event_name, event_args.Pass())); 135 new Event(histogram_value, event_name, std::move(event_args)));
135 event->restrict_to_browser_context = restrict_to_profile; 136 event->restrict_to_browser_context = restrict_to_profile;
136 event->event_url = event_url; 137 event->event_url = event_url;
137 if (extension_id.empty()) { 138 if (extension_id.empty()) {
138 extensions::EventRouter::Get(profile)->BroadcastEvent(event.Pass()); 139 extensions::EventRouter::Get(profile)->BroadcastEvent(std::move(event));
139 } else { 140 } else {
140 extensions::EventRouter::Get(profile) 141 extensions::EventRouter::Get(profile)
141 ->DispatchEventToExtension(extension_id, event.Pass()); 142 ->DispatchEventToExtension(extension_id, std::move(event));
142 } 143 }
143 } 144 }
144 145
145 } // namespace extensions 146 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/error_console/error_console.cc ('k') | chrome/browser/extensions/event_router_forwarder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698