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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 187 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
187 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 188 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
188 #include "third_party/WebKit/public/web/WebSettings.h" | 189 #include "third_party/WebKit/public/web/WebSettings.h" |
189 #include "third_party/WebKit/public/web/WebStorageQuotaCallbacks.h" | 190 #include "third_party/WebKit/public/web/WebStorageQuotaCallbacks.h" |
190 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 191 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
191 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 192 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
192 #include "third_party/WebKit/public/web/WebView.h" | 193 #include "third_party/WebKit/public/web/WebView.h" |
193 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 194 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
194 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" | 195 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" |
195 #include "ui/base/ui_base_switches_util.h" | 196 #include "ui/base/ui_base_switches_util.h" |
| 197 #include "ui/events/latency_info.h" |
196 #include "ui/gfx/native_widget_types.h" | 198 #include "ui/gfx/native_widget_types.h" |
197 #include "ui/gfx/point.h" | 199 #include "ui/gfx/point.h" |
198 #include "ui/gfx/rect.h" | 200 #include "ui/gfx/rect.h" |
199 #include "ui/gfx/rect_conversions.h" | 201 #include "ui/gfx/rect_conversions.h" |
200 #include "ui/gfx/size_conversions.h" | 202 #include "ui/gfx/size_conversions.h" |
201 #include "ui/shell_dialogs/selected_file_info.h" | 203 #include "ui/shell_dialogs/selected_file_info.h" |
202 #include "v8/include/v8.h" | 204 #include "v8/include/v8.h" |
203 #include "webkit/child/weburlresponse_extradata_impl.h" | 205 #include "webkit/child/weburlresponse_extradata_impl.h" |
204 | 206 |
205 #if defined(OS_ANDROID) | 207 #if defined(OS_ANDROID) |
(...skipping 2040 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 if (RenderWidgetCompositor* rwc = compositor()) { |
| 2263 rwc->SetLatencyInfo(latency_info); |
| 2264 } else { |
| 2265 latency_info_.MergeWith(latency_info); |
| 2266 } |
| 2267 ScheduleCompositeWithForcedRedraw(); |
2257 } | 2268 } |
2258 | 2269 |
2259 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, | 2270 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, |
2260 const gfx::Size& size, const std::vector<unsigned char>& png) { | 2271 const gfx::Size& size, const std::vector<unsigned char>& png) { |
2261 PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id); | 2272 |
2262 DCHECK(it != pending_snapshots_.end()); | 2273 // Any pending snapshots with a lower ID than the one received are considered |
2263 it->second.Run(size, png); | 2274 // to be implicitly complete, and returned the same snapshot data. |
2264 pending_snapshots_.erase(it); | 2275 PendingSnapshotMap::iterator it = pending_snapshots_.begin(); |
| 2276 while(it != pending_snapshots_.end()) { |
| 2277 if (it->first <= snapshot_id) { |
| 2278 it->second.Run(size, png); |
| 2279 pending_snapshots_.erase(it++); |
| 2280 } else { |
| 2281 ++it; |
| 2282 } |
| 2283 } |
2265 } | 2284 } |
2266 | 2285 |
2267 // WebKit::WebViewClient ------------------------------------------------------ | 2286 // WebKit::WebViewClient ------------------------------------------------------ |
2268 | 2287 |
2269 WebView* RenderViewImpl::createView( | 2288 WebView* RenderViewImpl::createView( |
2270 WebFrame* creator, | 2289 WebFrame* creator, |
2271 const WebURLRequest& request, | 2290 const WebURLRequest& request, |
2272 const WebWindowFeatures& features, | 2291 const WebWindowFeatures& features, |
2273 const WebString& frame_name, | 2292 const WebString& frame_name, |
2274 WebNavigationPolicy policy) { | 2293 WebNavigationPolicy policy) { |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 } | 2758 } |
2740 } | 2759 } |
2741 | 2760 |
2742 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( | 2761 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
2743 const gfx::RectF& rect) const { | 2762 const gfx::RectF& rect) const { |
2744 gfx::RectF window_rect = rect; | 2763 gfx::RectF window_rect = rect; |
2745 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); | 2764 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
2746 return window_rect; | 2765 return window_rect; |
2747 } | 2766 } |
2748 | 2767 |
| 2768 int64 RenderViewImpl::GetLatencyComponentId() { |
| 2769 // Note: this must match the logic in RenderWidgetHostImpl. |
| 2770 return GetRoutingID() | (static_cast<int64>( |
| 2771 RenderThreadImpl::current()->renderer_process_id()) << 32); |
| 2772 } |
| 2773 |
2749 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { | 2774 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
2750 // No need to update state if no page has committed yet. | 2775 // No need to update state if no page has committed yet. |
2751 if (page_id_ == -1) | 2776 if (page_id_ == -1) |
2752 return; | 2777 return; |
2753 | 2778 |
2754 int delay; | 2779 int delay; |
2755 if (send_content_state_immediately_) | 2780 if (send_content_state_immediately_) |
2756 delay = 0; | 2781 delay = 0; |
2757 else if (is_hidden()) | 2782 else if (is_hidden()) |
2758 delay = kDelaySecondsForContentStateSyncHidden; | 2783 delay = kDelaySecondsForContentStateSyncHidden; |
(...skipping 3788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6547 for (size_t i = 0; i < icon_urls.size(); i++) { | 6572 for (size_t i = 0; i < icon_urls.size(); i++) { |
6548 WebURL url = icon_urls[i].iconURL(); | 6573 WebURL url = icon_urls[i].iconURL(); |
6549 if (!url.isEmpty()) | 6574 if (!url.isEmpty()) |
6550 urls.push_back(FaviconURL(url, | 6575 urls.push_back(FaviconURL(url, |
6551 ToFaviconType(icon_urls[i].iconType()))); | 6576 ToFaviconType(icon_urls[i].iconType()))); |
6552 } | 6577 } |
6553 SendUpdateFaviconURL(urls); | 6578 SendUpdateFaviconURL(urls); |
6554 } | 6579 } |
6555 | 6580 |
6556 } // namespace content | 6581 } // namespace content |
OLD | NEW |