summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-12 18:12:22 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-12 18:12:22 +0000
commita9e60072222bce1db00e65a80297f0ee0210a613 (patch)
treee757d7908a69a3bc115b6be02ce5325859885611 /chrome
parent3fbc8276f724079cb0e0ddd3899c3b49a40e11d9 (diff)
downloadchromium_src-a9e60072222bce1db00e65a80297f0ee0210a613.zip
chromium_src-a9e60072222bce1db00e65a80297f0ee0210a613.tar.gz
chromium_src-a9e60072222bce1db00e65a80297f0ee0210a613.tar.bz2
Mac: Tell task manager model to stop updating when the task manager window is closed.
Also change how the controller is deallocated, which should fix a valgrind bug. Nib change: Make TaskManagerWindowController the delegate of the window in the nib, so that its windowWillClose: gets called. TFR=trungl BUG=13156,30398 TEST=Open Activity Monitor, look at browser %cpu. Open chrome's task manager, note %cpu goes up slightly. Close task manager again, %cpu should go down again. Open task manager again, should still work. Review URL: http://codereview.chromium.org/536026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/TaskManager.xib16
-rw-r--r--chrome/browser/cocoa/task_manager_mac.h21
-rw-r--r--chrome/browser/cocoa/task_manager_mac.mm35
-rw-r--r--chrome/test/data/valgrind/unit_tests.gtest_mac.txt2
4 files changed, 54 insertions, 20 deletions
diff --git a/chrome/app/nibs/TaskManager.xib b/chrome/app/nibs/TaskManager.xib
index a30d2d1..4231806 100644
--- a/chrome/app/nibs/TaskManager.xib
+++ b/chrome/app/nibs/TaskManager.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="3"/>
+ <integer value="1" id="9"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -369,6 +369,14 @@
</object>
<int key="connectionID">33</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="1005"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">34</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -564,7 +572,7 @@
<string>{{274, 515}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{274, 515}, {480, 270}}</string>
- <integer value="1"/>
+ <reference ref="9"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -604,7 +612,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">33</int>
+ <int key="maxID">34</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -720,12 +728,14 @@
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>killSelectedProcesses:</string>
+ <string>selectDoubleClickedTab:</string>
<string>statsLinkClicked:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
diff --git a/chrome/browser/cocoa/task_manager_mac.h b/chrome/browser/cocoa/task_manager_mac.h
index b0e1481..cbcb5d2 100644
--- a/chrome/browser/cocoa/task_manager_mac.h
+++ b/chrome/browser/cocoa/task_manager_mac.h
@@ -9,18 +9,21 @@
#include "base/scoped_nsobject.h"
#include "chrome/browser/task_manager.h"
+class TaskManagerMac;
+
// This class is responsible for loading the task manager window and for
// managing it.
@interface TaskManagerWindowController : NSWindowController {
@private
IBOutlet NSTableView* tableView_;
IBOutlet NSButton* endProcessButton_;
+ TaskManagerMac* taskManagerObserver_; // weak
TaskManager* taskManager_; // weak
TaskManagerModel* model_; // weak
}
// Creates and shows the task manager's window.
-- (id)initWithTaskManager:(TaskManager*)taskManager;
+- (id)initWithTaskManagerObserver:(TaskManagerMac*)taskManagerObserver;
// Refreshes all data in the task manager table.
- (void)reloadData;
@@ -47,19 +50,27 @@ class TaskManagerMac : public TaskManagerModelObserver {
virtual void OnItemsAdded(int start, int length);
virtual void OnItemsRemoved(int start, int length);
+ // Called by the cocoa window controller when its window closes and the
+ // controller destroyed itself. Informs the model to stop updating.
+ void WindowWasClosed();
+
// Creates the task manager if it doesn't exist; otherwise, it activates the
// existing task manager window.
static void Show();
+ // Returns the TaskManager observed by |this|.
+ TaskManager* task_manager() { return task_manager_; }
+
private:
// The task manager.
- TaskManager* task_manager_; // weak
+ TaskManager* const task_manager_; // weak
// Our model.
- TaskManagerModel* model_; // weak
+ TaskManagerModel* const model_; // weak
- // Controller of our window.
- scoped_nsobject<TaskManagerWindowController> window_controller_;
+ // Controller of our window, destroys itself when the task manager window
+ // is closed.
+ TaskManagerWindowController* window_controller_; // weak
// An open task manager window. There can only be one open at a time. This
// is reset to NULL when the window is closed.
diff --git a/chrome/browser/cocoa/task_manager_mac.mm b/chrome/browser/cocoa/task_manager_mac.mm
index 00f0002..71b24f5 100644
--- a/chrome/browser/cocoa/task_manager_mac.mm
+++ b/chrome/browser/cocoa/task_manager_mac.mm
@@ -15,10 +15,8 @@
// TODO(thakis): Autoremember window size/pos (and selected columns?)
// TODO(thakis): Column sort comparator
// TODO(thakis): Clicking column header doesn't sort
-// TODO(thakis): On window close, stop updating
// TODO(thakis): Favicons in rows
// TODO(thakis): Default sort column
-// TODO(thakis): Metrics for all processes except browser process are missing.
@interface TaskManagerWindowController (Private)
- (void)addColumnWithId:(int)columnId visible:(BOOL)isVisible;
@@ -33,12 +31,13 @@
@implementation TaskManagerWindowController
-- (id)initWithTaskManager:(TaskManager*)taskManager {
+- (id)initWithTaskManagerObserver:(TaskManagerMac*)taskManagerObserver {
NSString* nibpath = [mac_util::MainAppBundle()
pathForResource:@"TaskManager"
ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
- taskManager_ = taskManager;
+ taskManagerObserver_ = taskManagerObserver;
+ taskManager_ = taskManagerObserver_->task_manager();
model_ = taskManager_->model();
[[self window] makeKeyAndOrderFront:self];
}
@@ -175,6 +174,17 @@
[self adjustEndProcessButton];
}
+// Called when the window is being closed. Send out a notification that the user
+// is done editing preferences. Make sure there are no pending field editors
+// by clearing the first responder.
+- (void)windowWillClose:(NSNotification*)notification {
+ if (taskManagerObserver_) {
+ taskManagerObserver_->WindowWasClosed();
+ taskManagerObserver_ = nil;
+ }
+ [self autorelease];
+}
+
@end
@implementation TaskManagerWindowController (NSTableDataSource)
@@ -259,8 +269,8 @@
TaskManagerMac::TaskManagerMac()
: task_manager_(TaskManager::GetInstance()),
model_(TaskManager::GetInstance()->model()) {
- window_controller_.reset(
- [[TaskManagerWindowController alloc] initWithTaskManager:task_manager_]);
+ window_controller_ =
+ [[TaskManagerWindowController alloc] initWithTaskManagerObserver:this];
model_->AddObserver(this);
}
@@ -276,24 +286,29 @@ TaskManagerMac::~TaskManagerMac() {
// TaskManagerMac, TaskManagerModelObserver implementation:
void TaskManagerMac::OnModelChanged() {
- [window_controller_.get() reloadData];
+ [window_controller_ reloadData];
}
void TaskManagerMac::OnItemsChanged(int start, int length) {
- [window_controller_.get() reloadData];
+ [window_controller_ reloadData];
}
void TaskManagerMac::OnItemsAdded(int start, int length) {
- [window_controller_.get() reloadData];
+ [window_controller_ reloadData];
}
void TaskManagerMac::OnItemsRemoved(int start, int length) {
- [window_controller_.get() reloadData];
+ [window_controller_ reloadData];
}
////////////////////////////////////////////////////////////////////////////////
// TaskManagerMac, public:
+void TaskManagerMac::WindowWasClosed() {
+ delete this;
+ instance_ = NULL;
+}
+
// static
void TaskManagerMac::Show() {
if (instance_) {
diff --git a/chrome/test/data/valgrind/unit_tests.gtest_mac.txt b/chrome/test/data/valgrind/unit_tests.gtest_mac.txt
index a013c37..caace66 100644
--- a/chrome/test/data/valgrind/unit_tests.gtest_mac.txt
+++ b/chrome/test/data/valgrind/unit_tests.gtest_mac.txt
@@ -34,5 +34,3 @@ RenderViewTest.OnPrintPages
RenderViewTest.Print*
# See http://crbug.com/30397.
TabStripControllerTest.AddRemoveTabs
-# See http://crbug.com/30398.
-TaskManagerWindowControllerTest.*