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

Side by Side Diff: chrome/browser/task_management/providers/task_provider.h

Issue 1038033002: New Task Manager - Phase 1.1: Implement Browser Process Task Providing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Lei Zhang's comments Created 5 years, 8 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 2015 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_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
7
8 #include "chrome/browser/task_management/providers/task_provider_observer.h"
9
10 namespace task_management {
11
12 // Defines the interface for task providers. A concrete task provider must be
13 // able to collect all the tasks of a particular type which this provider
14 // supports as well as track any tasks addition / removal. Once StartUpdating()
15 // is called, the provider is responsible for notifying the observer about the
16 // tasks it's tracking. The TaskProviders own the tasks they provide.
17 class TaskProvider {
18 public:
19 TaskProvider();
20 virtual ~TaskProvider();
21
22 // Should return the task associated to the specified ids of a URLRequest,
23 // or nullptr if the desired task does not belong to this provider.
24 // See |content::ResourceRequestInfo|.
25 //
26 // |origin_pid| is the PID of the originating process of the URLRequest, if
27 // the request is sent on behalf of another process. Otherwise it's 0.
28 // |child_id| is the unique ID of host of the child process requestor.
29 // |route_id| is the ID of the IPC route for the URLRequest (this identifies
30 // the RenderView or like-thing in the renderer that the request gets routed
31 // to).
32 virtual Task* GetTaskOfUrlRequest(int origin_pid,
33 int child_id,
34 int route_id) = 0;
35
36 // Set the sole observer of this provider. It's an error to set an observer
37 // if there's already one there.
38 void SetObserver(TaskProviderObserver* observer);
39
40 // Clears the currently set observer for this provider. It's an error to clear
41 // the observer if there's no one set.
42 void ClearObserver();
43
44 protected:
45 // Used by concrete task providers to notify the observer of tasks addition/
46 // removal. These methods should only be called after StartUpdating() has been
47 // called and before StopUpdating() is called.
48 void NotifyObserverTaskAdded(Task* task) const;
49 void NotifyObserverTaskRemoved(Task* task) const;
50
51 private:
52 // This will be called once an observer is set for this provider. When it is
53 // called, the concrete provider must notify the observer of all pre-existing
54 // tasks as well as track new addition and terminations and notify the
55 // observer of these changes.
56 virtual void StartUpdating() = 0;
57
58 // This will be called once the observer is cleared, at which point the
59 // provider can stop tracking tasks addition / removal and can clear its own
60 // resources.
61 virtual void StopUpdating() = 0;
62
63 // We support only one single obsever which will be the sampler in this case.
64 TaskProviderObserver* observer_;
65
66 DISALLOW_COPY_AND_ASSIGN(TaskProvider);
67 };
68
69 } // namespace task_management
70
71 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698