Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ |
| 6 #define CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ | 6 #define CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/process.h" | |
| 9 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 10 #include "base/time.h" | 11 #include "base/time.h" |
| 11 #include "chrome/browser/plugin_process_host.h" | 12 #include "chrome/browser/plugin_process_host.h" |
| 12 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
| 13 | 14 |
| 14 class Task; | 15 class Task; |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class MessageLoopProxy; | 18 class MessageLoopProxy; |
| 18 } | 19 } |
| 19 | 20 |
| 20 class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>, | 21 class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>, |
| 21 public PluginProcessHost::Client, | 22 public PluginProcessHost::Client, |
| 22 public IPC::Channel::Listener { | 23 public IPC::Channel::Listener { |
| 23 public: | 24 public: |
| 24 PluginDataRemover(); | 25 PluginDataRemover(); |
| 25 | 26 |
| 26 // Starts removing plug-in data stored since |begin_time|. If |done_task| is | 27 // Starts removing plug-in data stored since |begin_time|. |
| 27 // not NULL, it is run on the current thread when removing has finished. | 28 // If |terminate| is true, the plugin process should exit after removing data. |
| 28 void StartRemoving(base::Time begin_time, Task* done_task); | 29 // If |done_task| is not NULL, it is run on the current thread when removing |
| 30 // has finished. | |
| 31 void StartRemoving(const base::Time& begin_time, | |
| 32 bool terminate, | |
| 33 Task* done_task); | |
| 29 | 34 |
| 30 // Returns whether there is a plug-in installed that supports removing | 35 // Returns whether there is a plug-in installed that supports removing |
| 31 // LSO data. Because this method possibly has to load the plug-in list, it | 36 // LSO data. Because this method possibly has to load the plug-in list, it |
| 32 // should only be called on the FILE thread. | 37 // should only be called on the FILE thread. |
| 33 static bool IsSupported(); | 38 static bool IsSupported(); |
| 34 | 39 |
| 35 bool is_removing() const { return is_removing_; } | 40 bool is_removing() const { return is_removing_; } |
| 36 | 41 |
| 37 // Sets the task to run when removing has finished. Takes ownership of | 42 // Wait for the plugin process to exit. This should only be called after |
| 38 // the passed task. | 43 // StartRemoving has been called with |terminate| equals true. |
| 39 void set_done_task(Task* task) { done_task_.reset(task); } | 44 void WaitForPluginToExit(); |
| 40 | 45 |
| 41 // PluginProcessHost::Client methods | 46 // PluginProcessHost::Client methods |
| 42 virtual int ID(); | 47 virtual int ID(); |
| 43 virtual bool OffTheRecord(); | 48 virtual bool OffTheRecord(); |
| 44 virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info); | 49 virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info); |
| 50 virtual void OnPluginProcessFound(PluginProcessHost* process); | |
| 45 virtual void OnChannelOpened(const IPC::ChannelHandle& handle); | 51 virtual void OnChannelOpened(const IPC::ChannelHandle& handle); |
| 46 virtual void OnError(); | 52 virtual void OnError(); |
| 47 | 53 |
| 48 // IPC::Channel::Listener methods | 54 // IPC::Channel::Listener methods |
| 49 virtual bool OnMessageReceived(const IPC::Message& message); | 55 virtual bool OnMessageReceived(const IPC::Message& message); |
| 50 virtual void OnChannelError(); | 56 virtual void OnChannelError(); |
| 51 | 57 |
| 52 private: | 58 private: |
| 53 friend class base::RefCountedThreadSafe<PluginDataRemover>; | 59 friend class base::RefCountedThreadSafe<PluginDataRemover>; |
| 54 ~PluginDataRemover(); | 60 ~PluginDataRemover(); |
| 55 | 61 |
| 56 void SignalDone(); | 62 void SignalDone(); |
| 63 void ReleaseBrowserProcess(); | |
| 57 void ConnectToChannel(const IPC::ChannelHandle& handle); | 64 void ConnectToChannel(const IPC::ChannelHandle& handle); |
| 58 void OnClearSiteDataResult(bool success); | 65 void OnClearSiteDataResult(bool success); |
| 66 void OnPluginShuttingDown(); | |
| 59 void OnTimeout(); | 67 void OnTimeout(); |
| 60 | 68 |
| 61 scoped_refptr<base::MessageLoopProxy> message_loop_; | 69 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 62 bool is_removing_; | 70 bool is_removing_; |
| 71 bool terminate_process_; | |
| 63 scoped_ptr<Task> done_task_; | 72 scoped_ptr<Task> done_task_; |
| 64 // The point in time when we start removing data. | 73 // The point in time when we start removing data. |
| 65 base::Time remove_start_time_; | 74 base::Time remove_start_time_; |
| 66 // The point in time from which on we remove data. | 75 // The point in time from which on we remove data. |
| 67 base::Time begin_time_; | 76 base::Time begin_time_; |
| 77 bool has_browser_ref_; | |
|
jam
2011/01/13 19:52:44
comment?
| |
| 78 PluginProcessHost* plugin_process_; | |
| 79 base::ProcessHandle handle_; | |
| 68 // We own the channel, but it's used on the IO thread, so it needs to be | 80 // We own the channel, but it's used on the IO thread, so it needs to be |
| 69 // deleted there as well. | 81 // deleted there as well. |
| 70 IPC::Channel* channel_; | 82 IPC::Channel* channel_; |
| 71 }; | 83 }; |
| 72 | 84 |
| 73 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ | 85 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ |
| OLD | NEW |