OLD | NEW |
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 #include "chrome/browser/task_manager/task_manager_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" |
10 #include "base/file_version_info.h" | 11 #include "base/file_version_info.h" |
11 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
12 #include "base/process_util.h" | 13 #include "base/process_util.h" |
13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
19 #include "chrome/browser/background/background_contents_service.h" | 20 #include "chrome/browser/background/background_contents_service.h" |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 | 914 |
914 // Register for notifications to get new child processes. | 915 // Register for notifications to get new child processes. |
915 registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED, | 916 registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED, |
916 content::NotificationService::AllBrowserContextsAndSources()); | 917 content::NotificationService::AllBrowserContextsAndSources()); |
917 registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, | 918 registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, |
918 content::NotificationService::AllBrowserContextsAndSources()); | 919 content::NotificationService::AllBrowserContextsAndSources()); |
919 | 920 |
920 // Get the existing child processes. | 921 // Get the existing child processes. |
921 BrowserThread::PostTask( | 922 BrowserThread::PostTask( |
922 BrowserThread::IO, FROM_HERE, | 923 BrowserThread::IO, FROM_HERE, |
923 NewRunnableMethod( | 924 base::Bind( |
924 this, | 925 &TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo, |
925 &TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo)); | 926 this)); |
926 } | 927 } |
927 | 928 |
928 void TaskManagerChildProcessResourceProvider::StopUpdating() { | 929 void TaskManagerChildProcessResourceProvider::StopUpdating() { |
929 DCHECK(updating_); | 930 DCHECK(updating_); |
930 updating_ = false; | 931 updating_ = false; |
931 | 932 |
932 // Unregister for notifications to get new plugin processes. | 933 // Unregister for notifications to get new plugin processes. |
933 registrar_.Remove( | 934 registrar_.Remove( |
934 this, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED, | 935 this, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED, |
935 content::NotificationService::AllBrowserContextsAndSources()); | 936 content::NotificationService::AllBrowserContextsAndSources()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 void TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo() { | 1026 void TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo() { |
1026 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { | 1027 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { |
1027 // Only add processes which are already started, since we need their handle. | 1028 // Only add processes which are already started, since we need their handle. |
1028 if ((*iter)->handle() != base::kNullProcessHandle) | 1029 if ((*iter)->handle() != base::kNullProcessHandle) |
1029 existing_child_process_info_.push_back(**iter); | 1030 existing_child_process_info_.push_back(**iter); |
1030 } | 1031 } |
1031 // Now notify the UI thread that we have retrieved information about child | 1032 // Now notify the UI thread that we have retrieved information about child |
1032 // processes. | 1033 // processes. |
1033 BrowserThread::PostTask( | 1034 BrowserThread::PostTask( |
1034 BrowserThread::UI, FROM_HERE, | 1035 BrowserThread::UI, FROM_HERE, |
1035 NewRunnableMethod(this, | 1036 base::Bind( |
1036 &TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived)); | 1037 &TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived, |
| 1038 this)); |
1037 } | 1039 } |
1038 | 1040 |
1039 // This is called on the UI thread. | 1041 // This is called on the UI thread. |
1040 void TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived() { | 1042 void TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived() { |
1041 std::vector<ChildProcessInfo>::const_iterator iter; | 1043 std::vector<ChildProcessInfo>::const_iterator iter; |
1042 for (iter = existing_child_process_info_.begin(); | 1044 for (iter = existing_child_process_info_.begin(); |
1043 iter != existing_child_process_info_.end(); ++iter) { | 1045 iter != existing_child_process_info_.end(); ++iter) { |
1044 Add(*iter); | 1046 Add(*iter); |
1045 } | 1047 } |
1046 existing_child_process_info_.clear(); | 1048 existing_child_process_info_.clear(); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 | 1391 |
1390 return &resource_; | 1392 return &resource_; |
1391 } | 1393 } |
1392 | 1394 |
1393 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1395 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1394 task_manager_->AddResource(&resource_); | 1396 task_manager_->AddResource(&resource_); |
1395 } | 1397 } |
1396 | 1398 |
1397 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1399 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1398 } | 1400 } |
OLD | NEW |