Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / task_management / providers / task_provider.h
blob91f71c18d89139e3b98d19d82b2c3da4dae70b86
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.
5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
8 #include "chrome/browser/task_management/providers/task_provider_observer.h"
10 namespace task_management {
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();
22 // Should return the task associated to the specified IDs from a
23 // |content::ResourceRequestInfo| that represents a |URLRequest|. A value of
24 // nullptr will be returned if the desired task does not belong to this
25 // provider.
27 // |origin_pid| is the PID of the originating process of the URLRequest, if
28 // the request is sent on behalf of another process. Otherwise it's 0.
29 // |child_id| is the unique ID of the host of the child process requestor.
30 // |route_id| is the ID of the IPC route for the URLRequest (this identifies
31 // the RenderView or like-thing in the renderer that the request gets routed
32 // to).
33 virtual Task* GetTaskOfUrlRequest(int origin_pid,
34 int child_id,
35 int route_id) = 0;
37 // Set the sole observer of this provider. It's an error to set an observer
38 // if there's already one there.
39 void SetObserver(TaskProviderObserver* observer);
41 // Clears the currently set observer for this provider. It's an error to clear
42 // the observer if there's no one set.
43 void ClearObserver();
45 protected:
46 // Used by concrete task providers to notify the observer of tasks addition/
47 // removal. These methods should only be called after StartUpdating() has been
48 // called and before StopUpdating() is called.
49 void NotifyObserverTaskAdded(Task* task) const;
50 void NotifyObserverTaskRemoved(Task* task) const;
52 private:
53 // This will be called once an observer is set for this provider. When it is
54 // called, the concrete provider must notify the observer of all pre-existing
55 // tasks as well as track new addition and terminations and notify the
56 // observer of these changes.
57 virtual void StartUpdating() = 0;
59 // This will be called once the observer is cleared, at which point the
60 // provider can stop tracking tasks addition / removal and can clear its own
61 // resources.
62 virtual void StopUpdating() = 0;
64 // We support only one single obsever which will be the sampler in this case.
65 TaskProviderObserver* observer_;
67 DISALLOW_COPY_AND_ASSIGN(TaskProvider);
70 } // namespace task_management
72 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_