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/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "chrome/browser/plugin_process_host.h" | 11 #include "chrome/browser/plugin_process_host.h" |
12 #include "ipc/ipc_channel_proxy.h" | 12 #include "ipc/ipc_channel.h" |
13 #include "ipc/ipc_message.h" | |
14 | 13 |
15 class Task; | 14 class Task; |
16 | 15 |
17 namespace base { | 16 namespace base { |
18 class MessageLoopProxy; | 17 class MessageLoopProxy; |
19 } | 18 } |
20 | 19 |
21 class PluginDataRemover : public PluginProcessHost::Client, | 20 class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>, |
| 21 public PluginProcessHost::Client, |
22 public IPC::Channel::Listener { | 22 public IPC::Channel::Listener { |
23 public: | 23 public: |
24 PluginDataRemover(); | 24 PluginDataRemover(); |
25 ~PluginDataRemover(); | |
26 | 25 |
27 // Starts removing plug-in data stored since |begin_time| and calls | 26 // Starts removing plug-in data stored since |begin_time|. If |done_task| is |
28 // |done_task| on the current thread when finished. | 27 // not NULL, it is run on the current thread when removing has finished. |
29 void StartRemoving(base::Time begin_time, Task* done_task); | 28 void StartRemoving(base::Time begin_time, Task* done_task); |
30 | 29 |
| 30 // 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 |
| 32 // should only be called on the FILE thread. |
| 33 static bool IsSupported(); |
| 34 |
| 35 bool is_removing() const { return is_removing_; } |
| 36 |
| 37 // Sets the task to run when removing has finished. Takes ownership of |
| 38 // the passed task. |
| 39 void set_done_task(Task* task) { done_task_.reset(task); } |
| 40 |
31 // PluginProcessHost::Client methods | 41 // PluginProcessHost::Client methods |
32 virtual int ID(); | 42 virtual int ID(); |
33 virtual bool OffTheRecord(); | 43 virtual bool OffTheRecord(); |
34 virtual void SetPluginInfo(const WebPluginInfo& info); | 44 virtual void SetPluginInfo(const WebPluginInfo& info); |
35 virtual void OnChannelOpened(const IPC::ChannelHandle& handle); | 45 virtual void OnChannelOpened(const IPC::ChannelHandle& handle); |
36 virtual void OnError(); | 46 virtual void OnError(); |
37 | 47 |
38 // IPC::ChannelProxy::MessageFilter methods | 48 // IPC::ChannelProxy::MessageFilter methods |
39 virtual void OnMessageReceived(const IPC::Message& message); | 49 virtual void OnMessageReceived(const IPC::Message& message); |
40 virtual void OnChannelError(); | 50 virtual void OnChannelError(); |
41 | 51 |
42 private: | 52 private: |
| 53 friend class base::RefCountedThreadSafe<PluginDataRemover>; |
| 54 ~PluginDataRemover(); |
| 55 |
43 void SignalDone(); | 56 void SignalDone(); |
44 void SignalError(); | 57 void ConnectToChannel(const IPC::ChannelHandle& handle); |
45 void OnClearSiteDataResult(bool success); | 58 void OnClearSiteDataResult(bool success); |
46 void OnTimeout(); | 59 void OnTimeout(); |
47 | 60 |
48 scoped_refptr<base::MessageLoopProxy> message_loop_; | 61 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 62 bool is_removing_; |
49 scoped_ptr<Task> done_task_; | 63 scoped_ptr<Task> done_task_; |
| 64 // The point in time when we start removing data. |
| 65 base::Time remove_start_time_; |
| 66 // The point in time from which on we remove data. |
50 base::Time begin_time_; | 67 base::Time begin_time_; |
51 // We own the channel, but it's used on the IO thread, so it needs to be | 68 // We own the channel, but it's used on the IO thread, so it needs to be |
52 // deleted there as well. | 69 // deleted there as well. |
53 IPC::Channel* channel_; | 70 IPC::Channel* channel_; |
54 ScopedRunnableMethodFactory<PluginDataRemover> method_factory_; | |
55 }; | 71 }; |
56 | 72 |
57 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ | 73 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ |
OLD | NEW |