OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 PrivetInfoOperation::Delegate* delegate_; | 37 PrivetInfoOperation::Delegate* delegate_; |
38 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 38 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
39 }; | 39 }; |
40 | 40 |
41 class PrivetRegisterOperationImpl | 41 class PrivetRegisterOperationImpl |
42 : public PrivetRegisterOperation, | 42 : public PrivetRegisterOperation, |
43 public PrivetURLFetcher::Delegate, | 43 public PrivetURLFetcher::Delegate, |
44 public PrivetInfoOperation::Delegate, | 44 public PrivetInfoOperation::Delegate, |
45 public base::SupportsWeakPtr<PrivetRegisterOperationImpl> { | 45 public base::SupportsWeakPtr<PrivetRegisterOperationImpl> { |
46 public: | 46 public: |
| 47 class Cancelation : public PrivetURLFetcher::Delegate { |
| 48 public: |
| 49 Cancelation(PrivetHTTPClientImpl* privet_client, |
| 50 const std::string& user); |
| 51 virtual ~Cancelation(); |
| 52 |
| 53 virtual void OnError(PrivetURLFetcher* fetcher, |
| 54 PrivetURLFetcher::ErrorType error) OVERRIDE; |
| 55 |
| 56 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
| 57 const base::DictionaryValue* value, |
| 58 bool has_error) OVERRIDE; |
| 59 |
| 60 private: |
| 61 void Cleanup(); |
| 62 |
| 63 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
| 64 }; |
| 65 |
47 PrivetRegisterOperationImpl(PrivetHTTPClientImpl* privet_client, | 66 PrivetRegisterOperationImpl(PrivetHTTPClientImpl* privet_client, |
48 const std::string& user, | 67 const std::string& user, |
49 PrivetRegisterOperation::Delegate* delegate); | 68 PrivetRegisterOperation::Delegate* delegate); |
50 virtual ~PrivetRegisterOperationImpl(); | 69 virtual ~PrivetRegisterOperationImpl(); |
51 | 70 |
52 virtual void Start() OVERRIDE; | 71 virtual void Start() OVERRIDE; |
53 virtual void Cancel() OVERRIDE; | 72 virtual void Cancel() OVERRIDE; |
54 virtual void CompleteRegistration() OVERRIDE; | 73 virtual void CompleteRegistration() OVERRIDE; |
55 | 74 |
56 virtual void OnError(PrivetURLFetcher* fetcher, | 75 virtual void OnError(PrivetURLFetcher* fetcher, |
(...skipping 16 matching lines...) Expand all Loading... |
73 void StartResponse(const base::DictionaryValue& value); | 92 void StartResponse(const base::DictionaryValue& value); |
74 void GetClaimTokenResponse(const base::DictionaryValue& value); | 93 void GetClaimTokenResponse(const base::DictionaryValue& value); |
75 void CompleteResponse(const base::DictionaryValue& value); | 94 void CompleteResponse(const base::DictionaryValue& value); |
76 | 95 |
77 void StartInfoOperation(); | 96 void StartInfoOperation(); |
78 | 97 |
79 void SendRequest(const std::string& action); | 98 void SendRequest(const std::string& action); |
80 | 99 |
81 bool PrivetErrorTransient(const std::string& error); | 100 bool PrivetErrorTransient(const std::string& error); |
82 | 101 |
| 102 static GURL GetURLForActionAndUser( |
| 103 PrivetHTTPClientImpl* privet_client, |
| 104 const std::string& action, |
| 105 const std::string& user); |
| 106 |
83 std::string user_; | 107 std::string user_; |
84 std::string current_action_; | 108 std::string current_action_; |
85 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 109 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
86 PrivetRegisterOperation::Delegate* delegate_; | 110 PrivetRegisterOperation::Delegate* delegate_; |
87 PrivetHTTPClientImpl* privet_client_; | 111 PrivetHTTPClientImpl* privet_client_; |
88 ResponseHandler next_response_handler_; | 112 ResponseHandler next_response_handler_; |
89 // Required to ensure destroying completed register operations doesn't cause | 113 // Required to ensure destroying completed register operations doesn't cause |
90 // extraneous cancelations. | 114 // extraneous cancelations. |
91 bool ongoing_; | 115 bool ongoing_; |
92 scoped_ptr<PrivetInfoOperation> info_operation_; | 116 scoped_ptr<PrivetInfoOperation> info_operation_; |
(...skipping 27 matching lines...) Expand all Loading... |
120 | 144 |
121 private: | 145 private: |
122 std::string name_; | 146 std::string name_; |
123 PrivetURLFetcherFactory fetcher_factory_; | 147 PrivetURLFetcherFactory fetcher_factory_; |
124 net::HostPortPair host_port_; | 148 net::HostPortPair host_port_; |
125 scoped_ptr<base::DictionaryValue> cached_info_; | 149 scoped_ptr<base::DictionaryValue> cached_info_; |
126 }; | 150 }; |
127 | 151 |
128 } // namespace local_discovery | 152 } // namespace local_discovery |
129 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 153 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
OLD | NEW |