OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "content/browser/plugin_process_host.h" | 11 #include "content/browser/plugin_process_host.h" |
12 | 12 |
| 13 class Profile; |
13 class Task; | 14 class Task; |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class MessageLoopProxy; | 17 class MessageLoopProxy; |
17 class WaitableEvent; | 18 class WaitableEvent; |
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 explicit PluginDataRemover(Profile* profile); |
25 | 26 |
26 // The plug-in whose data should be removed (usually Flash) is specified via | 27 // The plug-in whose data should be removed (usually Flash) is specified via |
27 // its MIME type. This method sets a different MIME type in order to call a | 28 // its MIME type. This method sets a different MIME type in order to call a |
28 // different plug-in (for example in tests). | 29 // different plug-in (for example in tests). |
29 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; } | 30 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; } |
30 | 31 |
31 // Starts removing plug-in data stored since |begin_time|. | 32 // Starts removing plug-in data stored since |begin_time|. |
32 base::WaitableEvent* StartRemoving(base::Time begin_time); | 33 base::WaitableEvent* StartRemoving(base::Time begin_time); |
33 | 34 |
34 // Returns whether there is a plug-in installed that supports removing | 35 // Returns whether there is a plug-in installed that supports removing |
35 // 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 |
36 // should only be called on the FILE thread. | 37 // should only be called on the FILE thread. |
37 static bool IsSupported(); | 38 static bool IsSupported(); |
38 | 39 |
39 // Indicates whether we are still in the process of removing plug-in data. | 40 // Indicates whether we are still in the process of removing plug-in data. |
40 bool is_removing() const { return is_removing_; } | 41 bool is_removing() const { return is_removing_; } |
41 | 42 |
42 // Wait until removing has finished. When the browser is still running (i.e. | 43 // Wait until removing has finished. When the browser is still running (i.e. |
43 // not during shutdown), you should use a WaitableEventWatcher in combination | 44 // not during shutdown), you should use a WaitableEventWatcher in combination |
44 // with the WaitableEvent returned by StartRemoving. | 45 // with the WaitableEvent returned by StartRemoving. |
45 void Wait(); | 46 void Wait(); |
46 | 47 |
47 // PluginProcessHost::Client methods. | 48 // PluginProcessHost::Client methods. |
48 virtual int ID(); | 49 virtual int ID(); |
49 virtual bool OffTheRecord(); | 50 virtual bool OffTheRecord(); |
| 51 virtual const content::ResourceContext& GetResourceContext(); |
50 virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info); | 52 virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info); |
51 virtual void OnChannelOpened(const IPC::ChannelHandle& handle); | 53 virtual void OnChannelOpened(const IPC::ChannelHandle& handle); |
52 virtual void OnError(); | 54 virtual void OnError(); |
53 | 55 |
54 // IPC::Channel::Listener methods. | 56 // IPC::Channel::Listener methods. |
55 virtual bool OnMessageReceived(const IPC::Message& message); | 57 virtual bool OnMessageReceived(const IPC::Message& message); |
56 virtual void OnChannelError(); | 58 virtual void OnChannelError(); |
57 | 59 |
58 private: | 60 private: |
59 friend class base::RefCountedThreadSafe<PluginDataRemover>; | 61 friend class base::RefCountedThreadSafe<PluginDataRemover>; |
(...skipping 10 matching lines...) Expand all Loading... |
70 // Called when a timeout happens in order not to block the client | 72 // Called when a timeout happens in order not to block the client |
71 // indefinitely. | 73 // indefinitely. |
72 void OnTimeout(); | 74 void OnTimeout(); |
73 | 75 |
74 std::string mime_type_; | 76 std::string mime_type_; |
75 bool is_removing_; | 77 bool is_removing_; |
76 // The point in time when we start removing data. | 78 // The point in time when we start removing data. |
77 base::Time remove_start_time_; | 79 base::Time remove_start_time_; |
78 // The point in time from which on we remove data. | 80 // The point in time from which on we remove data. |
79 base::Time begin_time_; | 81 base::Time begin_time_; |
| 82 // The resource context for the profile. |
| 83 const content::ResourceContext& context_; |
80 scoped_ptr<base::WaitableEvent> event_; | 84 scoped_ptr<base::WaitableEvent> event_; |
81 // We own the channel, but it's used on the IO thread, so it needs to be | 85 // We own the channel, but it's used on the IO thread, so it needs to be |
82 // deleted there. It's NULL until we have opened a connection to the plug-in | 86 // deleted there. It's NULL until we have opened a connection to the plug-in |
83 // process. | 87 // process. |
84 IPC::Channel* channel_; | 88 IPC::Channel* channel_; |
85 | 89 |
86 DISALLOW_COPY_AND_ASSIGN(PluginDataRemover); | 90 DISALLOW_COPY_AND_ASSIGN(PluginDataRemover); |
87 }; | 91 }; |
88 | 92 |
89 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ | 93 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_ |
OLD | NEW |