OLD | NEW |
---|---|
(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 virtual Task* GetTaskOfUrlRequest(int origin_pid, | |
Lei Zhang
2015/04/01 22:47:51
I looked in net/url_request/url_request.h and I st
afakhry
2015/04/03 01:51:01
I agree it's confusing. You need to look at conten
Lei Zhang
2015/04/03 02:39:37
Would it make sense to just say "the task associat
afakhry
2015/04/03 16:04:27
It's important to mention here that the only user
| |
25 int child_id, | |
26 int route_id) = 0; | |
27 | |
28 void SetObserver(TaskProviderObserver* observer); | |
Lei Zhang
2015/04/01 22:47:51
Given the impl, shouldn't this state:
- it's inva
afakhry
2015/04/03 01:51:01
Done.
| |
29 void ClearObserver(); | |
30 | |
31 protected: | |
32 // Used by concrete task providers to notify the observer of tasks addition/ | |
33 // removal. These methods should only be called after StartUpdating() has been | |
34 // called and before StopUpdating() is called. | |
35 void NotifyObserverTaskAdded(Task* task) const; | |
36 void NotifyObserverTaskRemoved(Task* task) const; | |
37 | |
38 private: | |
39 // This will be called once an observer is set for this provider. When it is | |
40 // called, the concrete provider must notify the observer of all pre-existing | |
41 // tasks as well as track new addition and terminations and notify the | |
42 // observer of these changes. | |
43 virtual void StartUpdating() = 0; | |
44 | |
45 // This will be called once the observer is cleared, at which point the | |
46 // provider can stop tracking tasks addition / removal and can clear its own | |
47 // resources. | |
48 virtual void StopUpdating() = 0; | |
49 | |
50 // We support only one single obsever which will be the sampler in this case. | |
51 TaskProviderObserver* observer_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(TaskProvider); | |
54 }; | |
55 | |
56 } // namespace task_management | |
57 | |
58 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_ | |
OLD | NEW |