summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data/cache_counter.h
blob: 9ac3ad777e8be3124ddfa6f47e5f2b13f0ca16de (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
// Copyright (c) 2015 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_BROWSING_DATA_CACHE_COUNTER_H_
#define CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_

#include <stdint.h>

#include "base/memory/weak_ptr.h"
#include "chrome/browser/browsing_data/browsing_data_counter.h"

class CacheCounter: public BrowsingDataCounter {
 public:
  CacheCounter();
  ~CacheCounter() override;

  const std::string& GetPrefName() const override;

  // Whether this counter awaits the calculation result callback.
  // Used only for testing.
  bool Pending();

 private:
  const std::string pref_name_;
  bool pending_;

  base::WeakPtrFactory<CacheCounter> weak_ptr_factory_;

  void Count() override;
  void OnCacheSizeCalculated(int64_t bytes);
};

#endif  // CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_