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

Side by Side Diff: extensions/browser/api/web_request/web_request_api.cc

Issue 1569673002: [NOT FOR LANDING] Detailed loading traces Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
« no previous file with comments | « content/public/browser/browser_message_filter.cc ('k') | net/base/ip_endpoint.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 "extensions/browser/api/web_request/web_request_api.h" 5 #include "extensions/browser/api/web_request/web_request_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 609 }
610 return event_details; 610 return event_details;
611 } 611 }
612 612
613 int ExtensionWebRequestEventRouter::OnBeforeRequest( 613 int ExtensionWebRequestEventRouter::OnBeforeRequest(
614 void* browser_context, 614 void* browser_context,
615 const InfoMap* extension_info_map, 615 const InfoMap* extension_info_map,
616 net::URLRequest* request, 616 net::URLRequest* request,
617 const net::CompletionCallback& callback, 617 const net::CompletionCallback& callback,
618 GURL* new_url) { 618 GURL* new_url) {
619 TRACE_EVENT0("toplevel", "ExtensionWebRequestEventRouter::OnBeforeRequest");
620
619 if (ShouldHideEvent(browser_context, extension_info_map, request)) 621 if (ShouldHideEvent(browser_context, extension_info_map, request))
620 return net::OK; 622 return net::OK;
623 TRACE_EVENT0("toplevel",
624 "ExtensionWebRequestEventRouter::OnBeforeRequest::A");
621 625
622 if (IsPageLoad(request)) 626 if (IsPageLoad(request))
623 NotifyPageLoad(); 627 NotifyPageLoad();
624 628 TRACE_EVENT0("toplevel",
629 "ExtensionWebRequestEventRouter::OnBeforeRequest::B");
625 request_time_tracker_->LogRequestStartTime(request->identifier(), 630 request_time_tracker_->LogRequestStartTime(request->identifier(),
626 base::Time::Now(), 631 base::Time::Now(),
627 request->url(), 632 request->url(),
628 browser_context); 633 browser_context);
629 634 TRACE_EVENT0("toplevel",
635 "ExtensionWebRequestEventRouter::OnBeforeRequest::C");
630 // Whether to initialized |blocked_requests_|. 636 // Whether to initialized |blocked_requests_|.
631 bool initialize_blocked_requests = false; 637 bool initialize_blocked_requests = false;
632 638
633 initialize_blocked_requests |= 639 initialize_blocked_requests |=
634 ProcessDeclarativeRules(browser_context, extension_info_map, 640 ProcessDeclarativeRules(browser_context, extension_info_map,
635 web_request::OnBeforeRequest::kEventName, request, 641 web_request::OnBeforeRequest::kEventName, request,
636 ON_BEFORE_REQUEST, NULL); 642 ON_BEFORE_REQUEST, NULL);
637 643 TRACE_EVENT0("toplevel",
644 "ExtensionWebRequestEventRouter::OnBeforeRequest::D");
638 int extra_info_spec = 0; 645 int extra_info_spec = 0;
639 EventListeners listeners = GetMatchingListeners( 646 EventListeners listeners = GetMatchingListeners(
640 browser_context, extension_info_map, 647 browser_context, extension_info_map,
641 web_request::OnBeforeRequest::kEventName, request, &extra_info_spec); 648 web_request::OnBeforeRequest::kEventName, request, &extra_info_spec);
649 TRACE_EVENT0("toplevel",
650 "ExtensionWebRequestEventRouter::OnBeforeRequest::E");
642 if (!listeners.empty() && 651 if (!listeners.empty() &&
643 !GetAndSetSignaled(request->identifier(), kOnBeforeRequest)) { 652 !GetAndSetSignaled(request->identifier(), kOnBeforeRequest)) {
644 scoped_ptr<WebRequestEventDetails> event_details( 653 scoped_ptr<WebRequestEventDetails> event_details(
645 CreateEventDetails(request, extra_info_spec)); 654 CreateEventDetails(request, extra_info_spec));
646 event_details->SetRequestBody(request); 655 event_details->SetRequestBody(request);
647 656
648 initialize_blocked_requests |= DispatchEvent( 657 initialize_blocked_requests |= DispatchEvent(
649 browser_context, request, listeners, std::move(event_details)); 658 browser_context, request, listeners, std::move(event_details));
650 } 659 }
651 660 TRACE_EVENT0("toplevel",
661 "ExtensionWebRequestEventRouter::OnBeforeRequest::F");
652 if (!initialize_blocked_requests) 662 if (!initialize_blocked_requests)
653 return net::OK; // Nobody saw a reason for modifying the request. 663 return net::OK; // Nobody saw a reason for modifying the request.
654 664
655 BlockedRequest& blocked_request = blocked_requests_[request->identifier()]; 665 BlockedRequest& blocked_request = blocked_requests_[request->identifier()];
656 blocked_request.event = kOnBeforeRequest; 666 blocked_request.event = kOnBeforeRequest;
657 blocked_request.is_incognito |= IsIncognitoBrowserContext(browser_context); 667 blocked_request.is_incognito |= IsIncognitoBrowserContext(browser_context);
658 blocked_request.request = request; 668 blocked_request.request = request;
659 blocked_request.callback = callback; 669 blocked_request.callback = callback;
660 blocked_request.new_url = new_url; 670 blocked_request.new_url = new_url;
661 blocked_request.net_log = &request->net_log(); 671 blocked_request.net_log = &request->net_log();
662 672 TRACE_EVENT0("toplevel",
673 "ExtensionWebRequestEventRouter::OnBeforeRequest::G");
663 if (blocked_request.num_handlers_blocking == 0) { 674 if (blocked_request.num_handlers_blocking == 0) {
664 // If there are no blocking handlers, only the declarative rules tried 675 // If there are no blocking handlers, only the declarative rules tried
665 // to modify the request and we can respond synchronously. 676 // to modify the request and we can respond synchronously.
666 return ExecuteDeltas(browser_context, request->identifier(), 677 return ExecuteDeltas(browser_context, request->identifier(),
667 false /* call_callback*/); 678 false /* call_callback*/);
668 } 679 }
669 return net::ERR_IO_PENDING; 680 return net::ERR_IO_PENDING;
670 } 681 }
671 682
672 int ExtensionWebRequestEventRouter::OnBeforeSendHeaders( 683 int ExtensionWebRequestEventRouter::OnBeforeSendHeaders(
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 // Continue gracefully. 2296 // Continue gracefully.
2286 RunSync(); 2297 RunSync();
2287 } 2298 }
2288 2299
2289 bool WebRequestHandlerBehaviorChangedFunction::RunSync() { 2300 bool WebRequestHandlerBehaviorChangedFunction::RunSync() {
2290 helpers::ClearCacheOnNavigation(); 2301 helpers::ClearCacheOnNavigation();
2291 return true; 2302 return true;
2292 } 2303 }
2293 2304
2294 } // namespace extensions 2305 } // namespace extensions
OLDNEW
« no previous file with comments | « content/public/browser/browser_message_filter.cc ('k') | net/base/ip_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698