summaryrefslogtreecommitdiffstats
path: root/chrome/browser/data_usage/tab_id_annotator.h
blob: f4fcccf8255cc6c1585e965b697cdf9d612b0e39 (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
// Copyright 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_DATA_USAGE_TAB_ID_ANNOTATOR_H_
#define CHROME_BROWSER_DATA_USAGE_TAB_ID_ANNOTATOR_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "components/data_usage/core/data_use_annotator.h"

namespace data_usage {
struct DataUse;
}

namespace net {
class URLRequest;
}

namespace chrome_browser_data_usage {

// Class that annotates DataUse objects with their associated tab IDs.
class TabIdAnnotator : public data_usage::DataUseAnnotator {
 public:
  TabIdAnnotator();
  ~TabIdAnnotator() override;

  // Determines the tab ID associated with |request| if there is one, setting
  // the tab ID on |data_use| appropriately and passing it to |callback| once
  // the tab ID is ready. A tab ID of -1 is used if no tab ID is found for
  // |request|. This method will attach a new TabIdProvider to |request| as user
  // data if there isn't one attached already and |request| has enough
  // information to get a tab ID.
  void Annotate(net::URLRequest* request,
                scoped_ptr<data_usage::DataUse> data_use,
                const DataUseConsumerCallback& callback) override;

 private:
  base::ThreadChecker thread_checker_;

  DISALLOW_COPY_AND_ASSIGN(TabIdAnnotator);
};

}  // namespace chrome_browser_data_usage

#endif  // CHROME_BROWSER_DATA_USAGE_TAB_ID_ANNOTATOR_H_