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

Unified 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: Converting size_t's to int64's 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/task_management/providers/task_provider.h
diff --git a/chrome/browser/task_management/providers/task_provider.h b/chrome/browser/task_management/providers/task_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..91f71c18d89139e3b98d19d82b2c3da4dae70b86
--- /dev/null
+++ b/chrome/browser/task_management/providers/task_provider.h
@@ -0,0 +1,72 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
+#define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
+
+#include "chrome/browser/task_management/providers/task_provider_observer.h"
+
+namespace task_management {
+
+// Defines the interface for task providers. A concrete task provider must be
+// able to collect all the tasks of a particular type which this provider
+// supports as well as track any tasks addition / removal. Once StartUpdating()
+// is called, the provider is responsible for notifying the observer about the
+// tasks it's tracking. The TaskProviders own the tasks they provide.
+class TaskProvider {
+ public:
+ TaskProvider();
+ virtual ~TaskProvider();
+
+ // Should return the task associated to the specified IDs from a
+ // |content::ResourceRequestInfo| that represents a |URLRequest|. A value of
+ // nullptr will be returned if the desired task does not belong to this
+ // provider.
+ //
+ // |origin_pid| is the PID of the originating process of the URLRequest, if
+ // the request is sent on behalf of another process. Otherwise it's 0.
+ // |child_id| is the unique ID of the host of the child process requestor.
+ // |route_id| is the ID of the IPC route for the URLRequest (this identifies
+ // the RenderView or like-thing in the renderer that the request gets routed
+ // to).
+ virtual Task* GetTaskOfUrlRequest(int origin_pid,
+ int child_id,
+ int route_id) = 0;
+
+ // Set the sole observer of this provider. It's an error to set an observer
+ // if there's already one there.
+ void SetObserver(TaskProviderObserver* observer);
+
+ // Clears the currently set observer for this provider. It's an error to clear
+ // the observer if there's no one set.
+ void ClearObserver();
+
+ protected:
+ // Used by concrete task providers to notify the observer of tasks addition/
+ // removal. These methods should only be called after StartUpdating() has been
+ // called and before StopUpdating() is called.
+ void NotifyObserverTaskAdded(Task* task) const;
+ void NotifyObserverTaskRemoved(Task* task) const;
+
+ private:
+ // This will be called once an observer is set for this provider. When it is
+ // called, the concrete provider must notify the observer of all pre-existing
+ // tasks as well as track new addition and terminations and notify the
+ // observer of these changes.
+ virtual void StartUpdating() = 0;
+
+ // This will be called once the observer is cleared, at which point the
+ // provider can stop tracking tasks addition / removal and can clear its own
+ // resources.
+ virtual void StopUpdating() = 0;
+
+ // We support only one single obsever which will be the sampler in this case.
+ TaskProviderObserver* observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(TaskProvider);
+};
+
+} // namespace task_management
+
+#endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_PROVIDER_H_
« no previous file with comments | « chrome/browser/task_management/providers/task.cc ('k') | chrome/browser/task_management/providers/task_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698