[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / net_benchmarking.h
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_BENCHMARKING_H_
6 #define CHROME_BROWSER_NET_BENCHMARKING_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/common/net_benchmarking.mojom.h"
10 #include "mojo/public/cpp/bindings/pending_receiver.h"
11
12 namespace predictors {
13 class LoadingPredictor;
14 }
15
16 // This class handles Chrome-specific benchmarking IPC messages for the renderer
17 // process.
18 // All methods of this class should be called on the IO thread unless the
19 // contrary is explicitly specified.
20 class NetBenchmarking : public chrome::mojom::NetBenchmarking {
21  public:
22   NetBenchmarking(base::WeakPtr<predictors::LoadingPredictor> loading_predictor,
23                   int render_process_id);
24
25   NetBenchmarking(const NetBenchmarking&) = delete;
26   NetBenchmarking& operator=(const NetBenchmarking&) = delete;
27
28   ~NetBenchmarking() override;
29
30   // Creates a NetBenchmarking instance and connects it strongly to a mojo pipe.
31   // Callers should prefer this over using the constructor directly.
32   static void Create(
33       base::WeakPtr<predictors::LoadingPredictor> loading_predictor,
34       int render_process_id,
35       mojo::PendingReceiver<chrome::mojom::NetBenchmarking> receiver);
36
37   // This method is thread-safe.
38   static bool CheckBenchmarkingEnabled();
39
40  private:
41   // chrome:mojom:NetBenchmarking.
42   void CloseCurrentConnections(
43       CloseCurrentConnectionsCallback callback) override;
44   void ClearCache(ClearCacheCallback callback) override;
45   void ClearHostResolverCache(ClearHostResolverCacheCallback callback) override;
46   void ClearPredictorCache(ClearPredictorCacheCallback callback) override;
47
48   // These weak pointers should be dereferenced only on the UI thread.
49   base::WeakPtr<predictors::LoadingPredictor> loading_predictor_;
50   const int render_process_id_;
51 };
52
53 #endif  // CHROME_BROWSER_NET_BENCHMARKING_H_