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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 183993004: Tease apart ServiceWorkerNetworkProvider from other stuff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/alias.h" 11 #include "base/debug/alias.h"
12 #include "base/debug/dump_without_crashing.h" 12 #include "base/debug/dump_without_crashing.h"
13 #include "base/i18n/char_iterator.h" 13 #include "base/i18n/char_iterator.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "content/child/appcache/appcache_dispatcher.h" 17 #include "content/child/appcache/appcache_dispatcher.h"
18 #include "content/child/plugin_messages.h" 18 #include "content/child/plugin_messages.h"
19 #include "content/child/quota_dispatcher.h" 19 #include "content/child/quota_dispatcher.h"
20 #include "content/child/request_extra_data.h" 20 #include "content/child/request_extra_data.h"
21 #include "content/child/service_worker/service_worker_network_provider.h"
21 #include "content/child/service_worker/web_service_worker_provider_impl.h" 22 #include "content/child/service_worker/web_service_worker_provider_impl.h"
22 #include "content/common/frame_messages.h" 23 #include "content/common/frame_messages.h"
23 #include "content/common/socket_stream_handle_data.h" 24 #include "content/common/socket_stream_handle_data.h"
24 #include "content/common/swapped_out_messages.h" 25 #include "content/common/swapped_out_messages.h"
25 #include "content/common/view_messages.h" 26 #include "content/common/view_messages.h"
26 #include "content/public/common/bindings_policy.h" 27 #include "content/public/common/bindings_policy.h"
27 #include "content/public/common/content_constants.h" 28 #include "content/public/common/content_constants.h"
28 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
29 #include "content/public/common/context_menu_params.h" 30 #include "content/public/common/context_menu_params.h"
30 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 blink::WebDataSource* datasource) { 923 blink::WebDataSource* datasource) {
923 DCHECK(!frame_ || frame_ == frame); 924 DCHECK(!frame_ || frame_ == frame);
924 925
925 // TODO(nasko): Move implementation here. Needed state: 926 // TODO(nasko): Move implementation here. Needed state:
926 // * pending_navigation_params_ 927 // * pending_navigation_params_
927 // * webview 928 // * webview
928 // Needed methods: 929 // Needed methods:
929 // * PopulateDocumentStateFromPending 930 // * PopulateDocumentStateFromPending
930 // * CreateNavigationStateFromPending 931 // * CreateNavigationStateFromPending
931 render_view_->didCreateDataSource(frame, datasource); 932 render_view_->didCreateDataSource(frame, datasource);
933
934 // Create the serviceworker's per-document network observing object.
935 scoped_ptr<ServiceWorkerNetworkProvider> network_provider(
936 new ServiceWorkerNetworkProvider(
937 ChildThread::current()->thread_safe_sender()));
938 ServiceWorkerNetworkProvider::AttachToDocumentState(
939 DocumentState::FromDataSource(datasource),
940 network_provider.Pass());
932 } 941 }
933 942
934 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { 943 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) {
935 DCHECK(!frame_ || frame_ == frame); 944 DCHECK(!frame_ || frame_ == frame);
936 WebDataSource* ds = frame->provisionalDataSource(); 945 WebDataSource* ds = frame->provisionalDataSource();
937 946
938 // In fast/loader/stop-provisional-loads.html, we abort the load before this 947 // In fast/loader/stop-provisional-loads.html, we abort the load before this
939 // callback is invoked. 948 // callback is invoked.
940 if (!ds) 949 if (!ds)
941 return; 950 return;
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 1433 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
1425 } else { 1434 } else {
1426 // If the navigation is browser-initiated, the NavigationState contains the 1435 // If the navigation is browser-initiated, the NavigationState contains the
1427 // correct value instead of the WebDataSource. 1436 // correct value instead of the WebDataSource.
1428 // 1437 //
1429 // TODO(davidben): Avoid this awkward duplication of state. See comment on 1438 // TODO(davidben): Avoid this awkward duplication of state. See comment on
1430 // NavigationState::should_replace_current_entry(). 1439 // NavigationState::should_replace_current_entry().
1431 should_replace_current_entry = 1440 should_replace_current_entry =
1432 navigation_state->should_replace_current_entry(); 1441 navigation_state->should_replace_current_entry();
1433 } 1442 }
1443
1444 // TODO(michaeln): Add WebDataSource* as a param to willSendRequest so
1445 // this ambiguity about which datasource can be removed.
1446 ServiceWorkerNetworkProvider* service_worker_network_provider = NULL;
1447 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame ||
1448 request.targetType() == blink::WebURLRequest::TargetIsSubframe) {
1449 service_worker_network_provider =
1450 ServiceWorkerNetworkProvider::FromDocumentState(
1451 DocumentState::FromDataSource(frame->provisionalDataSource()));
1452 } else {
1453 service_worker_network_provider =
1454 ServiceWorkerNetworkProvider::FromDocumentState(
1455 DocumentState::FromDataSource(frame->dataSource()));
1456 }
kinuko 2014/02/28 04:31:00 Couldn't we just use document_state retrieved at l
michaeln 2014/02/28 20:48:27 Nope, that's from the wrong document. That corresp
kinuko 2014/03/03 03:26:33 I see, thanks. Some of the tests look failing prob
1457
1434 // TODO(creis): Remove the second routing ID from the request, now that we 1458 // TODO(creis): Remove the second routing ID from the request, now that we
1435 // use routing IDs instead of frame IDs. (This is a viral change, so I'm 1459 // use routing IDs instead of frame IDs. (This is a viral change, so I'm
1436 // splitting it into multiple CLs.) 1460 // splitting it into multiple CLs.)
1437 int parent_routing_id = frame->parent() ? 1461 int parent_routing_id = frame->parent() ?
1438 FromWebFrame(frame->parent())->GetRoutingID() : -1; 1462 FromWebFrame(frame->parent())->GetRoutingID() : -1;
1439 request.setExtraData( 1463 request.setExtraData(
1440 new RequestExtraData(render_view_->visibilityState(), 1464 new RequestExtraData(render_view_->visibilityState(),
1441 custom_user_agent, 1465 custom_user_agent,
1442 was_after_preconnect_request, 1466 was_after_preconnect_request,
1443 routing_id_, 1467 routing_id_,
1444 (frame == top_frame), 1468 (frame == top_frame),
1445 routing_id_, 1469 routing_id_,
1446 GURL(frame->document().securityOrigin().toString()), 1470 GURL(frame->document().securityOrigin().toString()),
1447 frame->parent() == top_frame, 1471 frame->parent() == top_frame,
1448 parent_routing_id, 1472 parent_routing_id,
1449 navigation_state->allow_download(), 1473 navigation_state->allow_download(),
1450 transition_type, 1474 transition_type,
1451 should_replace_current_entry, 1475 should_replace_current_entry,
1452 navigation_state->transferred_request_child_id(), 1476 navigation_state->transferred_request_child_id(),
1453 navigation_state->transferred_request_request_id())); 1477 navigation_state->transferred_request_request_id(),
1478 service_worker_network_provider->provider_id()));
1454 1479
1455 DocumentState* top_document_state = 1480 DocumentState* top_document_state =
1456 DocumentState::FromDataSource(top_data_source); 1481 DocumentState::FromDataSource(top_data_source);
1457 if (top_document_state) { 1482 if (top_document_state) {
1458 // TODO(gavinp): separate out prefetching and prerender field trials 1483 // TODO(gavinp): separate out prefetching and prerender field trials
1459 // if the rel=prerender rel type is sticking around. 1484 // if the rel=prerender rel type is sticking around.
1460 if (request.targetType() == WebURLRequest::TargetIsPrefetch) 1485 if (request.targetType() == WebURLRequest::TargetIsPrefetch)
1461 top_document_state->set_was_prefetcher(true); 1486 top_document_state->set_was_prefetcher(true);
1462 1487
1463 if (was_after_preconnect_request) 1488 if (was_after_preconnect_request)
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 2059
2035 void RenderFrameImpl::didStartLoading() { 2060 void RenderFrameImpl::didStartLoading() {
2036 Send(new FrameHostMsg_DidStartLoading(routing_id_)); 2061 Send(new FrameHostMsg_DidStartLoading(routing_id_));
2037 } 2062 }
2038 2063
2039 void RenderFrameImpl::didStopLoading() { 2064 void RenderFrameImpl::didStopLoading() {
2040 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 2065 Send(new FrameHostMsg_DidStopLoading(routing_id_));
2041 } 2066 }
2042 2067
2043 } // namespace content 2068 } // namespace content
OLDNEW
« content/child/service_worker/service_worker_network_provider.cc ('K') | « content/content_child.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698