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

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

Issue 7043007: Kill URLRequestJobTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge. Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/task_manager/task_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/process_util.h" 19 #include "base/process_util.h"
20 #include "base/string16.h" 20 #include "base/string16.h"
21 #include "base/timer.h" 21 #include "base/timer.h"
22 #include "chrome/browser/renderer_host/web_cache_manager.h" 22 #include "chrome/browser/renderer_host/web_cache_manager.h"
23 #include "net/url_request/url_request_job_tracker.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
25 24
26 class Extension; 25 class Extension;
27 class SkBitmap; 26 class SkBitmap;
28 class TabContentsWrapper; 27 class TabContentsWrapper;
29 class TaskManagerModel; 28 class TaskManagerModel;
30 29
31 namespace base { 30 namespace base {
32 class ProcessMetrics; 31 class ProcessMetrics;
33 } 32 }
33 namespace net {
34 class URLRequest;
35 }
34 36
35 // This class is a singleton. 37 // This class is a singleton.
36 class TaskManager { 38 class TaskManager {
37 public: 39 public:
38 // A resource represents one row in the task manager. 40 // A resource represents one row in the task manager.
39 // Resources from similar processes are grouped together by the task manager. 41 // Resources from similar processes are grouped together by the task manager.
40 class Resource { 42 class Resource {
41 public: 43 public:
42 virtual ~Resource() {} 44 virtual ~Resource() {}
43 45
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 virtual void OnItemsChanged(int start, int length) = 0; 209 virtual void OnItemsChanged(int start, int length) = 0;
208 210
209 // Invoked when new items are added. 211 // Invoked when new items are added.
210 virtual void OnItemsAdded(int start, int length) = 0; 212 virtual void OnItemsAdded(int start, int length) = 0;
211 213
212 // Invoked when a range of items has been removed. 214 // Invoked when a range of items has been removed.
213 virtual void OnItemsRemoved(int start, int length) = 0; 215 virtual void OnItemsRemoved(int start, int length) = 0;
214 }; 216 };
215 217
216 // The model that the TaskManager is using. 218 // The model that the TaskManager is using.
217 class TaskManagerModel : public net::URLRequestJobTracker::JobObserver, 219 class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> {
218 public base::RefCountedThreadSafe<TaskManagerModel> {
219 public: 220 public:
220 explicit TaskManagerModel(TaskManager* task_manager); 221 explicit TaskManagerModel(TaskManager* task_manager);
221 222
222 void AddObserver(TaskManagerModelObserver* observer); 223 void AddObserver(TaskManagerModelObserver* observer);
223 void RemoveObserver(TaskManagerModelObserver* observer); 224 void RemoveObserver(TaskManagerModelObserver* observer);
224 225
225 // Returns number of registered resources. 226 // Returns number of registered resources.
226 int ResourceCount() const; 227 int ResourceCount() const;
227 228
228 // Methods to return raw resource information. 229 // Methods to return raw resource information.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 // Returns the type of the given resource. 292 // Returns the type of the given resource.
292 TaskManager::Resource::Type GetResourceType(int index) const; 293 TaskManager::Resource::Type GetResourceType(int index) const;
293 294
294 // Returns TabContents of given resource or NULL if not applicable. 295 // Returns TabContents of given resource or NULL if not applicable.
295 TabContentsWrapper* GetResourceTabContents(int index) const; 296 TabContentsWrapper* GetResourceTabContents(int index) const;
296 297
297 // Returns Extension of given resource or NULL if not applicable. 298 // Returns Extension of given resource or NULL if not applicable.
298 const Extension* GetResourceExtension(int index) const; 299 const Extension* GetResourceExtension(int index) const;
299 300
300 // JobObserver methods:
301 virtual void OnJobAdded(net::URLRequestJob* job);
302 virtual void OnJobRemoved(net::URLRequestJob* job);
303 virtual void OnJobDone(net::URLRequestJob* job,
304 const net::URLRequestStatus& status);
305 virtual void OnJobRedirect(net::URLRequestJob* job,
306 const GURL& location,
307 int status_code);
308 virtual void OnBytesRead(net::URLRequestJob* job,
309 const char* buf,
310 int byte_count);
311
312 void AddResource(TaskManager::Resource* resource); 301 void AddResource(TaskManager::Resource* resource);
313 void RemoveResource(TaskManager::Resource* resource); 302 void RemoveResource(TaskManager::Resource* resource);
314 303
315 void StartUpdating(); 304 void StartUpdating();
316 void StopUpdating(); 305 void StopUpdating();
317 306
318 void Clear(); // Removes all items. 307 void Clear(); // Removes all items.
319 308
320 // Sends OnModelChanged() to all observers to inform them of significant 309 // Sends OnModelChanged() to all observers to inform them of significant
321 // changes to the model. 310 // changes to the model.
322 void ModelChanged(); 311 void ModelChanged();
323 312
324 void NotifyResourceTypeStats( 313 void NotifyResourceTypeStats(
325 base::ProcessId renderer_id, 314 base::ProcessId renderer_id,
326 const WebKit::WebCache::ResourceTypeStats& stats); 315 const WebKit::WebCache::ResourceTypeStats& stats);
327 316
328 void NotifyV8HeapStats(base::ProcessId renderer_id, 317 void NotifyV8HeapStats(base::ProcessId renderer_id,
329 size_t v8_memory_allocated, 318 size_t v8_memory_allocated,
330 size_t v8_memory_used); 319 size_t v8_memory_used);
331 320
321 void NotifyBytesRead(const net::URLRequest& request, int bytes_read);
322
332 private: 323 private:
333 friend class base::RefCountedThreadSafe<TaskManagerModel>; 324 friend class base::RefCountedThreadSafe<TaskManagerModel>;
334 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); 325 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled);
335 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); 326 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager);
336 327
337 ~TaskManagerModel(); 328 ~TaskManagerModel();
338 329
339 enum UpdateState { 330 enum UpdateState {
340 IDLE = 0, // Currently not updating. 331 IDLE = 0, // Currently not updating.
341 TASK_PENDING, // An update task is pending. 332 TASK_PENDING, // An update task is pending.
(...skipping 30 matching lines...) Expand all
372 typedef std::map<TaskManager::Resource*, int64> ResourceValueMap; 363 typedef std::map<TaskManager::Resource*, int64> ResourceValueMap;
373 typedef std::map<base::ProcessHandle, 364 typedef std::map<base::ProcessHandle,
374 std::pair<size_t, size_t> > MemoryUsageMap; 365 std::pair<size_t, size_t> > MemoryUsageMap;
375 366
376 // Updates the values for all rows. 367 // Updates the values for all rows.
377 void Refresh(); 368 void Refresh();
378 369
379 void AddItem(TaskManager::Resource* resource, bool notify_table); 370 void AddItem(TaskManager::Resource* resource, bool notify_table);
380 void RemoveItem(TaskManager::Resource* resource); 371 void RemoveItem(TaskManager::Resource* resource);
381 372
382 // Register for network usage updates
383 void RegisterForJobDoneNotifications();
384 void UnregisterForJobDoneNotifications();
385
386 // Returns the network usage (in bytes per seconds) for the specified 373 // Returns the network usage (in bytes per seconds) for the specified
387 // resource. That's the value retrieved at the last timer's tick. 374 // resource. That's the value retrieved at the last timer's tick.
388 int64 GetNetworkUsageForResource(TaskManager::Resource* resource) const; 375 int64 GetNetworkUsageForResource(TaskManager::Resource* resource) const;
389 376
390 // Called on the UI thread when some bytes are read. 377 // Called on the UI thread when some bytes are read.
391 void BytesRead(BytesReadParam param); 378 void BytesRead(BytesReadParam param);
392 379
393 // Returns the network usage (in byte per second) that should be displayed for 380 // Returns the network usage (in byte per second) that should be displayed for
394 // the passed |resource|. -1 means the information is not available for that 381 // the passed |resource|. -1 means the information is not available for that
395 // resource. 382 // resource.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // Whether we are currently in the process of updating. 446 // Whether we are currently in the process of updating.
460 UpdateState update_state_; 447 UpdateState update_state_;
461 448
462 // A salt lick for the goats. 449 // A salt lick for the goats.
463 int goat_salt_; 450 int goat_salt_;
464 451
465 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); 452 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel);
466 }; 453 };
467 454
468 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ 455 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/task_manager/task_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698