| 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/plugin_data_remover_impl.h" | 5 #include "content/browser/plugin_data_remover_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/sequenced_task_runner_helpers.h" |
| 9 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "base/version.h" | 12 #include "base/version.h" |
| 12 #include "content/browser/plugin_process_host.h" | 13 #include "content/browser/plugin_process_host.h" |
| 13 #include "content/browser/plugin_service_impl.h" | 14 #include "content/browser/plugin_service_impl.h" |
| 14 #include "content/browser/renderer_host/pepper_file_message_filter.h" | 15 #include "content/browser/renderer_host/pepper_file_message_filter.h" |
| 15 #include "content/common/child_process_host_impl.h" | 16 #include "content/common/child_process_host_impl.h" |
| 16 #include "content/common/plugin_messages.h" | 17 #include "content/common/plugin_messages.h" |
| 17 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 Context(base::Time begin_time, BrowserContext* browser_context) | 67 Context(base::Time begin_time, BrowserContext* browser_context) |
| 67 : event_(new base::WaitableEvent(true, false)), | 68 : event_(new base::WaitableEvent(true, false)), |
| 68 begin_time_(begin_time), | 69 begin_time_(begin_time), |
| 69 is_removing_(false), | 70 is_removing_(false), |
| 70 browser_context_path_(browser_context->GetPath()), | 71 browser_context_path_(browser_context->GetPath()), |
| 71 resource_context_(browser_context->GetResourceContext()), | 72 resource_context_(browser_context->GetResourceContext()), |
| 72 channel_(NULL) { | 73 channel_(NULL) { |
| 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 74 } | 75 } |
| 75 | 76 |
| 76 virtual ~Context() { | |
| 77 } | |
| 78 | |
| 79 void Init(const std::string& mime_type) { | 77 void Init(const std::string& mime_type) { |
| 80 BrowserThread::PostTask( | 78 BrowserThread::PostTask( |
| 81 BrowserThread::IO, | 79 BrowserThread::IO, |
| 82 FROM_HERE, | 80 FROM_HERE, |
| 83 base::Bind(&Context::InitOnIOThread, this, mime_type)); | 81 base::Bind(&Context::InitOnIOThread, this, mime_type)); |
| 84 BrowserThread::PostDelayedTask( | 82 BrowserThread::PostDelayedTask( |
| 85 BrowserThread::IO, | 83 BrowserThread::IO, |
| 86 FROM_HERE, | 84 FROM_HERE, |
| 87 base::Bind(&Context::OnTimeout, this), | 85 base::Bind(&Context::OnTimeout, this), |
| 88 base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); | 86 base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 130 } |
| 133 | 131 |
| 134 virtual bool OffTheRecord() OVERRIDE { | 132 virtual bool OffTheRecord() OVERRIDE { |
| 135 return false; | 133 return false; |
| 136 } | 134 } |
| 137 | 135 |
| 138 virtual ResourceContext* GetResourceContext() OVERRIDE { | 136 virtual ResourceContext* GetResourceContext() OVERRIDE { |
| 139 return resource_context_; | 137 return resource_context_; |
| 140 } | 138 } |
| 141 | 139 |
| 142 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE { | 140 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE {} |
| 143 } | |
| 144 | 141 |
| 145 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { | 142 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {} |
| 146 } | |
| 147 | 143 |
| 148 virtual void OnSentPluginChannelRequest() OVERRIDE { | 144 virtual void OnSentPluginChannelRequest() OVERRIDE {} |
| 149 } | |
| 150 | 145 |
| 151 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE { | 146 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE { |
| 152 ConnectToChannel(handle, false); | 147 ConnectToChannel(handle, false); |
| 153 // Balancing the AddRef call. | 148 // Balancing the AddRef call. |
| 154 Release(); | 149 Release(); |
| 155 } | 150 } |
| 156 | 151 |
| 157 virtual void OnError() OVERRIDE { | 152 virtual void OnError() OVERRIDE { |
| 158 LOG(ERROR) << "Couldn't open plugin channel"; | 153 LOG(ERROR) << "Couldn't open plugin channel"; |
| 159 SignalDone(); | 154 SignalDone(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 virtual void OnChannelError() OVERRIDE { | 189 virtual void OnChannelError() OVERRIDE { |
| 195 if (is_removing_) { | 190 if (is_removing_) { |
| 196 NOTREACHED() << "Channel error"; | 191 NOTREACHED() << "Channel error"; |
| 197 SignalDone(); | 192 SignalDone(); |
| 198 } | 193 } |
| 199 } | 194 } |
| 200 | 195 |
| 201 base::WaitableEvent* event() { return event_.get(); } | 196 base::WaitableEvent* event() { return event_.get(); } |
| 202 | 197 |
| 203 private: | 198 private: |
| 199 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
| 200 friend class base::DeleteHelper<Context>; |
| 201 virtual ~Context() {} |
| 202 |
| 204 // Connects the client side of a newly opened plug-in channel. | 203 // Connects the client side of a newly opened plug-in channel. |
| 205 void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { | 204 void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { |
| 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 207 | 206 |
| 208 // If we timed out, don't bother connecting. | 207 // If we timed out, don't bother connecting. |
| 209 if (!is_removing_) | 208 if (!is_removing_) |
| 210 return; | 209 return; |
| 211 | 210 |
| 212 DCHECK(!channel_.get()); | 211 DCHECK(!channel_.get()); |
| 213 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); | 212 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 297 |
| 299 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( | 298 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( |
| 300 base::Time begin_time) { | 299 base::Time begin_time) { |
| 301 DCHECK(!context_.get()); | 300 DCHECK(!context_.get()); |
| 302 context_ = new Context(begin_time, browser_context_); | 301 context_ = new Context(begin_time, browser_context_); |
| 303 context_->Init(mime_type_); | 302 context_->Init(mime_type_); |
| 304 return context_->event(); | 303 return context_->event(); |
| 305 } | 304 } |
| 306 | 305 |
| 307 } // namespace content | 306 } // namespace content |
| OLD | NEW |