summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/clear_on_exit_policy.h
blob: 288da71b75ee7b45bb2216eb58ef838e6cbd4380 (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
// Copyright (c) 2012 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.

// A wrapper around quota::PersistentStoragePolicy used by the net storage
// backends in chrome/browser/net to decide what to delete at shutdown.

#ifndef CHROME_BROWSER_NET_CLEAR_ON_EXIT_POLICY_H_
#define CHROME_BROWSER_NET_CLEAR_ON_EXIT_POLICY_H_

#include <string>

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"

namespace quota {
class SpecialStoragePolicy;
}

class ClearOnExitPolicy : public base::RefCountedThreadSafe<ClearOnExitPolicy> {
 public:
  // |special_storage_policy| can be NULL, if no policy is to be applied.
  // Otherwise, will keep a scoped_refptr to |special_storage_policy|
  // throughout its lifetime.
  explicit ClearOnExitPolicy(
      quota::SpecialStoragePolicy* special_storage_policy);

  // True if there are origins that should be cleared on exit.
  bool HasClearOnExitOrigins();

  // True if the given origin (defined by the |domain| and whether or not the
  // |scheme_is_secure|) should be cleared on exit.
  bool ShouldClearOriginOnExit(const std::string& domain,
                               bool scheme_is_secure);

 private:
  friend class base::RefCountedThreadSafe<ClearOnExitPolicy>;

  virtual ~ClearOnExitPolicy();

  scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;

  DISALLOW_COPY_AND_ASSIGN(ClearOnExitPolicy);
};

#endif  // CHROME_BROWSER_NET_CLEAR_ON_EXIT_POLICY_H_