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 #include "chrome/browser/local_discovery/privet_http_impl.h" | 5 #include "chrome/browser/local_discovery/privet_http_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 return name_; | 731 return name_; |
732 } | 732 } |
733 | 733 |
734 scoped_ptr<PrivetURLFetcher> PrivetHTTPClientImpl::CreateURLFetcher( | 734 scoped_ptr<PrivetURLFetcher> PrivetHTTPClientImpl::CreateURLFetcher( |
735 const GURL& url, net::URLFetcher::RequestType request_type, | 735 const GURL& url, net::URLFetcher::RequestType request_type, |
736 PrivetURLFetcher::Delegate* delegate) const { | 736 PrivetURLFetcher::Delegate* delegate) const { |
737 GURL::Replacements replacements; | 737 GURL::Replacements replacements; |
738 replacements.SetHostStr(host_port_.host()); | 738 replacements.SetHostStr(host_port_.host()); |
739 std::string port(base::IntToString(host_port_.port())); // Keep string alive. | 739 std::string port(base::IntToString(host_port_.port())); // Keep string alive. |
740 replacements.SetPortStr(port); | 740 replacements.SetPortStr(port); |
741 GURL url2 = url.ReplaceComponents(replacements); | |
742 return fetcher_factory_.CreateURLFetcher(url.ReplaceComponents(replacements), | 741 return fetcher_factory_.CreateURLFetcher(url.ReplaceComponents(replacements), |
743 request_type, delegate); | 742 request_type, delegate); |
744 } | 743 } |
745 | 744 |
746 void PrivetHTTPClientImpl::CacheInfo(const base::DictionaryValue* cached_info) { | 745 void PrivetHTTPClientImpl::CacheInfo(const base::DictionaryValue* cached_info) { |
747 cached_info_.reset(cached_info->DeepCopy()); | 746 cached_info_.reset(cached_info->DeepCopy()); |
748 std::string token; | 747 std::string token; |
749 if (cached_info_->GetString(kPrivetInfoKeyToken, &token)) { | 748 if (cached_info_->GetString(kPrivetInfoKeyToken, &token)) { |
750 fetcher_factory_.set_token(token); | 749 fetcher_factory_.set_token(token); |
751 } | 750 } |
(...skipping 29 matching lines...) Expand all Loading... |
781 TokenCallbackVector token_callbacks; | 780 TokenCallbackVector token_callbacks; |
782 token_callbacks_.swap(token_callbacks); | 781 token_callbacks_.swap(token_callbacks); |
783 | 782 |
784 for (TokenCallbackVector::iterator i = token_callbacks.begin(); | 783 for (TokenCallbackVector::iterator i = token_callbacks.begin(); |
785 i != token_callbacks.end(); i++) { | 784 i != token_callbacks.end(); i++) { |
786 i->Run(token); | 785 i->Run(token); |
787 } | 786 } |
788 } | 787 } |
789 | 788 |
790 } // namespace local_discovery | 789 } // namespace local_discovery |
OLD | NEW |