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

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

Issue 9580002: Add ResourceRequestInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/ssl/ssl_add_cert_handler.cc ('k') | chrome/browser/ui/login/login_prompt.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) 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 #include "chrome/browser/task_manager/task_manager.h" 5 #include "chrome/browser/task_manager/task_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/number_formatting.h" 9 #include "base/i18n/number_formatting.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
23 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/task_manager/task_manager_resource_providers.h" 24 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
25 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h" 25 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h"
26 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/browser_window.h" 27 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
29 #include "chrome/common/chrome_view_type.h" 29 #include "chrome/common/chrome_view_type.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
32 #include "content/browser/renderer_host/resource_dispatcher_host.h"
33 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
34 #include "content/public/browser/browser_child_process_host.h" 32 #include "content/public/browser/browser_child_process_host.h"
35 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
37 #include "content/public/browser/render_view_host_delegate.h" 35 #include "content/public/browser/render_view_host_delegate.h"
36 #include "content/public/browser/resource_request_info.h"
38 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
39 #include "content/public/common/result_codes.h" 38 #include "content/public/common/result_codes.h"
40 #include "grit/chromium_strings.h" 39 #include "grit/chromium_strings.h"
41 #include "grit/generated_resources.h" 40 #include "grit/generated_resources.h"
42 #include "grit/ui_resources.h" 41 #include "grit/ui_resources.h"
43 #include "third_party/skia/include/core/SkBitmap.h" 42 #include "third_party/skia/include/core/SkBitmap.h"
44 #include "ui/base/l10n/l10n_util.h" 43 #include "ui/base/l10n/l10n_util.h"
45 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
46 #include "ui/base/text/bytes_formatting.h" 45 #include "ui/base/text/bytes_formatting.h"
47 #include "unicode/coll.h" 46 #include "unicode/coll.h"
48 47
49 using content::BrowserThread; 48 using content::BrowserThread;
50 using content::OpenURLParams; 49 using content::OpenURLParams;
51 using content::Referrer; 50 using content::Referrer;
51 using content::ResourceRequestInfo;
52 52
53 namespace { 53 namespace {
54 54
55 // The delay between updates of the information (in ms). 55 // The delay between updates of the information (in ms).
56 #if defined(OS_MACOSX) 56 #if defined(OS_MACOSX)
57 // Match Activity Monitor's default refresh rate. 57 // Match Activity Monitor's default refresh rate.
58 const int kUpdateTimeMs = 2000; 58 const int kUpdateTimeMs = 2000;
59 #else 59 #else
60 const int kUpdateTimeMs = 1000; 60 const int kUpdateTimeMs = 1000;
61 #endif 61 #endif
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 if (iter_res == current_byte_count_map_.end()) 965 if (iter_res == current_byte_count_map_.end())
966 current_byte_count_map_[resource] = param.byte_count; 966 current_byte_count_map_[resource] = param.byte_count;
967 else 967 else
968 current_byte_count_map_[resource] = iter_res->second + param.byte_count; 968 current_byte_count_map_[resource] = iter_res->second + param.byte_count;
969 } 969 }
970 970
971 971
972 void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request, 972 void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request,
973 int byte_count) { 973 int byte_count) {
974 // Only net::URLRequestJob instances created by the ResourceDispatcherHost 974 // Only net::URLRequestJob instances created by the ResourceDispatcherHost
975 // have an associated ResourceRequestInfo.
976 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
977
975 // have a render view associated. All other jobs will have -1 returned for 978 // have a render view associated. All other jobs will have -1 returned for
976 // the render process child and routing ids - the jobs may still match a 979 // the render process child and routing ids - the jobs may still match a
977 // resource based on their origin id, otherwise BytesRead() will attribute 980 // resource based on their origin id, otherwise BytesRead() will attribute
978 // the activity to the Browser resource. 981 // the activity to the Browser resource.
979 int render_process_host_child_id = -1, routing_id = -1; 982 int render_process_host_child_id = -1, routing_id = -1;
980 ResourceDispatcherHost::RenderViewForRequest(&request, 983 if (info)
981 &render_process_host_child_id, 984 info->GetAssociatedRenderView(&render_process_host_child_id, &routing_id);
982 &routing_id);
983 985
984 // Get the origin PID of the request's originator. This will only be set for 986 // Get the origin PID of the request's originator. This will only be set for
985 // plugins - for renderer or browser initiated requests it will be zero. 987 // plugins - for renderer or browser initiated requests it will be zero.
986 int origin_pid = 0; 988 int origin_pid = 0;
987 const ResourceDispatcherHostRequestInfo* info =
988 ResourceDispatcherHost::InfoForRequest(&request);
989 if (info) 989 if (info)
990 origin_pid = info->origin_pid(); 990 origin_pid = info->GetOriginPID();
991 991
992 // This happens in the IO thread, post it to the UI thread. 992 // This happens in the IO thread, post it to the UI thread.
993 BrowserThread::PostTask( 993 BrowserThread::PostTask(
994 BrowserThread::UI, FROM_HERE, 994 BrowserThread::UI, FROM_HERE,
995 base::Bind(&TaskManagerModel::BytesRead, this, 995 base::Bind(&TaskManagerModel::BytesRead, this,
996 BytesReadParam(origin_pid, render_process_host_child_id, 996 BytesReadParam(origin_pid, render_process_host_child_id,
997 routing_id, byte_count))); 997 routing_id, byte_count)));
998 } 998 }
999 999
1000 bool TaskManagerModel::GetProcessMetricsForRow( 1000 bool TaskManagerModel::GetProcessMetricsForRow(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 // Count the number of extensions with background pages (including 1161 // Count the number of extensions with background pages (including
1162 // incognito). 1162 // incognito).
1163 count += CountExtensionBackgroundPagesForProfile(profile); 1163 count += CountExtensionBackgroundPagesForProfile(profile);
1164 if (profile->HasOffTheRecordProfile()) { 1164 if (profile->HasOffTheRecordProfile()) {
1165 count += CountExtensionBackgroundPagesForProfile( 1165 count += CountExtensionBackgroundPagesForProfile(
1166 profile->GetOffTheRecordProfile()); 1166 profile->GetOffTheRecordProfile());
1167 } 1167 }
1168 } 1168 }
1169 return count; 1169 return count;
1170 } 1170 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_add_cert_handler.cc ('k') | chrome/browser/ui/login/login_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698