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

Side by Side Diff: chrome/browser/cocoa/task_manager_mac.h

Issue 2873075: Mac: Add sort support for task manager. (Closed)
Patch Set: comments Created 10 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/cocoa/task_manager_mac.mm » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_COCOA_TASK_MANAGER_MAC_H_ 5 #ifndef CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_
6 #define CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_ 6 #define CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_
7 #pragma once 7 #pragma once
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 #include <vector>
11
10 #include "base/scoped_nsobject.h" 12 #include "base/scoped_nsobject.h"
11 #include "chrome/browser/cocoa/table_row_nsimage_cache.h" 13 #include "chrome/browser/cocoa/table_row_nsimage_cache.h"
12 #include "chrome/browser/task_manager.h" 14 #include "chrome/browser/task_manager.h"
13 15
14 @class WindowSizeAutosaver; 16 @class WindowSizeAutosaver;
15 class TaskManagerMac; 17 class TaskManagerMac;
16 18
17 // This class is responsible for loading the task manager window and for 19 // This class is responsible for loading the task manager window and for
18 // managing it. 20 // managing it.
19 @interface TaskManagerWindowController : NSWindowController { 21 @interface TaskManagerWindowController : NSWindowController {
20 @private 22 @private
21 IBOutlet NSTableView* tableView_; 23 IBOutlet NSTableView* tableView_;
22 IBOutlet NSButton* endProcessButton_; 24 IBOutlet NSButton* endProcessButton_;
23 TaskManagerMac* taskManagerObserver_; // weak 25 TaskManagerMac* taskManagerObserver_; // weak
24 TaskManager* taskManager_; // weak 26 TaskManager* taskManager_; // weak
25 TaskManagerModel* model_; // weak 27 TaskManagerModel* model_; // weak
26 28
27 scoped_nsobject<WindowSizeAutosaver> size_saver_; 29 scoped_nsobject<WindowSizeAutosaver> size_saver_;
30
31 // Contains a permutation of [0..|model_->ResourceCount() - 1|]. Used to
32 // implement sorting.
33 std::vector<int> indexShuffle_;
34
35 // Descriptor of the current sort column.
36 scoped_nsobject<NSSortDescriptor> currentSortDescriptor_;
28 } 37 }
29 38
30 // Creates and shows the task manager's window. 39 // Creates and shows the task manager's window.
31 - (id)initWithTaskManagerObserver:(TaskManagerMac*)taskManagerObserver; 40 - (id)initWithTaskManagerObserver:(TaskManagerMac*)taskManagerObserver;
32 41
33 // Refreshes all data in the task manager table. 42 // Refreshes all data in the task manager table.
34 - (void)reloadData; 43 - (void)reloadData;
35 44
36 // Callback for "Stats for nerds" link. 45 // Callback for "Stats for nerds" link.
37 - (IBAction)statsLinkClicked:(id)sender; 46 - (IBAction)statsLinkClicked:(id)sender;
38 47
39 // Callback for "End process" button. 48 // Callback for "End process" button.
40 - (IBAction)killSelectedProcesses:(id)sender; 49 - (IBAction)killSelectedProcesses:(id)sender;
41 50
42 // Callback for double clicks on the table. 51 // Callback for double clicks on the table.
43 - (void)selectDoubleClickedTab:(id)sender; 52 - (void)selectDoubleClickedTab:(id)sender;
44 @end 53 @end
45 54
55 @interface TaskManagerWindowController (TestingAPI)
56 - (NSTableView*)tableView;
57 @end
58
46 // This class listens to task changed events sent by chrome. 59 // This class listens to task changed events sent by chrome.
47 class TaskManagerMac : public TaskManagerModelObserver, 60 class TaskManagerMac : public TaskManagerModelObserver,
48 public TableRowNSImageCache::Table { 61 public TableRowNSImageCache::Table {
49 public: 62 public:
50 TaskManagerMac(); 63 TaskManagerMac(TaskManager* task_manager);
51 virtual ~TaskManagerMac(); 64 virtual ~TaskManagerMac();
52 65
53 // TaskManagerModelObserver 66 // TaskManagerModelObserver
54 virtual void OnModelChanged(); 67 virtual void OnModelChanged();
55 virtual void OnItemsChanged(int start, int length); 68 virtual void OnItemsChanged(int start, int length);
56 virtual void OnItemsAdded(int start, int length); 69 virtual void OnItemsAdded(int start, int length);
57 virtual void OnItemsRemoved(int start, int length); 70 virtual void OnItemsRemoved(int start, int length);
58 71
59 // Called by the cocoa window controller when its window closes and the 72 // Called by the cocoa window controller when its window closes and the
60 // controller destroyed itself. Informs the model to stop updating. 73 // controller destroyed itself. Informs the model to stop updating.
61 void WindowWasClosed(); 74 void WindowWasClosed();
62 75
63 // TableRowNSImageCache::Table 76 // TableRowNSImageCache::Table
64 virtual int RowCount() const { return model_->ResourceCount(); } 77 virtual int RowCount() const { return model_->ResourceCount(); }
65 virtual SkBitmap GetIcon(int r) const { return model_->GetResourceIcon(r); } 78 virtual SkBitmap GetIcon(int r) const { return model_->GetResourceIcon(r); }
66 79
67 // Creates the task manager if it doesn't exist; otherwise, it activates the 80 // Creates the task manager if it doesn't exist; otherwise, it activates the
68 // existing task manager window. 81 // existing task manager window.
69 static void Show(); 82 static void Show();
70 83
71 // Returns the TaskManager observed by |this|. 84 // Returns the TaskManager observed by |this|.
72 TaskManager* task_manager() { return task_manager_; } 85 TaskManager* task_manager() { return task_manager_; }
73 86
74 // Lazily converts the image at the given row and caches it in |icon_cache_|. 87 // Lazily converts the image at the given row and caches it in |icon_cache_|.
75 NSImage* GetImageForRow(int row); 88 NSImage* GetImageForRow(int row);
76 89
90 // Returns the cocoa object. Used for testing.
91 TaskManagerWindowController* cocoa_controller() { return window_controller_; }
77 private: 92 private:
78 // The task manager. 93 // The task manager.
79 TaskManager* const task_manager_; // weak 94 TaskManager* const task_manager_; // weak
80 95
81 // Our model. 96 // Our model.
82 TaskManagerModel* const model_; // weak 97 TaskManagerModel* const model_; // weak
83 98
84 // Controller of our window, destroys itself when the task manager window 99 // Controller of our window, destroys itself when the task manager window
85 // is closed. 100 // is closed.
86 TaskManagerWindowController* window_controller_; // weak 101 TaskManagerWindowController* window_controller_; // weak
87 102
88 // Caches favicons for all rows. Needs to be initalized after |model_|. 103 // Caches favicons for all rows. Needs to be initalized after |model_|.
89 TableRowNSImageCache icon_cache_; 104 TableRowNSImageCache icon_cache_;
90 105
91 // An open task manager window. There can only be one open at a time. This 106 // An open task manager window. There can only be one open at a time. This
92 // is reset to NULL when the window is closed. 107 // is reset to NULL when the window is closed.
93 static TaskManagerMac* instance_; 108 static TaskManagerMac* instance_;
94 109
95 DISALLOW_COPY_AND_ASSIGN(TaskManagerMac); 110 DISALLOW_COPY_AND_ASSIGN(TaskManagerMac);
96 }; 111 };
97 112
98 #endif // CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_ 113 #endif // CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/task_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698