[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / renderer_host / safe_browsing_resource_throttle_factory.cc
blob4429a6c4e6e81a9dcfd6c1d16fa76a7548acb79f
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
3 // found in the LICENSE file.
5 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h"
7 // Compiling this file only makes sense if SAFE_BROWSING_SERVICE is enabled.
8 // If the build is breaking here, it probably means that a gyp or gn file has
9 // been modified to build this file with safe_browsing=0 (gn
10 // safe_browsing_mode=0).
11 #if !defined(SAFE_BROWSING_SERVICE)
12 #error Need to define safe_browsing mode.
13 #endif
15 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
16 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h"
17 #endif
19 using content::ResourceThrottle;
21 namespace {
23 SafeBrowsingResourceThrottleFactory* g_factory = nullptr;
25 } // namespace
27 // static
28 void SafeBrowsingResourceThrottleFactory::RegisterFactory(
29 SafeBrowsingResourceThrottleFactory* factory) {
30 g_factory = factory;
33 // static
34 ResourceThrottle* SafeBrowsingResourceThrottleFactory::Create(
35 net::URLRequest* request,
36 content::ResourceContext* resource_context,
37 content::ResourceType resource_type,
38 SafeBrowsingService* service) {
39 if (g_factory) {
40 return g_factory->CreateResourceThrottle(
41 request, resource_context, resource_type, service);
43 return CreateWithoutRegisteredFactory(request, resource_type, service);
46 ResourceThrottle*
47 SafeBrowsingResourceThrottleFactory::CreateWithoutRegisteredFactory(
48 net::URLRequest* request,
49 content::ResourceType resource_type,
50 SafeBrowsingService* service) {
51 #if defined(SAFE_BROWSING_DB_LOCAL)
52 // Throttle consults a local database before starting the resource request.
53 return new SafeBrowsingResourceThrottle(request, resource_type, service,
54 true /* defer_at_start */);
55 #elif defined(SAFE_BROWSING_DB_REMOTE)
56 // Throttle consults a remote database before processing the response.
57 return new SafeBrowsingResourceThrottle(request, resource_type, service,
58 false /* defer_at_start */);
59 #else
60 return nullptr;
61 #endif