| 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 #ifndef NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_H_ | 5 #ifndef NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_H_ |
| 6 #define NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_H_ | 6 #define NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // If the request is cancelled (either using the "Cancel()" method or by | 55 // If the request is cancelled (either using the "Cancel()" method or by |
| 56 // deleting |this|), then no callback is invoked. | 56 // deleting |this|), then no callback is invoked. |
| 57 // | 57 // |
| 58 // Only one fetch is allowed to be outstanding at a time. | 58 // Only one fetch is allowed to be outstanding at a time. |
| 59 virtual int Fetch(base::string16* utf16_text, | 59 virtual int Fetch(base::string16* utf16_text, |
| 60 const CompletionCallback& callback) = 0; | 60 const CompletionCallback& callback) = 0; |
| 61 | 61 |
| 62 // Aborts the in-progress fetch (if any). | 62 // Aborts the in-progress fetch (if any). |
| 63 virtual void Cancel() = 0; | 63 virtual void Cancel() = 0; |
| 64 | 64 |
| 65 // Fails the in-progress fetch (if any) and future requests will fail |
| 66 // immediately. Must be called before the URLRequestContext the fetcher was |
| 67 // created with is torn down. |
| 68 virtual void OnShutdown() = 0; |
| 69 |
| 65 // After successful completion of |Fetch()|, this will return the URL | 70 // After successful completion of |Fetch()|, this will return the URL |
| 66 // retrieved from DHCP. It is reset if/when |Fetch()| is called again. | 71 // retrieved from DHCP. It is reset if/when |Fetch()| is called again. |
| 67 virtual const GURL& GetPacURL() const = 0; | 72 virtual const GURL& GetPacURL() const = 0; |
| 68 | 73 |
| 69 // Intended for unit tests only, so they can test that factories return | 74 // Intended for unit tests only, so they can test that factories return |
| 70 // the right types under given circumstances. | 75 // the right types under given circumstances. |
| 71 virtual std::string GetFetcherName() const; | 76 virtual std::string GetFetcherName() const; |
| 72 | 77 |
| 73 protected: | 78 protected: |
| 74 DhcpProxyScriptFetcher(); | 79 DhcpProxyScriptFetcher(); |
| 75 | 80 |
| 76 private: | 81 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcher); | 82 DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcher); |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 // A do-nothing retriever, always returns synchronously with | 85 // A do-nothing retriever, always returns synchronously with |
| 81 // ERR_NOT_IMPLEMENTED result and empty text. | 86 // ERR_NOT_IMPLEMENTED result and empty text. |
| 82 class NET_EXPORT_PRIVATE DoNothingDhcpProxyScriptFetcher | 87 class NET_EXPORT_PRIVATE DoNothingDhcpProxyScriptFetcher |
| 83 : public DhcpProxyScriptFetcher { | 88 : public DhcpProxyScriptFetcher { |
| 84 public: | 89 public: |
| 85 DoNothingDhcpProxyScriptFetcher(); | 90 DoNothingDhcpProxyScriptFetcher(); |
| 86 ~DoNothingDhcpProxyScriptFetcher() override; | 91 ~DoNothingDhcpProxyScriptFetcher() override; |
| 87 | 92 |
| 88 int Fetch(base::string16* utf16_text, | 93 int Fetch(base::string16* utf16_text, |
| 89 const CompletionCallback& callback) override; | 94 const CompletionCallback& callback) override; |
| 90 void Cancel() override; | 95 void Cancel() override; |
| 96 void OnShutdown() override; |
| 91 const GURL& GetPacURL() const override; | 97 const GURL& GetPacURL() const override; |
| 92 | 98 |
| 93 private: | 99 private: |
| 94 GURL gurl_; | 100 GURL gurl_; |
| 95 DISALLOW_COPY_AND_ASSIGN(DoNothingDhcpProxyScriptFetcher); | 101 DISALLOW_COPY_AND_ASSIGN(DoNothingDhcpProxyScriptFetcher); |
| 96 }; | 102 }; |
| 97 | 103 |
| 98 } // namespace net | 104 } // namespace net |
| 99 | 105 |
| 100 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_H_ | 106 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_H_ |
| OLD | NEW |