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

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
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/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/task_manager/task_manager_resource_providers.h" 23 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
24 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h" 24 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
28 #include "chrome/common/chrome_view_type.h" 28 #include "chrome/common/chrome_view_type.h"
29 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "content/browser/renderer_host/render_view_host.h" 31 #include "content/browser/renderer_host/render_view_host.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_delegate.h" 34 #include "content/public/browser/render_view_host_delegate.h"
35 #include "content/public/browser/resource_request_info.h"
37 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
38 #include "content/public/common/result_codes.h" 37 #include "content/public/common/result_codes.h"
39 #include "grit/chromium_strings.h" 38 #include "grit/chromium_strings.h"
40 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
41 #include "grit/ui_resources.h" 40 #include "grit/ui_resources.h"
42 #include "third_party/skia/include/core/SkBitmap.h" 41 #include "third_party/skia/include/core/SkBitmap.h"
43 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
45 #include "ui/base/text/bytes_formatting.h" 44 #include "ui/base/text/bytes_formatting.h"
46 #include "unicode/coll.h" 45 #include "unicode/coll.h"
47 46
48 using content::BrowserThread; 47 using content::BrowserThread;
49 using content::OpenURLParams; 48 using content::OpenURLParams;
50 using content::Referrer; 49 using content::Referrer;
50 using content::ResourceRequestInfo;
51 51
52 namespace { 52 namespace {
53 53
54 // The delay between updates of the information (in ms). 54 // The delay between updates of the information (in ms).
55 #if defined(OS_MACOSX) 55 #if defined(OS_MACOSX)
56 // Match Activity Monitor's default refresh rate. 56 // Match Activity Monitor's default refresh rate.
57 const int kUpdateTimeMs = 2000; 57 const int kUpdateTimeMs = 2000;
58 #else 58 #else
59 const int kUpdateTimeMs = 1000; 59 const int kUpdateTimeMs = 1000;
60 #endif 60 #endif
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 if (iter_res == current_byte_count_map_.end()) 964 if (iter_res == current_byte_count_map_.end())
965 current_byte_count_map_[resource] = param.byte_count; 965 current_byte_count_map_[resource] = param.byte_count;
966 else 966 else
967 current_byte_count_map_[resource] = iter_res->second + param.byte_count; 967 current_byte_count_map_[resource] = iter_res->second + param.byte_count;
968 } 968 }
969 969
970 970
971 void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request, 971 void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request,
972 int byte_count) { 972 int byte_count) {
973 // Only net::URLRequestJob instances created by the ResourceDispatcherHost 973 // Only net::URLRequestJob instances created by the ResourceDispatcherHost
974 // have an associated ResourceRequestInfo.
975 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
976
974 // have a render view associated. All other jobs will have -1 returned for 977 // have a render view associated. All other jobs will have -1 returned for
975 // the render process child and routing ids - the jobs may still match a 978 // the render process child and routing ids - the jobs may still match a
976 // resource based on their origin id, otherwise BytesRead() will attribute 979 // resource based on their origin id, otherwise BytesRead() will attribute
977 // the activity to the Browser resource. 980 // the activity to the Browser resource.
978 int render_process_host_child_id = -1, routing_id = -1; 981 int render_process_host_child_id = -1, routing_id = -1;
979 ResourceDispatcherHost::RenderViewForRequest(&request, 982 if (info)
980 &render_process_host_child_id, 983 info->GetAssociatedRenderView(&render_process_host_child_id, &routing_id);
981 &routing_id);
982 984
983 // Get the origin PID of the request's originator. This will only be set for 985 // Get the origin PID of the request's originator. This will only be set for
984 // plugins - for renderer or browser initiated requests it will be zero. 986 // plugins - for renderer or browser initiated requests it will be zero.
985 int origin_pid = 0; 987 int origin_pid = 0;
986 const ResourceDispatcherHostRequestInfo* info =
987 ResourceDispatcherHost::InfoForRequest(&request);
988 if (info) 988 if (info)
989 origin_pid = info->origin_pid(); 989 origin_pid = info->origin_pid();
990 990
991 // This happens in the IO thread, post it to the UI thread. 991 // This happens in the IO thread, post it to the UI thread.
992 BrowserThread::PostTask( 992 BrowserThread::PostTask(
993 BrowserThread::UI, FROM_HERE, 993 BrowserThread::UI, FROM_HERE,
994 base::Bind(&TaskManagerModel::BytesRead, this, 994 base::Bind(&TaskManagerModel::BytesRead, this,
995 BytesReadParam(origin_pid, render_process_host_child_id, 995 BytesReadParam(origin_pid, render_process_host_child_id,
996 routing_id, byte_count))); 996 routing_id, byte_count)));
997 } 997 }
(...skipping 163 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

Powered by Google App Engine
This is Rietveld 408576698