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

Side by Side Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc

Issue 141523010: Pepper: Log in UMA when an interface is used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again Created 6 years, 10 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
« no previous file with comments | « content/browser/renderer_host/pepper/browser_ppapi_host_impl.h ('k') | ppapi/PRESUBMIT.py » ('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) 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 "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" 5 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
6 6
7 #include "base/metrics/sparse_histogram.h"
7 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" 8 #include "content/browser/renderer_host/pepper/pepper_message_filter.h"
8 #include "content/browser/tracing/trace_message_filter.h" 9 #include "content/browser/tracing/trace_message_filter.h"
9 #include "content/common/pepper_renderer_instance_data.h" 10 #include "content/common/pepper_renderer_instance_data.h"
10 #include "content/public/common/process_type.h" 11 #include "content/public/common/process_type.h"
11 #include "ipc/ipc_message_macros.h" 12 #include "ipc/ipc_message_macros.h"
12 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 // static 17 // static
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived( 158 bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived(
158 const IPC::Message& msg) { 159 const IPC::Message& msg) {
159 // Don't forward messages if our owner object has been destroyed. 160 // Don't forward messages if our owner object has been destroyed.
160 if (!ppapi_host_) 161 if (!ppapi_host_)
161 return false; 162 return false;
162 163
163 bool handled = true; 164 bool handled = true;
164 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl::HostMessageFilter, msg) 165 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl::HostMessageFilter, msg)
165 // Add necessary message handlers here. 166 // Add necessary message handlers here.
166 IPC_MESSAGE_HANDLER(PpapiHostMsg_Keepalive, OnKeepalive) 167 IPC_MESSAGE_HANDLER(PpapiHostMsg_Keepalive, OnKeepalive)
168 IPC_MESSAGE_HANDLER(PpapiHostMsg_LogInterfaceUsage,
169 OnHostMsgLogInterfaceUsage)
167 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_->OnMessageReceived(msg)) 170 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_->OnMessageReceived(msg))
168 IPC_END_MESSAGE_MAP(); 171 IPC_END_MESSAGE_MAP();
169 return handled; 172 return handled;
170 } 173 }
171 174
172 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { 175 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() {
173 DCHECK(ppapi_host_); 176 DCHECK(ppapi_host_);
174 ppapi_host_ = NULL; 177 ppapi_host_ = NULL;
175 browser_ppapi_host_impl_ = NULL; 178 browser_ppapi_host_impl_ = NULL;
176 } 179 }
177 180
178 BrowserPpapiHostImpl::HostMessageFilter::~HostMessageFilter() { 181 BrowserPpapiHostImpl::HostMessageFilter::~HostMessageFilter() {
179 } 182 }
180 183
181 void BrowserPpapiHostImpl::HostMessageFilter::OnKeepalive() { 184 void BrowserPpapiHostImpl::HostMessageFilter::OnKeepalive() {
182 if (browser_ppapi_host_impl_) 185 if (browser_ppapi_host_impl_)
183 browser_ppapi_host_impl_->OnKeepalive(); 186 browser_ppapi_host_impl_->OnKeepalive();
184 } 187 }
185 188
189 void BrowserPpapiHostImpl::HostMessageFilter::OnHostMsgLogInterfaceUsage(
190 int hash) const {
191 UMA_HISTOGRAM_SPARSE_SLOWLY("Pepper.InterfaceUsed", hash);
192 }
193
186 void BrowserPpapiHostImpl::OnKeepalive() { 194 void BrowserPpapiHostImpl::OnKeepalive() {
187 // An instance has been active. The on_keepalive_callback_ will be 195 // An instance has been active. The on_keepalive_callback_ will be
188 // used to permit the content embedder to handle this, e.g. by tracking 196 // used to permit the content embedder to handle this, e.g. by tracking
189 // activity and shutting down processes that go idle. 197 // activity and shutting down processes that go idle.
190 // 198 //
191 // Currently embedders do not need to distinguish between instances having 199 // Currently embedders do not need to distinguish between instances having
192 // different idle state, and thus this implementation handles all instances 200 // different idle state, and thus this implementation handles all instances
193 // for this module together. 201 // for this module together.
194 202
195 if (on_keepalive_callback_.is_null()) 203 if (on_keepalive_callback_.is_null())
196 return; 204 return;
197 205
198 BrowserPpapiHost::OnKeepaliveInstanceData 206 BrowserPpapiHost::OnKeepaliveInstanceData
199 instance_data(instance_map_.size()); 207 instance_data(instance_map_.size());
200 208
201 InstanceMap::iterator instance = instance_map_.begin(); 209 InstanceMap::iterator instance = instance_map_.begin();
202 int i = 0; 210 int i = 0;
203 while (instance != instance_map_.end()) { 211 while (instance != instance_map_.end()) {
204 instance_data[i].render_process_id = instance->second.render_process_id; 212 instance_data[i].render_process_id = instance->second.render_process_id;
205 instance_data[i].render_frame_id = instance->second.render_frame_id; 213 instance_data[i].render_frame_id = instance->second.render_frame_id;
206 instance_data[i].document_url = instance->second.document_url; 214 instance_data[i].document_url = instance->second.document_url;
207 ++instance; 215 ++instance;
208 ++i; 216 ++i;
209 } 217 }
210 on_keepalive_callback_.Run(instance_data, profile_data_directory_); 218 on_keepalive_callback_.Run(instance_data, profile_data_directory_);
211 } 219 }
212 220
213 } // namespace content 221 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/browser_ppapi_host_impl.h ('k') | ppapi/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698