OLD | NEW |
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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
16 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/i18n/char_iterator.h" | 18 #include "base/i18n/char_iterator.h" |
19 #include "base/json/json_writer.h" | 19 #include "base/json/json_writer.h" |
20 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "base/message_loop/message_loop_proxy.h" | 22 #include "base/message_loop/message_loop_proxy.h" |
23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
24 #include "base/path_service.h" | 24 #include "base/path_service.h" |
25 #include "base/process/kill.h" | 25 #include "base/process/kill.h" |
| 26 #include "base/process/process.h" |
26 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
27 #include "base/strings/string_piece.h" | 28 #include "base/strings/string_piece.h" |
28 #include "base/strings/string_split.h" | 29 #include "base/strings/string_split.h" |
29 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
30 #include "base/strings/sys_string_conversions.h" | 31 #include "base/strings/sys_string_conversions.h" |
31 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
32 #include "base/time/time.h" | 33 #include "base/time/time.h" |
33 #include "content/child/appcache/appcache_dispatcher.h" | 34 #include "content/child/appcache/appcache_dispatcher.h" |
34 #include "content/child/appcache/web_application_cache_host_impl.h" | 35 #include "content/child/appcache/web_application_cache_host_impl.h" |
35 #include "content/child/child_thread.h" | 36 #include "content/child/child_thread.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 188 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
188 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 189 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
189 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 190 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
190 #include "third_party/WebKit/public/web/WebSettings.h" | 191 #include "third_party/WebKit/public/web/WebSettings.h" |
191 #include "third_party/WebKit/public/web/WebStorageQuotaCallbacks.h" | 192 #include "third_party/WebKit/public/web/WebStorageQuotaCallbacks.h" |
192 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 193 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
193 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 194 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
194 #include "third_party/WebKit/public/web/WebView.h" | 195 #include "third_party/WebKit/public/web/WebView.h" |
195 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 196 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
196 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" | 197 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" |
| 198 #include "ui/base/latency_info.h" |
197 #include "ui/base/ui_base_switches_util.h" | 199 #include "ui/base/ui_base_switches_util.h" |
198 #include "ui/gfx/native_widget_types.h" | 200 #include "ui/gfx/native_widget_types.h" |
199 #include "ui/gfx/point.h" | 201 #include "ui/gfx/point.h" |
200 #include "ui/gfx/rect.h" | 202 #include "ui/gfx/rect.h" |
201 #include "ui/gfx/rect_conversions.h" | 203 #include "ui/gfx/rect_conversions.h" |
202 #include "ui/gfx/size_conversions.h" | 204 #include "ui/gfx/size_conversions.h" |
203 #include "ui/shell_dialogs/selected_file_info.h" | 205 #include "ui/shell_dialogs/selected_file_info.h" |
204 #include "v8/include/v8.h" | 206 #include "v8/include/v8.h" |
205 #include "webkit/child/weburlresponse_extradata_impl.h" | 207 #include "webkit/child/weburlresponse_extradata_impl.h" |
206 | 208 |
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 2248 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
2247 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); | 2249 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
2248 | 2250 |
2249 message->EnableMessagePumping(); // Runs a nested message loop. | 2251 message->EnableMessagePumping(); // Runs a nested message loop. |
2250 return Send(message); | 2252 return Send(message); |
2251 } | 2253 } |
2252 | 2254 |
2253 void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) { | 2255 void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) { |
2254 int id = next_snapshot_id_++; | 2256 int id = next_snapshot_id_++; |
2255 pending_snapshots_.insert(std::make_pair(id, callback)); | 2257 pending_snapshots_.insert(std::make_pair(id, callback)); |
2256 Send(new ViewHostMsg_GetWindowSnapshot(routing_id_, id)); | 2258 ui::LatencyInfo latency_info; |
| 2259 latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 2260 GetLatencyComponentId(), |
| 2261 id); |
| 2262 LOG(INFO) << "RenderViewImpl::GetWindowSnapshot: id = " << id << " process id
= " << (int) base::Process::Current().pid() << " process handle = " << (int) b
ase::GetCurrentProcessHandle() << " routing id = " << GetRoutingID() << " laten
cy_component_id: " << GetLatencyComponentId(); |
| 2263 if (RenderWidgetCompositor* rwc = compositor()) { |
| 2264 LOG(INFO) << " composited path"; |
| 2265 rwc->SetLatencyInfo(latency_info); |
| 2266 } else { |
| 2267 LOG(INFO) << " non-composited path"; |
| 2268 latency_info_.MergeWith(latency_info); |
| 2269 } |
| 2270 ScheduleCompositeWithForcedRedraw(); |
2257 } | 2271 } |
2258 | 2272 |
2259 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, | 2273 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, |
2260 const gfx::Size& size, const std::vector<unsigned char>& png) { | 2274 const gfx::Size& size, const std::vector<unsigned char>& png) { |
2261 PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id); | 2275 PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id); |
2262 DCHECK(it != pending_snapshots_.end()); | 2276 DCHECK(it != pending_snapshots_.end()); |
2263 it->second.Run(size, png); | 2277 it->second.Run(size, png); |
2264 pending_snapshots_.erase(it); | 2278 pending_snapshots_.erase(it); |
2265 } | 2279 } |
2266 | 2280 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2734 } | 2748 } |
2735 } | 2749 } |
2736 | 2750 |
2737 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( | 2751 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
2738 const gfx::RectF& rect) const { | 2752 const gfx::RectF& rect) const { |
2739 gfx::RectF window_rect = rect; | 2753 gfx::RectF window_rect = rect; |
2740 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); | 2754 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
2741 return window_rect; | 2755 return window_rect; |
2742 } | 2756 } |
2743 | 2757 |
| 2758 int64 RenderViewImpl::GetLatencyComponentId() { |
| 2759 // Note: this must match the logic in RenderWidgetHostImpl. |
| 2760 return GetRoutingID() | (static_cast<int64>( |
| 2761 RenderThreadImpl::current()->renderer_process_id()) << 32); |
| 2762 } |
| 2763 |
2744 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { | 2764 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
2745 // No need to update state if no page has committed yet. | 2765 // No need to update state if no page has committed yet. |
2746 if (page_id_ == -1) | 2766 if (page_id_ == -1) |
2747 return; | 2767 return; |
2748 | 2768 |
2749 int delay; | 2769 int delay; |
2750 if (send_content_state_immediately_) | 2770 if (send_content_state_immediately_) |
2751 delay = 0; | 2771 delay = 0; |
2752 else if (is_hidden()) | 2772 else if (is_hidden()) |
2753 delay = kDelaySecondsForContentStateSyncHidden; | 2773 delay = kDelaySecondsForContentStateSyncHidden; |
(...skipping 3766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6520 for (size_t i = 0; i < icon_urls.size(); i++) { | 6540 for (size_t i = 0; i < icon_urls.size(); i++) { |
6521 WebURL url = icon_urls[i].iconURL(); | 6541 WebURL url = icon_urls[i].iconURL(); |
6522 if (!url.isEmpty()) | 6542 if (!url.isEmpty()) |
6523 urls.push_back(FaviconURL(url, | 6543 urls.push_back(FaviconURL(url, |
6524 ToFaviconType(icon_urls[i].iconType()))); | 6544 ToFaviconType(icon_urls[i].iconType()))); |
6525 } | 6545 } |
6526 SendUpdateFaviconURL(urls); | 6546 SendUpdateFaviconURL(urls); |
6527 } | 6547 } |
6528 | 6548 |
6529 } // namespace content | 6549 } // namespace content |
OLD | NEW |