| Index: content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
|
| diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
|
| index d9539ee5c59bcb527fa3dd9fa743fdfc9b5ac93e..5d0972e58848ae9d52a86b4cf5199d55a8b5f10f 100644
|
| --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
|
| +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
|
| @@ -99,8 +99,8 @@ bool BrowserPpapiHostImpl::GetRenderFrameIDsForInstance(
|
| return false;
|
| }
|
|
|
| - *render_process_id = found->second.render_process_id;
|
| - *render_frame_id = found->second.render_frame_id;
|
| + *render_process_id = found->second.renderer_data.render_process_id;
|
| + *render_frame_id = found->second.renderer_data.render_frame_id;
|
| return true;
|
| }
|
|
|
| @@ -120,14 +120,14 @@ GURL BrowserPpapiHostImpl::GetDocumentURLForInstance(PP_Instance instance) {
|
| InstanceMap::const_iterator found = instance_map_.find(instance);
|
| if (found == instance_map_.end())
|
| return GURL();
|
| - return found->second.document_url;
|
| + return found->second.renderer_data.document_url;
|
| }
|
|
|
| GURL BrowserPpapiHostImpl::GetPluginURLForInstance(PP_Instance instance) {
|
| InstanceMap::const_iterator found = instance_map_.find(instance);
|
| if (found == instance_map_.end())
|
| return GURL();
|
| - return found->second.plugin_url;
|
| + return found->second.renderer_data.plugin_url;
|
| }
|
|
|
| void BrowserPpapiHostImpl::SetOnKeepaliveCallback(
|
| @@ -139,7 +139,10 @@ void BrowserPpapiHostImpl::AddInstance(
|
| PP_Instance instance,
|
| const PepperRendererInstanceData& instance_data) {
|
| DCHECK(instance_map_.find(instance) == instance_map_.end());
|
| - instance_map_[instance] = instance_data;
|
| + instance_map_[instance].renderer_data = instance_data;
|
| +
|
| + instance_observers_map_.set(
|
| + instance, make_scoped_ptr(new ObserverList<InstanceObserver>()));
|
| }
|
|
|
| void BrowserPpapiHostImpl::DeleteInstance(PP_Instance instance) {
|
| @@ -149,6 +152,42 @@ void BrowserPpapiHostImpl::DeleteInstance(PP_Instance instance) {
|
| return;
|
| }
|
| instance_map_.erase(found);
|
| +
|
| + DCHECK(instance_observers_map_.get(instance));
|
| + instance_observers_map_.erase(instance);
|
| +}
|
| +
|
| +void BrowserPpapiHostImpl::AddInstanceObserver(PP_Instance instance,
|
| + InstanceObserver* observer) {
|
| + instance_observers_map_.get(instance)->AddObserver(observer);
|
| +}
|
| +
|
| +void BrowserPpapiHostImpl::RemoveInstanceObserver(PP_Instance instance,
|
| + InstanceObserver* observer) {
|
| + auto* instance_observer = instance_observers_map_.get(instance);
|
| + if (instance_observer != nullptr)
|
| + instance_observer->RemoveObserver(observer);
|
| +}
|
| +
|
| +void BrowserPpapiHostImpl::OnThrottleStateChanged(PP_Instance instance,
|
| + bool is_throttled) {
|
| + auto found = instance_map_.find(instance);
|
| + if (found != instance_map_.end())
|
| + found->second.is_throttled = is_throttled;
|
| +
|
| + auto* instance_observer = instance_observers_map_.get(instance);
|
| + if (instance_observer != nullptr) {
|
| + FOR_EACH_OBSERVER(InstanceObserver, *instance_observer,
|
| + OnThrottleStateChanged(is_throttled));
|
| + }
|
| +}
|
| +
|
| +bool BrowserPpapiHostImpl::IsThrottled(PP_Instance instance) const {
|
| + auto found = instance_map_.find(instance);
|
| + if (found != instance_map_.end()) {
|
| + return found->second.is_throttled;
|
| + }
|
| + return false;
|
| }
|
|
|
| BrowserPpapiHostImpl::HostMessageFilter::HostMessageFilter(
|
| @@ -192,6 +231,12 @@ void BrowserPpapiHostImpl::HostMessageFilter::OnHostMsgLogInterfaceUsage(
|
| UMA_HISTOGRAM_SPARSE_SLOWLY("Pepper.InterfaceUsed", hash);
|
| }
|
|
|
| +BrowserPpapiHostImpl::InstanceData::InstanceData() : is_throttled(false) {
|
| +}
|
| +
|
| +BrowserPpapiHostImpl::InstanceData::~InstanceData() {
|
| +}
|
| +
|
| void BrowserPpapiHostImpl::OnKeepalive() {
|
| // An instance has been active. The on_keepalive_callback_ will be
|
| // used to permit the content embedder to handle this, e.g. by tracking
|
| @@ -209,9 +254,11 @@ void BrowserPpapiHostImpl::OnKeepalive() {
|
| InstanceMap::iterator instance = instance_map_.begin();
|
| int i = 0;
|
| while (instance != instance_map_.end()) {
|
| - instance_data[i].render_process_id = instance->second.render_process_id;
|
| - instance_data[i].render_frame_id = instance->second.render_frame_id;
|
| - instance_data[i].document_url = instance->second.document_url;
|
| + instance_data[i].render_process_id =
|
| + instance->second.renderer_data.render_process_id;
|
| + instance_data[i].render_frame_id =
|
| + instance->second.renderer_data.render_frame_id;
|
| + instance_data[i].document_url = instance->second.renderer_data.document_url;
|
| ++instance;
|
| ++i;
|
| }
|
|
|