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

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

Issue 10175008: Improving the process model extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved to async extension functions and generated docs. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <utility> 10 #include <utility>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 // Invoked when a range of items has changed. 249 // Invoked when a range of items has changed.
250 virtual void OnItemsChanged(int start, int length) = 0; 250 virtual void OnItemsChanged(int start, int length) = 0;
251 251
252 // Invoked when new items are added. 252 // Invoked when new items are added.
253 virtual void OnItemsAdded(int start, int length) = 0; 253 virtual void OnItemsAdded(int start, int length) = 0;
254 254
255 // Invoked when a range of items has been removed. 255 // Invoked when a range of items has been removed.
256 virtual void OnItemsRemoved(int start, int length) = 0; 256 virtual void OnItemsRemoved(int start, int length) = 0;
257 257
258 // Invoked when a range of items is to be immediately removed. It differs
259 // from OnItemsRemoved by the fact that the item is still in the task manager,
260 // so it can be queried for and found.
261 virtual void OnItemsToBeRemoved(int start, int length) {}
262
258 // Invoked when the initialization of the model has been finished and 263 // Invoked when the initialization of the model has been finished and
259 // periodical updates is started. The first periodical update will be done 264 // periodical updates is started. The first periodical update will be done
260 // in a few seconds. (depending on platform) 265 // in a few seconds. (depending on platform)
261 virtual void OnReadyPeriodicalUpdate() {} 266 virtual void OnReadyPeriodicalUpdate() {}
262 }; 267 };
263 268
264 // The model that the TaskManager is using. 269 // The model that the TaskManager is using.
265 class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> { 270 class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> {
266 public: 271 public:
267 // (start, length) 272 // (start, length)
268 typedef std::pair<int, int> GroupRange; 273 typedef std::pair<int, int> GroupRange;
269 274
270 explicit TaskManagerModel(TaskManager* task_manager); 275 explicit TaskManagerModel(TaskManager* task_manager);
271 276
272 void AddObserver(TaskManagerModelObserver* observer); 277 void AddObserver(TaskManagerModelObserver* observer);
273 void RemoveObserver(TaskManagerModelObserver* observer); 278 void RemoveObserver(TaskManagerModelObserver* observer);
274 279
275 // Returns number of registered resources. 280 // Returns number of registered resources.
276 int ResourceCount() const; 281 int ResourceCount() const;
277 // Returns number of registered groups. 282 // Returns number of registered groups.
278 int GroupCount() const; 283 int GroupCount() const;
279 284
280 // Methods to return raw resource information. 285 // Methods to return raw resource information.
281 int64 GetNetworkUsage(int index) const; 286 int64 GetNetworkUsage(int index) const;
282 double GetCPUUsage(int index) const; 287 double GetCPUUsage(int index) const;
283 int GetProcessId(int index) const; 288 int GetProcessId(int index) const;
289 base::ProcessHandle GetProcess(int index) const;
284 int GetResourceUniqueId(int index) const; 290 int GetResourceUniqueId(int index) const;
285 // Returns the index of resource that has the given |unique_id|. Returns -1 if 291 // Returns the index of resource that has the given |unique_id|. Returns -1 if
286 // no resouce has the |unique_id|. 292 // no resouce has the |unique_id|.
287 int GetResourceIndexByUniqueId(const int unique_id) const; 293 int GetResourceIndexByUniqueId(const int unique_id) const;
288 294
289 // Methods to return formatted resource information. 295 // Methods to return formatted resource information.
290 string16 GetResourceTitle(int index) const; 296 string16 GetResourceTitle(int index) const;
291 string16 GetResourceProfileName(int index) const; 297 string16 GetResourceProfileName(int index) const;
292 string16 GetResourceNetworkUsage(int index) const; 298 string16 GetResourceNetworkUsage(int index) const;
293 string16 GetResourceCPUUsage(int index) const; 299 string16 GetResourceCPUUsage(int index) const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 bool GetFPS(int index, float* result) const; 333 bool GetFPS(int index, float* result) const;
328 334
329 // Gets the sqlite memory (in byte). Return false if the resource for the 335 // Gets the sqlite memory (in byte). Return false if the resource for the
330 // given row doesn't report information. 336 // given row doesn't report information.
331 bool GetSqliteMemoryUsedBytes(int index, size_t* result) const; 337 bool GetSqliteMemoryUsedBytes(int index, size_t* result) const;
332 338
333 // Gets the amount of memory allocated for javascript. Returns false if the 339 // Gets the amount of memory allocated for javascript. Returns false if the
334 // resource for the given row isn't a renderer. 340 // resource for the given row isn't a renderer.
335 bool GetV8Memory(int index, size_t* result) const; 341 bool GetV8Memory(int index, size_t* result) const;
336 342
343 // Gets the amount of memory used for javascript. Returns false if the
344 // resource for the given row isn't a renderer.
345 bool GetV8MemoryUsed(int index, size_t* result) const;
346
337 // Returns true if resource for the given row can be activated. 347 // Returns true if resource for the given row can be activated.
338 bool CanActivate(int index) const; 348 bool CanActivate(int index) const;
339 349
340 // Returns true if resource for the given row can be inspected using developer 350 // Returns true if resource for the given row can be inspected using developer
341 // tools. 351 // tools.
342 bool CanInspect(int index) const; 352 bool CanInspect(int index) const;
343 353
344 // Invokes or reveals developer tools window for resource in the given row. 354 // Invokes or reveals developer tools window for resource in the given row.
345 void Inspect(int index) const; 355 void Inspect(int index) const;
346 356
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 400
391 // Returns Extension of given resource or NULL if not applicable. 401 // Returns Extension of given resource or NULL if not applicable.
392 const Extension* GetResourceExtension(int index) const; 402 const Extension* GetResourceExtension(int index) const;
393 403
394 void AddResource(TaskManager::Resource* resource); 404 void AddResource(TaskManager::Resource* resource);
395 void RemoveResource(TaskManager::Resource* resource); 405 void RemoveResource(TaskManager::Resource* resource);
396 406
397 void StartUpdating(); 407 void StartUpdating();
398 void StopUpdating(); 408 void StopUpdating();
399 409
410 void StartListening();
Charlie Reis 2012/04/27 22:01:56 These should have comments to explain what they're
nasko 2012/04/30 18:05:19 Done.
411 void StopListening();
412
400 void Clear(); // Removes all items. 413 void Clear(); // Removes all items.
401 414
402 // Sends OnModelChanged() to all observers to inform them of significant 415 // Sends OnModelChanged() to all observers to inform them of significant
403 // changes to the model. 416 // changes to the model.
404 void ModelChanged(); 417 void ModelChanged();
405 418
406 void NotifyResourceTypeStats( 419 void NotifyResourceTypeStats(
407 base::ProcessId renderer_id, 420 base::ProcessId renderer_id,
408 const WebKit::WebCache::ResourceTypeStats& stats); 421 const WebKit::WebCache::ResourceTypeStats& stats);
409 422
(...skipping 13 matching lines...) Expand all
423 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); 436 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager);
424 437
425 ~TaskManagerModel(); 438 ~TaskManagerModel();
426 439
427 enum UpdateState { 440 enum UpdateState {
428 IDLE = 0, // Currently not updating. 441 IDLE = 0, // Currently not updating.
429 TASK_PENDING, // An update task is pending. 442 TASK_PENDING, // An update task is pending.
430 STOPPING // A update task is pending and it should stop the update. 443 STOPPING // A update task is pending and it should stop the update.
431 }; 444 };
432 445
446 enum ListenState {
Charlie Reis 2012/04/27 22:01:56 Why not a is_listeneing_ boolean? With UpdateStat
nasko 2012/04/30 18:05:19 I initially started with different states. You are
447 LISTEN_OFF = 0,
448 LISTEN_ON
449 };
450
433 // This struct is used to exchange information between the io and ui threads. 451 // This struct is used to exchange information between the io and ui threads.
434 struct BytesReadParam { 452 struct BytesReadParam {
435 BytesReadParam(int origin_pid, 453 BytesReadParam(int origin_pid,
436 int render_process_host_child_id, 454 int render_process_host_child_id,
437 int routing_id, 455 int routing_id,
438 int byte_count) 456 int byte_count)
439 : origin_pid(origin_pid), 457 : origin_pid(origin_pid),
440 render_process_host_child_id(render_process_host_child_id), 458 render_process_host_child_id(render_process_host_child_id),
441 routing_id(routing_id), 459 routing_id(routing_id),
442 byte_count(byte_count) {} 460 byte_count(byte_count) {}
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // because the linux call takes >10ms to complete. This cache is cleared on 553 // because the linux call takes >10ms to complete. This cache is cleared on
536 // every Refresh(). 554 // every Refresh().
537 mutable MemoryUsageMap memory_usage_map_; 555 mutable MemoryUsageMap memory_usage_map_;
538 556
539 ObserverList<TaskManagerModelObserver> observer_list_; 557 ObserverList<TaskManagerModelObserver> observer_list_;
540 558
541 // How many calls to StartUpdating have been made without matching calls to 559 // How many calls to StartUpdating have been made without matching calls to
542 // StopUpdating. 560 // StopUpdating.
543 int update_requests_; 561 int update_requests_;
544 562
563 // How many calls to StartListening have been made without matching calls to
564 // StopListening.
565 int listen_requests_;
566
545 // Whether we are currently in the process of updating. 567 // Whether we are currently in the process of updating.
546 UpdateState update_state_; 568 UpdateState update_state_;
547 569
570 // Whether we have resource managers listening for events and maintaining
571 // the TaskManagerModel resources.
572 ListenState listen_state_;
573
548 // A salt lick for the goats. 574 // A salt lick for the goats.
549 uint64 goat_salt_; 575 uint64 goat_salt_;
550 576
551 // Resource identifier that is unique within single session. 577 // Resource identifier that is unique within single session.
552 int last_unique_id_; 578 int last_unique_id_;
553 579
554 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); 580 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel);
555 }; 581 };
556 582
557 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ 583 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698