Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / net / proxy / proxy_service.h
index 1f77ad7..9fdcb58 100644 (file)
@@ -25,7 +25,6 @@
 class GURL;
 
 namespace base {
-class MessageLoop;
 class SingleThreadTaskRunner;
 class TimeDelta;
 }  // namespace base
@@ -124,16 +123,20 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   //
   // Profiling information for the request is saved to |net_log| if non-NULL.
   int ResolveProxy(const GURL& url,
+                   int load_flags,
                    ProxyInfo* results,
                    const net::CompletionCallback& callback,
                    PacRequest** pac_request,
+                   NetworkDelegate* network_delegate,
                    const BoundNetLog& net_log);
 
   // This method is called after a failure to connect or resolve a host name.
   // It gives the proxy service an opportunity to reconsider the proxy to use.
   // The |results| parameter contains the results returned by an earlier call
-  // to ResolveProxy.  The semantics of this call are otherwise similar to
-  // ResolveProxy.
+  // to ResolveProxy.  The |net_error| parameter contains the network error
+  // code associated with the failure. See "net/base/net_error_list.h" for a
+  // list of possible values. The semantics of this call are otherwise
+  // similar to ResolveProxy.
   //
   // NULL can be passed for |pac_request| if the caller will not need to
   // cancel the request.
@@ -142,26 +145,35 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   //
   // Profiling information for the request is saved to |net_log| if non-NULL.
   int ReconsiderProxyAfterError(const GURL& url,
+                                int load_flags,
+                                int net_error,
                                 ProxyInfo* results,
                                 const CompletionCallback& callback,
                                 PacRequest** pac_request,
+                                NetworkDelegate* network_delegate,
                                 const BoundNetLog& net_log);
 
   // Explicitly trigger proxy fallback for the given |results| by updating our
   // list of bad proxies to include the first entry of |results|, and,
   // optionally, another bad proxy. Will retry after |retry_delay| if positive,
-  // and will use the default proxy retry duration otherwise. Returns true if
+  // and will use the default proxy retry duration otherwise. Proxies marked as
+  // bad will not be retried until |retry_delay| has passed. Returns true if
   // there will be at least one proxy remaining in the list after fallback and
-  // false otherwise.
-  bool MarkProxiesAsBad(const ProxyInfo& results,
-                        base::TimeDelta retry_delay,
-                        const ProxyServer& another_bad_proxy,
-                        const BoundNetLog& net_log);
+  // false otherwise. This method should be used to add proxies to the bad
+  // proxy list only for reasons other than a network error. If a proxy needs
+  // to be added to the bad proxy list because a network error was encountered
+  // when trying to connect to it, use |ReconsiderProxyAfterError|.
+  bool MarkProxiesAsBadUntil(const ProxyInfo& results,
+                             base::TimeDelta retry_delay,
+                             const ProxyServer& another_bad_proxy,
+                             const BoundNetLog& net_log);
 
   // Called to report that the last proxy connection succeeded.  If |proxy_info|
   // has a non empty proxy_retry_info map, the proxies that have been tried (and
-  // failed) for this request will be marked as bad.
-  void ReportSuccess(const ProxyInfo& proxy_info);
+  // failed) for this request will be marked as bad. |network_delegate| will
+  // be notified of any proxy fallbacks.
+  void ReportSuccess(const ProxyInfo& proxy_info,
+                     NetworkDelegate* network_delegate);
 
   // Call this method with a non-null |pac_request| to cancel the PAC request.
   void CancelPacRequest(PacRequest* pac_request);
@@ -184,10 +196,6 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   // |new_proxy_config_service|.
   void ResetConfigService(ProxyConfigService* new_proxy_config_service);
 
-  // Tells the resolver to purge any memory it does not need.
-  void PurgeMemory();
-
-
   // Returns the last configuration fetched from ProxyConfigService.
   const ProxyConfig& fetched_config() {
     return fetched_config_;
@@ -246,8 +254,8 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   // Creates a config service appropriate for this platform that fetches the
   // system proxy settings.
   static ProxyConfigService* CreateSystemProxyConfigService(
-      base::SingleThreadTaskRunner* io_thread_task_runner,
-      base::MessageLoop* file_loop);
+      const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
+      const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner);
 
   // This method should only be used by unit tests.
   void set_stall_proxy_auto_config_delay(base::TimeDelta delay) {
@@ -269,35 +277,6 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
 
   bool quick_check_enabled() const { return quick_check_enabled_; }
 
-#if defined(SPDY_PROXY_AUTH_ORIGIN)
-  // Values of the UMA DataReductionProxy.BypassInfo{Primary|Fallback}
-  // histograms. This enum must remain synchronized with the enum of the same
-  // name in metrics/histograms/histograms.xml.
-  enum DataReductionProxyBypassEventType {
-    // Bypass the proxy for less than 30 minutes.
-    SHORT_BYPASS = 0,
-
-    // Bypass the proxy for 30 minutes or more.
-    LONG_BYPASS,
-
-    // Bypass the proxy because of an internal server error.
-    INTERNAL_SERVER_ERROR_BYPASS,
-
-    // Bypass the proxy because of any other error.
-    ERROR_BYPASS,
-
-    // This must always be last.
-    BYPASS_EVENT_TYPE_MAX
-  };
-
-  // Records a |DataReductionProxyBypassEventType| for either the data reduction
-  // proxy (|is_primary| is true) or the data reduction proxy fallback.
-  void RecordDataReductionProxyBypassInfo(
-      bool is_primary,
-      const ProxyServer& proxy_server,
-      DataReductionProxyBypassEventType bypass_type) const;
-#endif
-
  private:
   FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect);
   FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect);
@@ -337,7 +316,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   // Returns ERR_IO_PENDING if the request cannot be completed synchronously.
   // Otherwise it fills |result| with the proxy information for |url|.
   // Completing synchronously means we don't need to query ProxyResolver.
-  int TryToCompleteSynchronously(const GURL& url, ProxyInfo* result);
+  int TryToCompleteSynchronously(const GURL& url,
+                                 int load_flags,
+                                 NetworkDelegate* network_delegate,
+                                 ProxyInfo* result);
 
   // Cancels all of the requests sent to the ProxyResolver. These will be
   // restarted when calling SetReady().
@@ -356,7 +338,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   // Called when proxy resolution has completed (either synchronously or
   // asynchronously). Handles logging the result, and cleaning out
   // bad entries from the results list.
-  int DidFinishResolvingProxy(ProxyInfo* result,
+  int DidFinishResolvingProxy(const GURL& url,
+                              int load_flags,
+                              NetworkDelegate* network_delegate,
+                              ProxyInfo* result,
                               int result_code,
                               const BoundNetLog& net_log);
 
@@ -447,39 +432,6 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   DISALLOW_COPY_AND_ASSIGN(ProxyService);
 };
 
-// Wrapper for invoking methods on a ProxyService synchronously.
-class NET_EXPORT SyncProxyServiceHelper
-    : public base::RefCountedThreadSafe<SyncProxyServiceHelper> {
- public:
-  SyncProxyServiceHelper(base::MessageLoop* io_message_loop,
-                         ProxyService* proxy_service);
-
-  int ResolveProxy(const GURL& url,
-                   ProxyInfo* proxy_info,
-                   const BoundNetLog& net_log);
-  int ReconsiderProxyAfterError(const GURL& url,
-                                ProxyInfo* proxy_info,
-                                const BoundNetLog& net_log);
-
- private:
-  friend class base::RefCountedThreadSafe<SyncProxyServiceHelper>;
-
-  virtual ~SyncProxyServiceHelper();
-
-  void StartAsyncResolve(const GURL& url, const BoundNetLog& net_log);
-  void StartAsyncReconsider(const GURL& url, const BoundNetLog& net_log);
-
-  void OnCompletion(int result);
-
-  base::MessageLoop* io_message_loop_;
-  ProxyService* proxy_service_;
-
-  base::WaitableEvent event_;
-  CompletionCallback callback_;
-  ProxyInfo proxy_info_;
-  int result_;
-};
-
 }  // namespace net
 
 #endif  // NET_PROXY_PROXY_SERVICE_H_