Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / net / BUILD.gn
bloba77fac24fa3860f738cfa7149711ff6ecbde44ea
1 # Copyright (c) 2013 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 import("//build/config/crypto.gni")
6 import("//build/config/features.gni")
7 import("//build/config/ui.gni")
8 import("//tools/grit/grit_rule.gni")
9 import("//url/config.gni")
11 if (is_android) {
12   import("//build/config/android/config.gni")
13   import("//build/config/android/rules.gni")
14 } else if (is_mac) {
15   import("//build/config/mac/mac_sdk.gni")
18 # The list of net files is kept in net.gypi. Read it.
19 gypi_values = exec_script(
20     "//build/gypi_to_gn.py",
21     [ rebase_path("net.gypi") ],
22     "scope",
23     [ "net.gypi" ])
25 # Disable Kerberos on ChromeOS, Android and iOS, at least for now. It needs
26 # configuration (krb5.conf and so on).
27 use_kerberos = !is_chromeos && !is_android && !is_ios
29 # The way the cache uses mmap() is inefficient on some Android devices. If
30 # this flag is set, we hackily avoid using mmap() in the disk cache. We are
31 # pretty confident that mmap-ing the index would not hurt any existing x86
32 # android devices, but we cannot be so sure about the variety of ARM devices.
33 # So enable it for x86 only for now.
34 posix_avoid_mmap = is_android && cpu_arch != "x86"
36 # WebSockets and socket stream code are used everywhere except iOS.
37 enable_websockets = !is_ios
38 use_v8_in_net = !is_ios
39 enable_built_in_dns = !is_ios
40 disable_ftp_support = is_ios
42 declare_args() {
43   # Disables support for file URLs.  File URL support requires use of icu.
44   disable_file_support = false
47 config("net_config") {
48   defines = []
49   if (posix_avoid_mmap) {
50     defines += [ "POSIX_AVOID_MMAP" ]
51   }
52   if (disable_file_support) {
53     defines += [ "DISABLE_FILE_SUPPORT" ]
54   }
57 # Disables Windows warning about size to int truncations.
58 # TODO(jschuh): crbug.com/167187 fix this and delete this config.
59 config("net_win_size_truncation") {
60   if (is_win) {
61     cflags = [ "/wd4267" ]
62   }
65 component("net") {
66   sources =
67     gypi_values.net_nacl_common_sources +
68     gypi_values.net_non_nacl_sources
70   cflags = []
71   defines = [
72     # TODO(GYP) Note that he GYP file supports linux_link_kerberos (defaults to
73     # 0) which implies that we run pkg_config on kerberos and link to that
74     # rather than setting this define which will dynamically open it. That
75     # doesn't seem to be set in the regular builds, so we're skipping this
76     # capability here.
77     "DLOPEN_KERBEROS",
78     "NET_IMPLEMENTATION"
79   ]
80   configs += [ ":net_win_size_truncation" ]
81   direct_dependent_configs = [ ":net_config" ]
82   include_dirs = []
84   deps = [
85    ":net_resources",
86     "//base",
87     "//base:i18n",
88     "//base:prefs",
89     "//base/third_party/dynamic_annotations",
90     "//crypto",
91     "//crypto:platform",
92     "//net/base/registry_controlled_domains",
93     "//sdch",
94     "//third_party/icu",
95     "//third_party/zlib",
96     "//url",
97   ]
98   forward_dependent_configs_from = [
99     "//crypto",
100     "//crypto:platform"
101   ]
103   if (use_kerberos) {
104     defines += [ "USE_KERBEROS" ]
105     if (is_android) {
106       include_dirs += [ "/usr/include/kerberosV" ]
107     }
108   } else {
109     sources -= [
110       "http/http_auth_gssapi_posix.cc",
111       "http/http_auth_gssapi_posix.h",
112       "http/http_auth_handler_negotiate.h",
113       "http/http_auth_handler_negotiate.cc",
114     ]
115   }
117   if (is_posix) {
118     if (posix_avoid_mmap) {
119       sources -= [ "disk_cache/blockfile/mapped_file_posix.cc" ]
120     } else {
121       sources -= [ "disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc" ]
122     }
123   }
125   if (disable_file_support) {
126     sources -= [
127       "base/directory_lister.cc",
128       "base/directory_lister.h",
129       "url_request/url_request_file_dir_job.cc",
130       "url_request/url_request_file_dir_job.h",
131       "url_request/url_request_file_job.cc",
132       "url_request/url_request_file_job.h",
133       "url_request/file_protocol_handler.cc",
134       "url_request/file_protocol_handler.h",
135     ]
136   }
138   if (disable_ftp_support) {
139     sources -= [
140       "ftp/ftp_auth_cache.cc",
141       "ftp/ftp_auth_cache.h",
142       "ftp/ftp_ctrl_response_buffer.cc",
143       "ftp/ftp_ctrl_response_buffer.h",
144       "ftp/ftp_directory_listing_parser.cc",
145       "ftp/ftp_directory_listing_parser.h",
146       "ftp/ftp_directory_listing_parser_ls.cc",
147       "ftp/ftp_directory_listing_parser_ls.h",
148       "ftp/ftp_directory_listing_parser_netware.cc",
149       "ftp/ftp_directory_listing_parser_netware.h",
150       "ftp/ftp_directory_listing_parser_os2.cc",
151       "ftp/ftp_directory_listing_parser_os2.h",
152       "ftp/ftp_directory_listing_parser_vms.cc",
153       "ftp/ftp_directory_listing_parser_vms.h",
154       "ftp/ftp_directory_listing_parser_windows.cc",
155       "ftp/ftp_directory_listing_parser_windows.h",
156       "ftp/ftp_network_layer.cc",
157       "ftp/ftp_network_layer.h",
158       "ftp/ftp_network_session.cc",
159       "ftp/ftp_network_session.h",
160       "ftp/ftp_network_transaction.cc",
161       "ftp/ftp_network_transaction.h",
162       "ftp/ftp_request_info.h",
163       "ftp/ftp_response_info.cc",
164       "ftp/ftp_response_info.h",
165       "ftp/ftp_server_type_histograms.cc",
166       "ftp/ftp_server_type_histograms.h",
167       "ftp/ftp_transaction.h",
168       "ftp/ftp_transaction_factory.h",
169       "ftp/ftp_util.cc",
170       "ftp/ftp_util.h",
171       "url_request/ftp_protocol_handler.cc",
172       "url_request/ftp_protocol_handler.h",
173       "url_request/url_request_ftp_job.cc",
174       "url_request/url_request_ftp_job.h",
175     ]
176   }
178   if (enable_built_in_dns) {
179     defines += [ "ENABLE_BUILT_IN_DNS" ]
180   } else {
181     sources -= [
182       "dns/address_sorter_posix.cc",
183       "dns/address_sorter_posix.h",
184       "dns/dns_client.cc",
185     ]
186   }
188   if (use_openssl) {
189     sources -= [
190       "base/nss_memio.c",
191       "base/nss_memio.h",
192       "cert/ct_log_verifier_nss.cc",
193       "cert/ct_objects_extractor_nss.cc",
194       "cert/jwk_serializer_nss.cc",
195       "cert/scoped_nss_types.h",
196       "cert/x509_util_nss.cc",
197       "cert/x509_util_nss.h",
198       "quic/crypto/aead_base_decrypter_nss.cc",
199       "quic/crypto/aead_base_encrypter_nss.cc",
200       "quic/crypto/aes_128_gcm_12_decrypter_nss.cc",
201       "quic/crypto/aes_128_gcm_12_encrypter_nss.cc",
202       "quic/crypto/chacha20_poly1305_decrypter_nss.cc",
203       "quic/crypto/chacha20_poly1305_encrypter_nss.cc",
204       "quic/crypto/channel_id_nss.cc",
205       "quic/crypto/p256_key_exchange_nss.cc",
206       "socket/nss_ssl_util.cc",
207       "socket/nss_ssl_util.h",
208       "socket/ssl_client_socket_nss.cc",
209       "socket/ssl_client_socket_nss.h",
210       "socket/ssl_server_socket_nss.cc",
211       "socket/ssl_server_socket_nss.h",
212     ]
213     if (is_chromeos) {
214       sources -= [
215         "cert/nss_cert_database_chromeos.cc",
216         "cert/nss_cert_database_chromeos.h",
217         "cert/nss_profile_filter_chromeos.cc",
218         "cert/nss_profile_filter_chromeos.h",
219       ]
220     }
221     if (is_linux) {
222       # These are always removed for non-Linux cases below.
223       sources -= [
224         "base/crypto_module_nss.cc",
225         "base/keygen_handler_nss.cc",
226         "cert/cert_database_nss.cc",
227         "cert/nss_cert_database.cc",
228         "cert/nss_cert_database.h",
229         "cert/x509_certificate_nss.cc",
230         "third_party/mozilla_security_manager/nsKeygenHandler.cpp",
231         "third_party/mozilla_security_manager/nsKeygenHandler.h",
232         "third_party/mozilla_security_manager/nsNSSCertificateDB.cpp",
233         "third_party/mozilla_security_manager/nsNSSCertificateDB.h",
234         "third_party/mozilla_security_manager/nsPKCS12Blob.cpp",
235         "third_party/mozilla_security_manager/nsPKCS12Blob.h",
236       ]
237     }
238     if (is_ios) {
239       # Always removed for !ios below.
240       sources -= [
241         "cert/cert_verify_proc_nss.cc",
242         "cert/cert_verify_proc_nss.h",
243         "cert/test_root_certs_nss.cc",
244         "ocsp/nss_ocsp.cc",
245         "ocsp/nss_ocsp.h",
246       ]
247     }
248   } else {
249     sources -= [
250       "base/crypto_module_openssl.cc",
251       "base/keygen_handler_openssl.cc",
252       "cert/ct_log_verifier_openssl.cc",
253       "cert/ct_objects_extractor_openssl.cc",
254       "cert/jwk_serializer_openssl.cc",
255       "cert/x509_util_openssl.cc",
256       "cert/x509_util_openssl.h",
257       "quic/crypto/aead_base_decrypter_openssl.cc",
258       "quic/crypto/aead_base_encrypter_openssl.cc",
259       "quic/crypto/aes_128_gcm_12_decrypter_openssl.cc",
260       "quic/crypto/aes_128_gcm_12_encrypter_openssl.cc",
261       "quic/crypto/chacha20_poly1305_decrypter_openssl.cc",
262       "quic/crypto/chacha20_poly1305_encrypter_openssl.cc",
263       "quic/crypto/channel_id_openssl.cc",
264       "quic/crypto/p256_key_exchange_openssl.cc",
265       "quic/crypto/scoped_evp_aead_ctx.cc",
266       "quic/crypto/scoped_evp_aead_ctx.h",
267       "socket/openssl_ssl_util.cc",
268       "socket/openssl_ssl_util.h",
269       "socket/ssl_client_socket_openssl.cc",
270       "socket/ssl_client_socket_openssl.h",
271       "socket/ssl_server_socket_openssl.cc",
272       "socket/ssl_server_socket_openssl.h",
273       "socket/ssl_session_cache_openssl.cc",
274       "socket/ssl_session_cache_openssl.h",
275     ]
276   }
278   if (!use_openssl_certs) {
279     sources -= [
280       "base/openssl_private_key_store.h",
281       "base/openssl_private_key_store_memory.cc",
282       "cert/cert_database_openssl.cc",
283       "cert/cert_verify_proc_openssl.cc",
284       "cert/cert_verify_proc_openssl.h",
285       "cert/test_root_certs_openssl.cc",
286       "cert/x509_certificate_openssl.cc",
287       "ssl/openssl_client_key_store.cc",
288       "ssl/openssl_client_key_store.h",
289     ]
290     if (is_android) {
291       sources -= [
292         "base/openssl_private_key_store_android.cc",
293       ]
294     }
295   } else if (is_android) {
296     # Android doesn't use these even when using OpenSSL.
297     sources -= [
298       "base/openssl_private_key_store_memory.cc",
299       "cert/cert_database_openssl.cc",
300       "cert/cert_verify_proc_openssl.cc",
301       "cert/test_root_certs_openssl.cc",
302     ]
303   }
305   if (use_glib) {
306     configs += [ "//build/config/linux:gconf" ]
307     deps += [ "//build/config/linux:gio" ]
308   }
310   if (is_linux) {
311     configs += [ "//build/config/linux:libresolv" ]
312   } else {
313     sources -= [
314       "base/crypto_module_nss.cc",
315       "base/keygen_handler_nss.cc",
316       "cert/cert_database_nss.cc",
317       "cert/nss_cert_database.cc",
318       "cert/nss_cert_database.h",
319       "cert/x509_certificate_nss.cc",
320       "third_party/mozilla_security_manager/nsKeygenHandler.cpp",
321       "third_party/mozilla_security_manager/nsKeygenHandler.h",
322       "third_party/mozilla_security_manager/nsNSSCertificateDB.cpp",
323       "third_party/mozilla_security_manager/nsNSSCertificateDB.h",
324       "third_party/mozilla_security_manager/nsPKCS12Blob.cpp",
325       "third_party/mozilla_security_manager/nsPKCS12Blob.h",
326     ]
328     if (!is_ios) {
329       # These files are part of the partial implementation of NSS on iOS so
330       # keep them in that case.
331       sources -= [
332         "cert/test_root_certs_nss.cc",
333         "ocsp/nss_ocsp.cc",
334         "ocsp/nss_ocsp.h",
335       ]
336     }
337   }
339   if (!use_nss_certs) {
340     sources -= [
341       "ssl/client_cert_store_nss.cc",
342       "ssl/client_cert_store_nss.h",
343     ]
344     if (!is_ios) {
345       # These files are part of the partial implementation of NSS on iOS so
346       # keep them in that case (even though use_nss_certs is not set).
347       sources -= [
348         "cert/cert_verify_proc_nss.cc",
349         "cert/cert_verify_proc_nss.h",
350       ]
351     }
352     if (is_chromeos) {
353       # These were already removed on non-ChromeOS.
354       sources -= [
355         "ssl/client_cert_store_chromeos.cc",
356         "ssl/client_cert_store_chromeos.h",
357       ]
358     }
359   }
361   if (!enable_websockets) {
362     sources -= [
363       "socket_stream/socket_stream.cc",
364       "socket_stream/socket_stream.h",
365       "socket_stream/socket_stream_job.cc",
366       "socket_stream/socket_stream_job.h",
367       "socket_stream/socket_stream_job_manager.cc",
368       "socket_stream/socket_stream_job_manager.h",
369       "socket_stream/socket_stream_metrics.cc",
370       "socket_stream/socket_stream_metrics.h",
371       "spdy/spdy_websocket_stream.cc",
372       "spdy/spdy_websocket_stream.h",
373       "websockets/websocket_basic_handshake_stream.cc",
374       "websockets/websocket_basic_handshake_stream.h",
375       "websockets/websocket_basic_stream.cc",
376       "websockets/websocket_basic_stream.h",
377       "websockets/websocket_channel.cc",
378       "websockets/websocket_channel.h",
379       "websockets/websocket_deflate_predictor.h",
380       "websockets/websocket_deflate_predictor_impl.cc",
381       "websockets/websocket_deflate_predictor_impl.h",
382       "websockets/websocket_deflate_stream.cc",
383       "websockets/websocket_deflate_stream.h",
384       "websockets/websocket_deflater.cc",
385       "websockets/websocket_deflater.h",
386       "websockets/websocket_errors.cc",
387       "websockets/websocket_errors.h",
388       "websockets/websocket_extension.cc",
389       "websockets/websocket_extension.h",
390       "websockets/websocket_extension_parser.cc",
391       "websockets/websocket_extension_parser.h",
392       "websockets/websocket_frame.cc",
393       "websockets/websocket_frame.h",
394       "websockets/websocket_frame_parser.cc",
395       "websockets/websocket_frame_parser.h",
396       "websockets/websocket_handshake_constants.cc",
397       "websockets/websocket_handshake_constants.h",
398       "websockets/websocket_handshake_handler.cc",
399       "websockets/websocket_handshake_handler.h",
400       "websockets/websocket_handshake_request_info.cc",
401       "websockets/websocket_handshake_request_info.h",
402       "websockets/websocket_handshake_response_info.cc",
403       "websockets/websocket_handshake_response_info.h",
404       "websockets/websocket_handshake_stream_base.h",
405       "websockets/websocket_handshake_stream_create_helper.cc",
406       "websockets/websocket_handshake_stream_create_helper.h",
407       "websockets/websocket_inflater.cc",
408       "websockets/websocket_inflater.h",
409       "websockets/websocket_job.cc",
410       "websockets/websocket_job.h",
411       "websockets/websocket_mux.h",
412       "websockets/websocket_net_log_params.cc",
413       "websockets/websocket_net_log_params.h",
414       "websockets/websocket_stream.cc",
415       "websockets/websocket_stream.h",
416       "websockets/websocket_throttle.cc",
417       "websockets/websocket_throttle.h",
418     ]
419   }
421   if (!enable_mdns) {
422     sources -= [
423       "dns/mdns_cache.cc",
424       "dns/mdns_cache.h",
425       "dns/mdns_client.cc",
426       "dns/mdns_client.h",
427       "dns/mdns_client_impl.cc",
428       "dns/mdns_client_impl.h",
429       "dns/record_parsed.cc",
430       "dns/record_parsed.h",
431       "dns/record_rdata.cc",
432       "dns/record_rdata.h",
433     ]
434   }
436   if (is_win) {
437     sources -= [
438       "http/http_auth_handler_ntlm_portable.cc",
439       "socket/socket_libevent.cc",
440       "socket/socket_libevent.h",
441       "socket/tcp_socket_libevent.cc",
442       "socket/tcp_socket_libevent.h",
443       "udp/udp_socket_libevent.cc",
444       "udp/udp_socket_libevent.h",
445     ]
446     deps += [
447       "//third_party/nss:nspr",
448       "//third_party/nss",
449     ]
450   } else {  # !is_win
451     sources -= [
452       "base/winsock_init.cc",
453       "base/winsock_init.h",
454       "base/winsock_util.cc",
455       "base/winsock_util.h",
456       "proxy/proxy_resolver_winhttp.cc",
457       "proxy/proxy_resolver_winhttp.h",
458     ]
459   }
461   if (is_mac) {
462     deps += [
463       "//third_party/nss:nspr",
464       "//third_party/nss",
465     ]
466     libs = [
467       "Foundation.framework",
468       "Security.framework",
469       "SystemConfiguration.framework",
470       "resolv",
471     ]
472   }
474   if (is_ios) {
475     # Add back some sources that were otherwise filtered out. iOS additionally
476     # doesn't set USE_NSS but needs some of the files.
477     set_sources_assignment_filter([])
478     sources += [
479       "base/network_change_notifier_mac.cc",
480       "base/network_config_watcher_mac.cc",
481       "base/platform_mime_util_mac.mm",
482       "cert/cert_verify_proc_nss.cc",
483       "cert/cert_verify_proc_nss.h",
484       "cert/test_root_certs_nss.cc",
485       "cert/x509_util_nss.cc",
486       "cert/x509_util_nss.h",
487       "proxy/proxy_resolver_mac.cc",
488       "proxy/proxy_server_mac.cc",
489       "ocsp/nss_ocsp.cc",
490       "ocsp/nss_ocsp.h",
491     ]
492     set_sources_assignment_filter(sources_assignment_filter)
494     sources -= [ "disk_cache/blockfile/file_posix.cc" ]
495     deps += [
496       "//third_party/nss",
497     ]
498     libs = [
499       "CFNetwork.framework",
500       "MobileCoreServices.framework",
501       "Security.framework",
502       "SystemConfiguration.framework",
503       "resolv",
504     ]
505   }
507   if (is_android) {
508     # Add some Linux sources that were excluded by the filter, but which
509     # are needed.
510     set_sources_assignment_filter([])
511     sources += [
512       "base/platform_mime_util_linux.cc",
513       "base/address_tracker_linux.cc",
514       "base/address_tracker_linux.h",
515     ]
516     set_sources_assignment_filter(sources_assignment_filter)
518     if (!is_android_webview_build) {
519       deps += [ ":net_jni_headers" ]
521       # The net/android/keystore_openssl.cc source file needs to access an
522       # OpenSSL-internal header.
523       include_dirs = [ "//third_party/openssl" ]
524     }
525   }
527   if (use_icu_alternatives_on_android) {
528     deps -= [
529       "//base:i18n",
530       "//third_party/icu",
531     ]
532     sources -= [
533       "base/filename_util_icu.cc",
534       "base/net_string_util_icu.cc",
535       "base/net_util_icu.cc",
536     ]
537     sources += [
538       "base/net_string_util_icu_alternatives_android.cc",
539       "base/net_string_util_icu_alternatives_android.h",
540     ]
541   }
544 grit("net_resources") {
545   source = "base/net_resources.grd"
548 static_library("http_server") {
549   sources = [
550     "server/http_connection.cc",
551     "server/http_connection.h",
552     "server/http_server.cc",
553     "server/http_server.h",
554     "server/http_server_request_info.cc",
555     "server/http_server_request_info.h",
556     "server/http_server_response_info.cc",
557     "server/http_server_response_info.h",
558     "server/web_socket.cc",
559     "server/web_socket.h",
560   ]
561   configs += [ "//build/config/compiler:wexit_time_destructors" ]
562   deps = [
563     ":net",
564     "//base",
565   ]
568 executable("dump_cache") {
569   sources = [
570     "tools/dump_cache/cache_dumper.cc",
571     "tools/dump_cache/cache_dumper.h",
572     "tools/dump_cache/dump_cache.cc",
573     "tools/dump_cache/dump_files.cc",
574     "tools/dump_cache/dump_files.h",
575     "tools/dump_cache/simple_cache_dumper.cc",
576     "tools/dump_cache/simple_cache_dumper.h",
577     "tools/dump_cache/upgrade_win.cc",
578     "tools/dump_cache/upgrade_win.h",
579     "tools/dump_cache/url_to_filename_encoder.cc",
580     "tools/dump_cache/url_to_filename_encoder.h",
581     "tools/dump_cache/url_utilities.h",
582     "tools/dump_cache/url_utilities.cc",
583   ]
585   configs += [ ":net_win_size_truncation" ]
587   deps = [
588     "//base",
589     ":net",
590     ":test_support",
591   ]
594 source_set("test_support") {
595   sources = [
596     "base/capturing_net_log.cc",
597     "base/capturing_net_log.h",
598     "base/load_timing_info_test_util.cc",
599     "base/load_timing_info_test_util.h",
600     "base/mock_file_stream.cc",
601     "base/mock_file_stream.h",
602     "base/test_completion_callback.cc",
603     "base/test_completion_callback.h",
604     "base/test_data_directory.cc",
605     "base/test_data_directory.h",
606     "cert/mock_cert_verifier.cc",
607     "cert/mock_cert_verifier.h",
608     "cookies/cookie_monster_store_test.cc",
609     "cookies/cookie_monster_store_test.h",
610     "cookies/cookie_store_test_callbacks.cc",
611     "cookies/cookie_store_test_callbacks.h",
612     "cookies/cookie_store_test_helpers.cc",
613     "cookies/cookie_store_test_helpers.h",
614     "disk_cache/disk_cache_test_base.cc",
615     "disk_cache/disk_cache_test_base.h",
616     "disk_cache/disk_cache_test_util.cc",
617     "disk_cache/disk_cache_test_util.h",
618     "dns/dns_test_util.cc",
619     "dns/dns_test_util.h",
620     "dns/mock_host_resolver.cc",
621     "dns/mock_host_resolver.h",
622     "dns/mock_mdns_socket_factory.cc",
623     "dns/mock_mdns_socket_factory.h",
624     "http/http_transaction_test_util.cc",
625     "http/http_transaction_test_util.h",
626     "proxy/mock_proxy_resolver.cc",
627     "proxy/mock_proxy_resolver.h",
628     "proxy/mock_proxy_script_fetcher.cc",
629     "proxy/mock_proxy_script_fetcher.h",
630     "proxy/proxy_config_service_common_unittest.cc",
631     "proxy/proxy_config_service_common_unittest.h",
632     "socket/socket_test_util.cc",
633     "socket/socket_test_util.h",
634     "test/cert_test_util.cc",
635     "test/cert_test_util.h",
636     "test/ct_test_util.cc",
637     "test/ct_test_util.h",
638     "test/embedded_test_server/embedded_test_server.cc",
639     "test/embedded_test_server/embedded_test_server.h",
640     "test/embedded_test_server/http_connection.cc",
641     "test/embedded_test_server/http_connection.h",
642     "test/embedded_test_server/http_request.cc",
643     "test/embedded_test_server/http_request.h",
644     "test/embedded_test_server/http_response.cc",
645     "test/embedded_test_server/http_response.h",
646     "test/net_test_suite.cc",
647     "test/net_test_suite.h",
648     "test/python_utils.cc",
649     "test/python_utils.h",
650     "test/spawned_test_server/base_test_server.cc",
651     "test/spawned_test_server/base_test_server.h",
652     "test/spawned_test_server/local_test_server_posix.cc",
653     "test/spawned_test_server/local_test_server_win.cc",
654     "test/spawned_test_server/local_test_server.cc",
655     "test/spawned_test_server/local_test_server.h",
656     "test/spawned_test_server/remote_test_server.cc",
657     "test/spawned_test_server/remote_test_server.h",
658     "test/spawned_test_server/spawned_test_server.h",
659     "test/spawned_test_server/spawner_communicator.cc",
660     "test/spawned_test_server/spawner_communicator.h",
661     "url_request/test_url_fetcher_factory.cc",
662     "url_request/test_url_fetcher_factory.h",
663     "url_request/url_request_test_util.cc",
664     "url_request/url_request_test_util.h",
665   ]
667   configs += [ ":net_win_size_truncation" ]
669   deps = [
670     "//base",
671     "//base/test:test_support",
672     "//crypto:platform",
673     "//net",
674     "//net/tools/tld_cleanup",
675     "//testing/gmock",
676     "//testing/gtest",
677     "//url",
678   ]
680   if (is_ios) {
681     deps += [ "//third_party/nss" ]
682   }
684   if (!is_android) {
685     sources -= [
686       "test/spawned_test_server/remote_test_server.cc",
687       "test/spawned_test_server/remote_test_server.h",
688       "test/spawned_test_server/spawner_communicator.cc",
689       "test/spawned_test_server/spawner_communicator.h",
690     ]
691   }
693   if (use_v8_in_net) {
694     deps += [ ":net_with_v8" ]
695   }
697   if (!enable_mdns) {
698     sources -= [
699       "dns/mock_mdns_socket_factory.cc",
700       "dns/mock_mdns_socket_factory.h",
701     ]
702   }
704   forward_dependent_configs_from = deps
707 source_set("balsa") {
708   sources = [
709     "tools/balsa/balsa_enums.h",
710     "tools/balsa/balsa_frame.cc",
711     "tools/balsa/balsa_frame.h",
712     "tools/balsa/balsa_headers.cc",
713     "tools/balsa/balsa_headers.h",
714     "tools/balsa/balsa_headers_token_utils.cc",
715     "tools/balsa/balsa_headers_token_utils.h",
716     "tools/balsa/balsa_visitor_interface.h",
717     "tools/balsa/http_message_constants.cc",
718     "tools/balsa/http_message_constants.h",
719     "tools/balsa/noop_balsa_visitor.h",
720     "tools/balsa/simple_buffer.cc",
721     "tools/balsa/simple_buffer.h",
722     "tools/balsa/split.cc",
723     "tools/balsa/split.h",
724     "tools/balsa/string_piece_utils.h",
725     "tools/quic/spdy_utils.cc",
726     "tools/quic/spdy_utils.h",
727   ]
728   deps = [
729     ":net",
730     "//base",
731   ]
734 if (use_v8_in_net) {
735   component("net_with_v8") {
736     sources = [
737       "proxy/proxy_resolver_v8.cc",
738       "proxy/proxy_resolver_v8.h",
739       "proxy/proxy_resolver_v8_tracing.cc",
740       "proxy/proxy_resolver_v8_tracing.h",
741       "proxy/proxy_service_v8.cc",
742       "proxy/proxy_service_v8.h",
743     ]
745     defines = [ "NET_IMPLEMENTATION" ]
746     configs += [
747       ":net_win_size_truncation",
748       "//build/config/compiler:wexit_time_destructors",
749     ]
751     deps = [
752       ":net",
753       "//base",
754       "//gin",
755       "//url",
756       "//v8",
757     ]
759     forward_dependent_configs_from = [ ":net" ]
760   }
763 if (!is_ios && !is_android) {
764   executable("crash_cache") {
765     sources = [ "tools/crash_cache/crash_cache.cc" ]
766     configs += [ ":net_win_size_truncation" ]
767     deps = [
768       ":net",
769       ":test_support",
770       "//base",
771     ]
772   }
774   executable("crl_set_dump") {
775     sources = [ "tools/crl_set_dump/crl_set_dump.cc" ]
776     configs += [ ":net_win_size_truncation" ]
777     deps = [
778       ":net",
779       "//base",
780     ]
781   }
783   executable("dns_fuzz_stub") {
784     sources = [ "tools/dns_fuzz_stub/dns_fuzz_stub.cc" ]
785     configs += [ ":net_win_size_truncation" ]
786     deps = [
787       ":net",
788       "//base",
789     ]
790   }
792   executable("gdig") {
793     sources = [
794       "tools/gdig/file_net_log.cc",
795       "tools/gdig/gdig.cc",
796     ]
797     deps = [
798       ":net",
799       "//base",
800     ]
801   }
803   executable("get_server_time") {
804     sources = [ "tools/get_server_time/get_server_time.cc" ]
805     configs += [ ":net_win_size_truncation" ]
806     deps = [
807       ":net",
808       "//base",
809       "//base:i18n",
810       "//url",
811     ]
812   }
814   if (use_v8_in_net) {
815     executable("net_watcher") {
816       sources = [ "tools/net_watcher/net_watcher.cc" ]
817       deps = [
818         ":net",
819         ":net_with_v8",
820         "//base",
821       ]
823       if (is_linux) {
824         configs += [ "//build/config/linux:gconf" ]
825         deps += [ "//build/config/linux:gio" ]
826       }
827     }
828   }
830   executable("run_testserver") {
831     sources = [ "tools/testserver/run_testserver.cc" ]
832     deps = [
833       ":net",  # TODO(brettw) bug 363749: this shouldn't be necessary. It's not
834                # in the GYP build, and can be removed when the bug is fixed.
835       ":test_support",
836       "//base",
837       "//base/test:test_support",
838       "//testing/gtest",
839     ]
840   }
842   executable("stress_cache") {
843     sources = [ "disk_cache/blockfile/stress_cache.cc" ]
844     configs += [ ":net_win_size_truncation" ]
845     deps = [
846       ":net",
847       ":test_support",
848       "//base",
849     ]
850   }
852   executable("tld_cleanup") {
853     sources = [ "tools/tld_cleanup/tld_cleanup.cc" ]
854     configs += [ ":net_win_size_truncation" ]
855     deps = [
856       "//base",
857       "//base:i18n",
858       "//net/tools/tld_cleanup",
859     ]
860   }
863 if (is_linux) {
864   static_library("epoll_server") {
865     sources = [
866       "tools/epoll_server/epoll_server.cc",
867       "tools/epoll_server/epoll_server.h",
868     ]
869     deps = [
870       ":net",
871       "//base",
872     ]
873   }
875   static_library("flip_in_mem_edsm_server_base") {
876     sources = [
877       "tools/dump_cache/url_to_filename_encoder.cc",
878       "tools/dump_cache/url_to_filename_encoder.h",
879       "tools/dump_cache/url_utilities.h",
880       "tools/dump_cache/url_utilities.cc",
881       "tools/flip_server/acceptor_thread.h",
882       "tools/flip_server/acceptor_thread.cc",
883       "tools/flip_server/create_listener.cc",
884       "tools/flip_server/create_listener.h",
885       "tools/flip_server/constants.h",
886       "tools/flip_server/flip_config.cc",
887       "tools/flip_server/flip_config.h",
888       "tools/flip_server/http_interface.cc",
889       "tools/flip_server/http_interface.h",
890       "tools/flip_server/loadtime_measurement.h",
891       "tools/flip_server/mem_cache.h",
892       "tools/flip_server/mem_cache.cc",
893       "tools/flip_server/output_ordering.cc",
894       "tools/flip_server/output_ordering.h",
895       "tools/flip_server/ring_buffer.cc",
896       "tools/flip_server/ring_buffer.h",
897       "tools/flip_server/sm_connection.cc",
898       "tools/flip_server/sm_connection.h",
899       "tools/flip_server/sm_interface.h",
900       "tools/flip_server/spdy_ssl.cc",
901       "tools/flip_server/spdy_ssl.h",
902       "tools/flip_server/spdy_interface.cc",
903       "tools/flip_server/spdy_interface.h",
904       "tools/flip_server/spdy_util.cc",
905       "tools/flip_server/spdy_util.h",
906       "tools/flip_server/streamer_interface.cc",
907       "tools/flip_server/streamer_interface.h",
908     ]
909     deps = [
910       ":balsa",
911       ":epoll_server",
912       ":net",
913       "//base",
914       "//third_party/openssl",
915     ]
916   }
918   executable("flip_in_mem_edsm_server_unittests") {
919     sources = [
920       "tools/flip_server/flip_test_utils.cc",
921       "tools/flip_server/flip_test_utils.h",
922       "tools/flip_server/http_interface_test.cc",
923       "tools/flip_server/mem_cache_test.cc",
924       "tools/flip_server/run_all_tests.cc",
925       "tools/flip_server/spdy_interface_test.cc",
926     ]
927     deps = [
928       ":flip_in_mem_edsm_server_base",
929       ":net",
930       ":test_support",
931       "//testing/gtest",
932       "//testing/gmock",
933       "//third_party/openssl",
934     ]
935   }
937   executable("flip_in_mem_edsm_server") {
938     sources = [ "tools/flip_server/flip_in_mem_edsm_server.cc" ]
939     deps = [
940       ":flip_in_mem_edsm_server_base",
941       ":net",
942       "//base",
943     ]
944   }
946   source_set("quic_base") {
947     sources = [
948       "tools/quic/quic_client.cc",
949       "tools/quic/quic_client.h",
950       "tools/quic/quic_client_session.cc",
951       "tools/quic/quic_client_session.h",
952       "tools/quic/quic_default_packet_writer.cc",
953       "tools/quic/quic_default_packet_writer.h",
954       "tools/quic/quic_dispatcher.h",
955       "tools/quic/quic_dispatcher.cc",
956       "tools/quic/quic_epoll_clock.cc",
957       "tools/quic/quic_epoll_clock.h",
958       "tools/quic/quic_epoll_connection_helper.cc",
959       "tools/quic/quic_epoll_connection_helper.h",
960       "tools/quic/quic_in_memory_cache.cc",
961       "tools/quic/quic_in_memory_cache.h",
962       "tools/quic/quic_packet_writer_wrapper.cc",
963       "tools/quic/quic_packet_writer_wrapper.h",
964       "tools/quic/quic_server.cc",
965       "tools/quic/quic_server.h",
966       "tools/quic/quic_server_session.cc",
967       "tools/quic/quic_server_session.h",
968       "tools/quic/quic_socket_utils.cc",
969       "tools/quic/quic_socket_utils.h",
970       "tools/quic/quic_spdy_client_stream.cc",
971       "tools/quic/quic_spdy_client_stream.h",
972       "tools/quic/quic_spdy_server_stream.cc",
973       "tools/quic/quic_spdy_server_stream.h",
974       "tools/quic/quic_time_wait_list_manager.h",
975       "tools/quic/quic_time_wait_list_manager.cc",
976     ]
977     deps = [
978       ":balsa",
979       ":epoll_server",
980       ":net",
981       "//base",
982       "//base/third_party/dynamic_annotations",
983       "//crypto",
984       "//third_party/openssl",
985       "//url",
986     ]
987   }
989   executable("quic_client") {
990     sources = [ "tools/quic/quic_client_bin.cc" ]
991     deps = [
992       ":quic_base",
993       ":net",
994       "//base",
995       "//third_party/openssl",
996     ]
997   }
1000 if (is_android) {
1001   generate_jni("net_jni_headers") {
1002     sources = [
1003       "android/java/src/org/chromium/net/AndroidCertVerifyResult.java",
1004       "android/java/src/org/chromium/net/AndroidKeyStore.java",
1005       "android/java/src/org/chromium/net/AndroidNetworkLibrary.java",
1006       "android/java/src/org/chromium/net/AndroidPrivateKey.java",
1007       "android/java/src/org/chromium/net/GURLUtils.java",
1008       "android/java/src/org/chromium/net/NetworkChangeNotifier.java",
1009       "android/java/src/org/chromium/net/ProxyChangeListener.java",
1010       "android/java/src/org/chromium/net/X509Util.java",
1011     ]
1012     jni_package = "net"
1013   }
1016 if (is_android || is_linux) {
1017   executable("disk_cache_memory_test") {
1018     sources = [ "tools/disk_cache_memory_test/disk_cache_memory_test.cc" ]
1019     deps = [
1020       ":net",
1021       "//base",
1022     ]
1023   }
1026 # TODO(GYP) make this compile on Android, we need some native test deps done.
1027 if (!is_android) {
1029 source_set("quic_tools") {
1030   sources = [
1031     "quic/quic_dispatcher.cc",
1032     "quic/quic_dispatcher.h",
1033     "quic/quic_in_memory_cache.cc",
1034     "quic/quic_in_memory_cache.h",
1035     "quic/quic_per_connection_packet_writer.cc",
1036     "quic/quic_per_connection_packet_writer.h",
1037     "quic/quic_server.cc",
1038     "quic/quic_server.h",
1039     "quic/quic_server_packet_writer.cc",
1040     "quic/quic_server_packet_writer.h",
1041     "quic/quic_server_session.cc",
1042     "quic/quic_server_session.h",
1043     "quic/quic_spdy_server_stream.cc",
1044     "quic/quic_spdy_server_stream.h",
1045     "quic/quic_time_wait_list_manager.cc",
1046     "quic/quic_time_wait_list_manager.h",
1047   ]
1048   deps = [
1049     ":net",
1050     "//base",
1051     "//base/third_party/dynamic_annotations",
1052     "//url",
1053   ]
1056 test("net_unittests") {
1057   sources = gypi_values.net_test_sources
1059   configs += [ ":net_win_size_truncation" ]
1060   defines = []
1062   deps = [
1063     ":http_server",
1064     ":net",
1065     ":quic_tools",
1066     ":test_support",
1067     "//base",
1068     "//base:i18n",
1069     "//base:prefs_test_support",
1070     "//base/allocator",
1071     "//base/third_party/dynamic_annotations",
1072     "//crypto",
1073     "//crypto:platform",
1074     "//net/base/registry_controlled_domains",
1075     "//testing/gmock",
1076     "//testing/gtest",
1077     "//third_party/zlib",
1078     "//url",
1079   ]
1081   if (is_linux) {
1082     sources += gypi_values.net_linux_test_sources
1083     deps += [
1084       ":balsa",
1085       ":epoll_server",
1086       ":flip_in_mem_edsm_server_base",
1087       ":quic_base",
1088     ]
1089   }
1091   if (is_chromeos) {
1092     sources -= [
1093       "base/network_change_notifier_linux_unittest.cc",
1094       "proxy/proxy_config_service_linux_unittest.cc",
1095     ]
1096   }
1098   if (is_android) {
1099     sources -= [
1100       # See bug http://crbug.com/344533.
1101       "disk_cache/blockfile/index_table_v3_unittest.cc",
1102       # No res_ninit() et al on Android, so this doesn't make a lot of
1103       # sense.
1104       "dns/dns_config_service_posix_unittest.cc",
1105     ]
1106     deps += [
1107       ":net_javatests",  # FIXME(brettw)
1108       ":net_test_jni_headers",
1109     ]
1110   }
1112   if (!use_nss_certs) {
1113     sources -= [
1114       "ssl/client_cert_store_nss_unittest.cc",
1115     ]
1116     if (is_chromeos) {  # Already removed for all non-ChromeOS builds.
1117       sources -= [
1118         "ssl/client_cert_store_chromeos_unittest.cc",
1119       ]
1120     }
1121   }
1123   if (use_openssl) {
1124     # When building for OpenSSL, we need to exclude NSS specific tests
1125     # or functionality not supported by OpenSSL yet.
1126     # TODO(bulach): Add equivalent tests when the underlying
1127     #               functionality is ported to OpenSSL.
1128     sources -= [
1129       "cert/ct_objects_extractor_unittest.cc",
1130       "cert/multi_log_ct_verifier_unittest.cc",
1131       "cert/nss_cert_database_unittest.cc",
1132       "cert/nss_cert_database_chromeos_unittest.cc",
1133       "cert/nss_profile_filter_chromeos_unittest.cc",
1134       "cert/x509_util_nss_unittest.cc",
1135       "quic/test_tools/crypto_test_utils_nss.cc",
1136     ]
1137   } else {
1138     sources -= [
1139       "cert/x509_util_openssl_unittest.cc",
1140       "quic/test_tools/crypto_test_utils_openssl.cc",
1141       "socket/ssl_client_socket_openssl_unittest.cc",
1142       "socket/ssl_session_cache_openssl_unittest.cc",
1143     ]
1144     if (!is_desktop_linux && !is_chromeos) {
1145       sources -= [ "cert/nss_cert_database_unittest.cc" ]
1146     }
1147   }
1149   if (use_kerberos) {
1150     defines += [ "USE_KERBEROS" ]
1151   } else {
1152     sources -= [
1153       "http/http_auth_gssapi_posix_unittest.cc",
1154       "http/http_auth_handler_negotiate_unittest.cc",
1155       "http/mock_gssapi_library_posix.cc",
1156       "http/mock_gssapi_library_posix.h",
1157     ]
1158   }
1160   if (use_openssl || (!is_desktop_linux && !is_chromeos && !is_ios)) {
1161     # Only include this test when on Posix and using NSS for
1162     # cert verification or on iOS (which also uses NSS for certs).
1163     sources -= [ "ocsp/nss_ocsp_unittest.cc" ]
1164   }
1166   if (!use_openssl_certs) {
1167     sources -= [ "ssl/openssl_client_key_store_unittest.cc" ]
1168   }
1170   if (!enable_websockets) {
1171     sources -= [
1172       "socket_stream/socket_stream_metrics_unittest.cc",
1173       "socket_stream/socket_stream_unittest.cc",
1174       "spdy/spdy_websocket_stream_unittest.cc",
1175       "websockets/websocket_basic_stream_test.cc",
1176       "websockets/websocket_channel_test.cc",
1177       "websockets/websocket_deflate_predictor_impl_test.cc",
1178       "websockets/websocket_deflate_stream_test.cc",
1179       "websockets/websocket_deflater_test.cc",
1180       "websockets/websocket_errors_test.cc",
1181       "websockets/websocket_extension_parser_test.cc",
1182       "websockets/websocket_frame_parser_test.cc",
1183       "websockets/websocket_frame_test.cc",
1184       "websockets/websocket_handshake_handler_spdy_test.cc",
1185       "websockets/websocket_handshake_handler_test.cc",
1186       "websockets/websocket_handshake_stream_create_helper_test.cc",
1187       "websockets/websocket_inflater_test.cc",
1188       "websockets/websocket_job_test.cc",
1189       "websockets/websocket_net_log_params_test.cc",
1190       "websockets/websocket_stream_test.cc",
1191       "websockets/websocket_test_util.cc",
1192       "websockets/websocket_test_util.h",
1193       "websockets/websocket_throttle_test.cc",
1194     ]
1195   }
1197   if (disable_file_support) {
1198     sources -= [
1199       "base/directory_lister_unittest.cc",
1200       "url_request/url_request_file_job_unittest.cc",
1201     ]
1202   }
1204   if (disable_ftp_support) {
1205     sources -= [
1206       "ftp/ftp_auth_cache_unittest.cc",
1207       "ftp/ftp_ctrl_response_buffer_unittest.cc",
1208       "ftp/ftp_directory_listing_parser_ls_unittest.cc",
1209       "ftp/ftp_directory_listing_parser_netware_unittest.cc",
1210       "ftp/ftp_directory_listing_parser_os2_unittest.cc",
1211       "ftp/ftp_directory_listing_parser_unittest.cc",
1212       "ftp/ftp_directory_listing_parser_unittest.h",
1213       "ftp/ftp_directory_listing_parser_vms_unittest.cc",
1214       "ftp/ftp_directory_listing_parser_windows_unittest.cc",
1215       "ftp/ftp_network_transaction_unittest.cc",
1216       "ftp/ftp_util_unittest.cc",
1217       "url_request/url_request_ftp_job_unittest.cc",
1218     ]
1219   }
1221   if (!enable_built_in_dns) {
1222     sources -= [
1223       "dns/address_sorter_posix_unittest.cc",
1224       "dns/address_sorter_unittest.cc",
1225     ]
1226   }
1228   # Always need use_v8_in_net to be 1 to run on Android, so just remove
1229   # net_unittest's dependency on v8 when using icu alternatives instead of
1230   # setting use_v8_in_net to 0.
1231   if (use_v8_in_net && !use_icu_alternatives_on_android) {
1232     deps += [ ":net_with_v8" ]
1233   } else {
1234     sources -= [
1235       "proxy/proxy_resolver_v8_unittest.cc",
1236       "proxy/proxy_resolver_v8_tracing_unittest.cc",
1237     ]
1238   }
1240   if (!enable_mdns) {
1241     sources -= [
1242       "dns/mdns_cache_unittest.cc",
1243       "dns/mdns_client_unittest.cc",
1244       "dns/record_parsed_unittest.cc",
1245       "dns/record_rdata_unittest.cc",
1246     ]
1247   }
1249   if (is_ios) {
1250     # TODO(GYP)
1251     #  'actions': [
1252     #    {
1253     #      'action_name': 'copy_test_data',
1254     #      'variables': {
1255     #        'test_data_files': [
1256     #          'data/ssl/certificates/',
1257     #          'data/test.html',
1258     #          'data/url_request_unittest/',
1259     #        ],
1260     #        'test_data_prefix': 'net',
1261     #      },
1262     #      'includes': [ '../build/copy_test_data_ios.gypi' ],
1263     #    },
1264     #  ],
1265     sources -= [
1266       # TODO(droger): The following tests are disabled because the
1267       # implementation is missing or incomplete.
1268       # KeygenHandler::GenKeyAndSignChallenge() is not ported to iOS.
1269       "base/keygen_handler_unittest.cc",
1270       "disk_cache/backend_unittest.cc",
1271       "disk_cache/blockfile/block_files_unittest.cc",
1272       # Need to read input data files.
1273       "filter/gzip_filter_unittest.cc",
1274       "socket/ssl_server_socket_unittest.cc",
1275       "spdy/fuzzing/hpack_fuzz_util_test.cc",
1276       # Need TestServer.
1277       "proxy/proxy_script_fetcher_impl_unittest.cc",
1278       "socket/ssl_client_socket_unittest.cc",
1279       "url_request/url_fetcher_impl_unittest.cc",
1280       "url_request/url_request_context_builder_unittest.cc",
1281       # Needs GetAppOutput().
1282       "test/python_utils_unittest.cc",
1284       # The following tests are disabled because they don't apply to
1285       # iOS.
1286       # OS is not "linux" or "freebsd" or "openbsd".
1287       "socket/unix_domain_socket_posix_unittest.cc",
1289       # See bug http://crbug.com/344533.
1290       "disk_cache/blockfile/index_table_v3_unittest.cc",
1291     ]
1292   }
1294   if (is_android) {
1295     sources -= [
1296       "dns/dns_config_service_posix_unittest.cc",
1297     ]
1298     # TODO(GYP)
1299     # # TODO(mmenke):  This depends on test_support_base, which depends on
1300     # #                icu.  Figure out a way to remove that dependency.
1301     # 'dependencies': [
1302     #   '../testing/android/native_test.gyp:native_test_native_code',
1303     # ]
1305     set_sources_assignment_filter([])
1306     sources += [ "base/address_tracker_linux_unittest.cc" ]
1307     set_sources_assignment_filter(sources_assignment_filter)
1308   }
1310   if (use_icu_alternatives_on_android) {
1311     sources -= [
1312       "base/filename_util_unittest.cc",
1313       "base/net_util_icu_unittest.cc",
1314     ]
1315     deps -= [ "//base:i18n" ]
1316   }
1319 executable("quic_server") {
1320   sources = [ "quic/quic_server_bin.cc" ]
1321   deps = [
1322     ":quic_tools",
1323     ":net",
1324     "//base",
1325     "//third_party/openssl",
1326   ]
1329 }  # !is_android