Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: content/browser/plugin_data_remover_impl.h

Issue 8603012: Fix race in PluginDataRemoverImpl going away while it's still being used on the IO thread... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Move Context class to cc file Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/plugin_data_remover_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CONTENT_BROWSER_PLUGIN_DATA_REMOVER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_PLUGIN_DATA_REMOVER_IMPL_H_
6 #define CONTENT_BROWSER_PLUGIN_DATA_REMOVER_IMPL_H_ 6 #define CONTENT_BROWSER_PLUGIN_DATA_REMOVER_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/ref_counted.h"
13 #include "content/browser/plugin_process_host.h"
14 #include "content/public/browser/plugin_data_remover.h" 13 #include "content/public/browser/plugin_data_remover.h"
15 14
16 class CONTENT_EXPORT PluginDataRemoverImpl 15 class CONTENT_EXPORT PluginDataRemoverImpl : public content::PluginDataRemover {
17 : public content::PluginDataRemover,
18 public NON_EXPORTED_BASE(PluginProcessHost::Client),
19 public IPC::Channel::Listener {
20 public: 16 public:
21 explicit PluginDataRemoverImpl( 17 explicit PluginDataRemoverImpl(
22 const content::ResourceContext& resource_context); 18 const content::ResourceContext& resource_context);
23 virtual ~PluginDataRemoverImpl(); 19 virtual ~PluginDataRemoverImpl();
24 20
25 // content::PluginDataRemover implementation: 21 // content::PluginDataRemover implementation:
26 virtual base::WaitableEvent* StartRemoving(base::Time begin_time) OVERRIDE; 22 virtual base::WaitableEvent* StartRemoving(base::Time begin_time) OVERRIDE;
27 23
28 // The plug-in whose data should be removed (usually Flash) is specified via 24 // The plug-in whose data should be removed (usually Flash) is specified via
29 // its MIME type. This method sets a different MIME type in order to call a 25 // its MIME type. This method sets a different MIME type in order to call a
30 // different plug-in (for example in tests). 26 // different plug-in (for example in tests).
31 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; } 27 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; }
32 28
33 // PluginProcessHost::Client methods.
34 virtual int ID() OVERRIDE;
35 virtual bool OffTheRecord() OVERRIDE;
36 virtual const content::ResourceContext& GetResourceContext() OVERRIDE;
37 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE;
38 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE;
39 virtual void OnSentPluginChannelRequest() OVERRIDE;
40 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE;
41 virtual void OnError() OVERRIDE;
42
43 // IPC::Channel::Listener methods.
44 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
45 virtual void OnChannelError() OVERRIDE;
46
47 private: 29 private:
48 // Signals that we are finished with removing data (successful or not). This 30 class Context;
49 // method is safe to call multiple times.
50 void SignalDone();
51 // Connects the client side of a newly opened plug-in channel.
52 void ConnectToChannel(const IPC::ChannelHandle& handle);
53 // Handles the PluginHostMsg_ClearSiteDataResult message.
54 void OnClearSiteDataResult(bool success);
55 // Called when a timeout happens in order not to block the client
56 // indefinitely.
57 void OnTimeout();
58 31
59 std::string mime_type_; 32 std::string mime_type_;
60 bool is_starting_process_;
61 bool is_removing_;
62 // The point in time when we start removing data.
63 base::Time remove_start_time_;
64 // The point in time from which on we remove data.
65 base::Time begin_time_;
66 // The resource context for the profile. 33 // The resource context for the profile.
67 const content::ResourceContext& context_; 34 const content::ResourceContext& resource_context_;
68 scoped_ptr<base::WaitableEvent> event_;
69 // We own the channel, but it's used on the IO thread, so it needs to be
70 // deleted there. It's NULL until we have opened a connection to the plug-in
71 // process.
72 IPC::Channel* channel_;
73 35
74 base::WeakPtrFactory<PluginDataRemoverImpl> weak_factory_; 36 // This allows this object to be deleted on the UI thread while it's still
37 // being used on the IO thread.
38 scoped_refptr<Context> context_;
75 39
76 DISALLOW_COPY_AND_ASSIGN(PluginDataRemoverImpl); 40 DISALLOW_COPY_AND_ASSIGN(PluginDataRemoverImpl);
77 }; 41 };
78 42
79 #endif // CONTENT_BROWSER_PLUGIN_DATA_REMOVER_IMPL_H_ 43 #endif // CONTENT_BROWSER_PLUGIN_DATA_REMOVER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/plugin_data_remover_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698