All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WebIOConfig.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include <string>
6 
7 namespace Eegeo
8 {
9  namespace Web
10  {
11  const int WebLoadPoolSizeDefault = 10;
12  const int CacheLoadPoolSizeDefault = 40;
13  const int CacheStorePoolSizeDefault = 20;
14 
15  struct WebIOConfig
16  {
17  static WebIOConfig CreateDefaultUsingOperatingSystemCACert()
18  {
19  // if libcurl was compiled for a given platform's native SSL (e.g. iOS/darwinSSL),
20  // there's no need to provide a CA cert -- it will use the inbuilt OS cert.
21 
22  // http://curl.haxx.se/docs/sslcerts.html ("Certificate Verification with Schannel and Secure Transport")
23  const std::string UseOperatingSystemCACert = "";
24  return WebIOConfig(
25  WebLoadPoolSizeDefault, CacheLoadPoolSizeDefault, CacheStorePoolSizeDefault, UseOperatingSystemCACert);
26  }
27 
28  static WebIOConfig CreateDefaultUsingCustomCACert(const std::string& caCertFilePath)
29  {
30  return WebIOConfig(
31  WebLoadPoolSizeDefault, CacheLoadPoolSizeDefault, CacheStorePoolSizeDefault, caCertFilePath);
32  }
33 
35  const int webLoadPoolSize,
36  const int cacheLoadPoolSize,
37  const int cacheStorePoolSize,
38  const std::string& optionalCaCertFilePath)
39  : webLoadPoolSize(webLoadPoolSize),
40  cacheLoadPoolSize(cacheLoadPoolSize),
41  cacheStorePoolSize(cacheStorePoolSize),
42  caCertFilePath(optionalCaCertFilePath)
43  {
44 
45  }
46 
47  bool ShouldUseCACertFile() const
48  {
49  return !caCertFilePath.empty();
50  }
51 
52  int webLoadPoolSize;
53  int cacheLoadPoolSize;
54  int cacheStorePoolSize;
55 
56  std::string caCertFilePath;
57  };
58  }
59 }