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