| OLD | NEW |
| 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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 9 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
| 10 #include "content/browser/tracing/trace_message_filter.h" | 10 #include "content/browser/tracing/trace_message_filter.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 ppapi_host_->AddHostFactoryFilter(std::unique_ptr<ppapi::host::HostFactory>( | 64 ppapi_host_->AddHostFactoryFilter(std::unique_ptr<ppapi::host::HostFactory>( |
| 65 new ContentBrowserPepperHostFactory(this))); | 65 new ContentBrowserPepperHostFactory(this))); |
| 66 } | 66 } |
| 67 | 67 |
| 68 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { | 68 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { |
| 69 // Notify the filter so it won't foward messages to us. | 69 // Notify the filter so it won't foward messages to us. |
| 70 message_filter_->OnHostDestroyed(); | 70 message_filter_->OnHostDestroyed(); |
| 71 | 71 |
| 72 // Notify instance observers about our impending destruction. | 72 // Notify instance observers about our impending destruction. |
| 73 for (auto& instance_data : instance_map_) { | 73 for (auto& instance_data : instance_map_) { |
| 74 FOR_EACH_OBSERVER(InstanceObserver, instance_data.second->observer_list, | 74 for (auto& observer : instance_data.second->observer_list) |
| 75 OnHostDestroyed()); | 75 observer.OnHostDestroyed(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Delete the host explicitly first. This shutdown will destroy the | 78 // Delete the host explicitly first. This shutdown will destroy the |
| 79 // resources, which may want to do cleanup in their destructors and expect | 79 // resources, which may want to do cleanup in their destructors and expect |
| 80 // their pointers to us to be valid. | 80 // their pointers to us to be valid. |
| 81 ppapi_host_.reset(); | 81 ppapi_host_.reset(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() { | 84 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() { |
| 85 return ppapi_host_.get(); | 85 return ppapi_host_.get(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 auto* data = instance_map_.get(instance); | 173 auto* data = instance_map_.get(instance); |
| 174 if (data) | 174 if (data) |
| 175 data->observer_list.RemoveObserver(observer); | 175 data->observer_list.RemoveObserver(observer); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void BrowserPpapiHostImpl::OnThrottleStateChanged(PP_Instance instance, | 178 void BrowserPpapiHostImpl::OnThrottleStateChanged(PP_Instance instance, |
| 179 bool is_throttled) { | 179 bool is_throttled) { |
| 180 auto* data = instance_map_.get(instance); | 180 auto* data = instance_map_.get(instance); |
| 181 if (data) { | 181 if (data) { |
| 182 data->is_throttled = is_throttled; | 182 data->is_throttled = is_throttled; |
| 183 FOR_EACH_OBSERVER(InstanceObserver, data->observer_list, | 183 for (auto& observer : data->observer_list) |
| 184 OnThrottleStateChanged(is_throttled)); | 184 observer.OnThrottleStateChanged(is_throttled); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool BrowserPpapiHostImpl::IsThrottled(PP_Instance instance) const { | 188 bool BrowserPpapiHostImpl::IsThrottled(PP_Instance instance) const { |
| 189 auto* data = instance_map_.get(instance); | 189 auto* data = instance_map_.get(instance); |
| 190 if (data) | 190 if (data) |
| 191 return data->is_throttled; | 191 return data->is_throttled; |
| 192 | 192 |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 instance->second->renderer_data.render_frame_id; | 265 instance->second->renderer_data.render_frame_id; |
| 266 instance_data[i].document_url = | 266 instance_data[i].document_url = |
| 267 instance->second->renderer_data.document_url; | 267 instance->second->renderer_data.document_url; |
| 268 ++instance; | 268 ++instance; |
| 269 ++i; | 269 ++i; |
| 270 } | 270 } |
| 271 on_keepalive_callback_.Run(instance_data, profile_data_directory_); | 271 on_keepalive_callback_.Run(instance_data, profile_data_directory_); |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace content | 274 } // namespace content |
| OLD | NEW |