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 "chrome/browser/extensions/api/web_request/web_request_api.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 rules_registries_.end()) { | 1954 rules_registries_.end()) { |
1955 relevant_registries.push_back( | 1955 relevant_registries.push_back( |
1956 std::make_pair(rules_registries_[cross_profile_rules_key].get(), true)); | 1956 std::make_pair(rules_registries_[cross_profile_rules_key].get(), true)); |
1957 } | 1957 } |
1958 | 1958 |
1959 // The following block is experimentally enabled and its impact on load time | 1959 // The following block is experimentally enabled and its impact on load time |
1960 // logged with UMA Extensions.NetworkDelayRegistryLoad. crbug.com/175961 | 1960 // logged with UMA Extensions.NetworkDelayRegistryLoad. crbug.com/175961 |
1961 for (RelevantRegistries::iterator i = relevant_registries.begin(); | 1961 for (RelevantRegistries::iterator i = relevant_registries.begin(); |
1962 i != relevant_registries.end(); ++i) { | 1962 i != relevant_registries.end(); ++i) { |
1963 extensions::WebRequestRulesRegistry* rules_registry = i->first; | 1963 extensions::WebRequestRulesRegistry* rules_registry = i->first; |
1964 if (!rules_registry->ready().is_signaled()) { | 1964 const extensions::OneShotEvent* ready = rules_registry->ready(); |
| 1965 if (ready && !ready->is_signaled()) { |
1965 // The rules registry is still loading. Block this request until it | 1966 // The rules registry is still loading. Block this request until it |
1966 // finishes. | 1967 // finishes. |
1967 rules_registry->ready().Post( | 1968 ready->Post( |
1968 FROM_HERE, | 1969 FROM_HERE, |
1969 base::Bind(&ExtensionWebRequestEventRouter::OnRulesRegistryReady, | 1970 base::Bind(&ExtensionWebRequestEventRouter::OnRulesRegistryReady, |
1970 AsWeakPtr(), | 1971 AsWeakPtr(), |
1971 profile, | 1972 profile, |
1972 event_name, | 1973 event_name, |
1973 request->identifier(), | 1974 request->identifier(), |
1974 request_stage)); | 1975 request_stage)); |
1975 blocked_requests_[request->identifier()].num_handlers_blocking++; | 1976 blocked_requests_[request->identifier()].num_handlers_blocking++; |
1976 blocked_requests_[request->identifier()].request = request; | 1977 blocked_requests_[request->identifier()].request = request; |
1977 blocked_requests_[request->identifier()].is_incognito |= | 1978 blocked_requests_[request->identifier()].is_incognito |= |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2372 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2372 adblock = true; | 2373 adblock = true; |
2373 } else { | 2374 } else { |
2374 other = true; | 2375 other = true; |
2375 } | 2376 } |
2376 } | 2377 } |
2377 } | 2378 } |
2378 | 2379 |
2379 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2380 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2380 } | 2381 } |
OLD | NEW |