| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); | 86 base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void InitOnIOThread(const std::string& mime_type) { | 89 void InitOnIOThread(const std::string& mime_type) { |
| 90 PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance(); | 90 PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance(); |
| 91 | 91 |
| 92 // Get the plugin file path. | 92 // Get the plugin file path. |
| 93 std::vector<webkit::WebPluginInfo> plugins; | 93 std::vector<webkit::WebPluginInfo> plugins; |
| 94 plugin_service->GetPluginInfoArray( | 94 plugin_service->GetPluginInfoArray( |
| 95 GURL(), mime_type, false, &plugins, NULL); | 95 GURL(), mime_type, false, &plugins, NULL); |
| 96 FilePath plugin_path; | 96 base::FilePath plugin_path; |
| 97 if (!plugins.empty()) // May be empty for some tests. | 97 if (!plugins.empty()) // May be empty for some tests. |
| 98 plugin_path = plugins[0].path; | 98 plugin_path = plugins[0].path; |
| 99 | 99 |
| 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 101 remove_start_time_ = base::Time::Now(); | 101 remove_start_time_ = base::Time::Now(); |
| 102 is_removing_ = true; | 102 is_removing_ = true; |
| 103 // Balanced in On[Ppapi]ChannelOpened or OnError. Exactly one them will | 103 // Balanced in On[Ppapi]ChannelOpened or OnError. Exactly one them will |
| 104 // eventually be called, so we need to keep this object around until then. | 104 // eventually be called, so we need to keep this object around until then. |
| 105 AddRef(); | 105 AddRef(); |
| 106 | 106 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 195 } |
| 196 | 196 |
| 197 base::WaitableEvent* event() { return event_.get(); } | 197 base::WaitableEvent* event() { return event_.get(); } |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | 200 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
| 201 friend class base::DeleteHelper<Context>; | 201 friend class base::DeleteHelper<Context>; |
| 202 virtual ~Context() {} | 202 virtual ~Context() {} |
| 203 | 203 |
| 204 IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) { | 204 IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) { |
| 205 FilePath profile_path = | 205 base::FilePath profile_path = |
| 206 PepperFlashFileMessageFilter::GetDataDirName(browser_context_path_); | 206 PepperFlashFileMessageFilter::GetDataDirName(browser_context_path_); |
| 207 // TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc | 207 // TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc |
| 208 // (which prepends the plugin name to the relative part of the path | 208 // (which prepends the plugin name to the relative part of the path |
| 209 // instead, with the absolute, profile-dependent part being enforced by | 209 // instead, with the absolute, profile-dependent part being enforced by |
| 210 // the browser). | 210 // the browser). |
| 211 #if defined(OS_WIN) | 211 #if defined(OS_WIN) |
| 212 FilePath plugin_data_path = | 212 base::FilePath plugin_data_path = |
| 213 profile_path.Append(FilePath(UTF8ToUTF16(plugin_name_))); | 213 profile_path.Append(base::FilePath(UTF8ToUTF16(plugin_name_))); |
| 214 #else | 214 #else |
| 215 FilePath plugin_data_path = profile_path.Append(FilePath(plugin_name_)); | 215 base::FilePath plugin_data_path = |
| 216 profile_path.Append(base::FilePath(plugin_name_)); |
| 216 #endif // defined(OS_WIN) | 217 #endif // defined(OS_WIN) |
| 217 return new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(), | 218 return new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(), |
| 218 kClearAllData, max_age); | 219 kClearAllData, max_age); |
| 219 } | 220 } |
| 220 | 221 |
| 221 // Connects the client side of a newly opened plug-in channel. | 222 // Connects the client side of a newly opened plug-in channel. |
| 222 void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { | 223 void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { |
| 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 224 | 225 |
| 225 // If we timed out, don't bother connecting. | 226 // If we timed out, don't bother connecting. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 279 |
| 279 scoped_ptr<base::WaitableEvent> event_; | 280 scoped_ptr<base::WaitableEvent> event_; |
| 280 // The point in time when we start removing data. | 281 // The point in time when we start removing data. |
| 281 base::Time remove_start_time_; | 282 base::Time remove_start_time_; |
| 282 // The point in time from which on we remove data. | 283 // The point in time from which on we remove data. |
| 283 base::Time begin_time_; | 284 base::Time begin_time_; |
| 284 bool is_removing_; | 285 bool is_removing_; |
| 285 | 286 |
| 286 // Path for the current profile. Must be retrieved on the UI thread from the | 287 // Path for the current profile. Must be retrieved on the UI thread from the |
| 287 // browser context when we start so we can use it later on the I/O thread. | 288 // browser context when we start so we can use it later on the I/O thread. |
| 288 FilePath browser_context_path_; | 289 base::FilePath browser_context_path_; |
| 289 | 290 |
| 290 // The resource context for the profile. Use only on the I/O thread. | 291 // The resource context for the profile. Use only on the I/O thread. |
| 291 ResourceContext* resource_context_; | 292 ResourceContext* resource_context_; |
| 292 | 293 |
| 293 // The name of the plugin. Use only on the I/O thread. | 294 // The name of the plugin. Use only on the I/O thread. |
| 294 std::string plugin_name_; | 295 std::string plugin_name_; |
| 295 | 296 |
| 296 // The channel is NULL until we have opened a connection to the plug-in | 297 // The channel is NULL until we have opened a connection to the plug-in |
| 297 // process. | 298 // process. |
| 298 scoped_ptr<IPC::Channel> channel_; | 299 scoped_ptr<IPC::Channel> channel_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 309 | 310 |
| 310 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( | 311 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( |
| 311 base::Time begin_time) { | 312 base::Time begin_time) { |
| 312 DCHECK(!context_.get()); | 313 DCHECK(!context_.get()); |
| 313 context_ = new Context(begin_time, browser_context_); | 314 context_ = new Context(begin_time, browser_context_); |
| 314 context_->Init(mime_type_); | 315 context_->Init(mime_type_); |
| 315 return context_->event(); | 316 return context_->event(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace content | 319 } // namespace content |
| OLD | NEW |