summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_data_remover.h
blob: cbc255678aeac711efbf95dc7f7251ec00185cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_
#define CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_
#pragma once

#include "base/ref_counted.h"
#include "base/time.h"
#include "chrome/browser/plugin_process_host.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_message.h"

class Task;

namespace base {
class MessageLoopProxy;
}

class PluginDataRemover : public PluginProcessHost::Client,
                          public IPC::Channel::Listener {
 public:
  PluginDataRemover();
  ~PluginDataRemover();

  // Starts removing plug-in data stored since |begin_time| and calls
  // |done_task| on the current thread when finished.
  void StartRemoving(base::Time begin_time, Task* done_task);

  // PluginProcessHost::Client methods
  virtual int ID();
  virtual bool OffTheRecord();
  virtual void SetPluginInfo(const WebPluginInfo& info);
  virtual void OnChannelOpened(const IPC::ChannelHandle& handle);
  virtual void OnError();

  // IPC::ChannelProxy::MessageFilter methods
  virtual void OnMessageReceived(const IPC::Message& message);
  virtual void OnChannelError();

 private:
  void SignalDone();
  void SignalError();
  void OnClearSiteDataResult(bool success);
  void OnTimeout();

  scoped_refptr<base::MessageLoopProxy> message_loop_;
  scoped_ptr<Task> done_task_;
  base::Time begin_time_;
  // We own the channel, but it's used on the IO thread, so it needs to be
  // deleted there as well.
  IPC::Channel* channel_;
  ScopedRunnableMethodFactory<PluginDataRemover> method_factory_;
};

#endif  // CHROME_BROWSER_PLUGIN_DATA_REMOVER_H_