Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: chrome/browser/task_manager/web_contents_information.h

Issue 2197483003: Move the Mac Task Manager to the new backend code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
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_TASK_MANAGER_WEB_CONTENTS_INFORMATION_H_
6 #define CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_INFORMATION_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14
15 namespace content {
16 class WebContents;
17 }
18
19 namespace task_manager {
20
21 class RendererResource;
22
23 // This interface gives a WebContentsResourceProvider information about a
24 // category of WebContentses owned by some service. The instances are expected
25 // to be owned by their WebContentsResourceProvider, which will track and adapt
26 // the WebContentses into TaskManager resources.
27 class WebContentsInformation {
28 public:
29 typedef base::Callback<void(content::WebContents*)> NewWebContentsCallback;
30
31 WebContentsInformation();
32 virtual ~WebContentsInformation();
33
34 // Retrieve all known WebContents instances from the service we're tracking.
35 // Invoke |callback| on each one.
36 virtual void GetAll(const NewWebContentsCallback& callback) = 0;
37
38 // Return true if |web_contents| is from the service we're tracking.
39 virtual bool CheckOwnership(content::WebContents* web_contents) = 0;
40
41 // Start listening to the creation of new WebContents instances from
42 // the service. While listening, invoke |callback| on each new instance.
43 virtual void StartObservingCreation(
44 const NewWebContentsCallback& callback) = 0;
45
46 // Stop listening to creation of new WebContents instances.
47 virtual void StopObservingCreation() = 0;
48
49 // Create a new task manager resource for the given WebContents instance.
50 virtual std::unique_ptr<RendererResource> MakeResource(
51 content::WebContents* web_contents) = 0;
52
53 private:
54 DISALLOW_COPY_AND_ASSIGN(WebContentsInformation);
55 };
56
57 // Implements the observer methods (StartObservingCreation() /
58 // StopObservingCreation()) of WebContentsInformation using
59 // NOTIFICATION_WEB_CONTENTS_CONNECTED.
60 class NotificationObservingWebContentsInformation
61 : public WebContentsInformation,
62 public content::NotificationObserver {
63 public:
64 NotificationObservingWebContentsInformation();
65 ~NotificationObservingWebContentsInformation() override;
66
67 // WebContentsInformation partial implementation.
68 void StartObservingCreation(const NewWebContentsCallback& callback) override;
69 void StopObservingCreation() override;
70
71 // content::NotificationObserver implementation.
72 void Observe(int type,
73 const content::NotificationSource& source,
74 const content::NotificationDetails& details) override;
75
76 private:
77 content::NotificationRegistrar registrar_;
78 NewWebContentsCallback observer_callback_;
79 DISALLOW_COPY_AND_ASSIGN(NotificationObservingWebContentsInformation);
80 };
81
82 } // namespace task_manager
83
84 #endif // CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_INFORMATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_util_unittest.cc ('k') | chrome/browser/task_manager/web_contents_information.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698