| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/android/rlz/rlz_ping_handler.h" | 5 #include "chrome/browser/android/rlz/rlz_ping_handler.h" |
| 6 | 6 |
| 7 #include "base/android/callback_android.h" | 7 #include "base/android/callback_android.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 url_fetcher_->SetMaxRetriesOn5xx(kMaxRetries); | 99 url_fetcher_->SetMaxRetriesOn5xx(kMaxRetries); |
| 100 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); | 100 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); |
| 101 url_fetcher_->SetAutomaticallyRetryOn5xx(true); | 101 url_fetcher_->SetAutomaticallyRetryOn5xx(true); |
| 102 url_fetcher_->SetRequestContext(request_context_.get()); | 102 url_fetcher_->SetRequestContext(request_context_.get()); |
| 103 url_fetcher_->Start(); | 103 url_fetcher_->Start(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void RlzPingHandler::OnURLFetchComplete(const net::URLFetcher* source) { | 106 void RlzPingHandler::OnURLFetchComplete(const net::URLFetcher* source) { |
| 107 DCHECK_EQ(source, url_fetcher_.get()); | 107 DCHECK_EQ(source, url_fetcher_.get()); |
| 108 | 108 |
| 109 jboolean valid = false; | 109 bool valid = false; |
| 110 if (!source->GetStatus().is_success() || | 110 if (!source->GetStatus().is_success() || |
| 111 source->GetResponseCode() != net::HTTP_OK) { | 111 source->GetResponseCode() != net::HTTP_OK) { |
| 112 LOG(WARNING) << base::StringPrintf("Rlz endpoint responded with code %d.", | 112 LOG(WARNING) << base::StringPrintf("Rlz endpoint responded with code %d.", |
| 113 source->GetResponseCode()); | 113 source->GetResponseCode()); |
| 114 } else { | 114 } else { |
| 115 std::string response; | 115 std::string response; |
| 116 source->GetResponseAsString(&response); | 116 source->GetResponseAsString(&response); |
| 117 int response_length = -1; | 117 int response_length = -1; |
| 118 valid = rlz_lib::IsPingResponseValid(response.c_str(), &response_length); | 118 valid = rlz_lib::IsPingResponseValid(response.c_str(), &response_length); |
| 119 } | 119 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 handler->Ping(j_brand, j_language, j_events, j_id, j_callback); | 136 handler->Ping(j_brand, j_language, j_events, j_id, j_callback); |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Register native methods | 139 // Register native methods |
| 140 bool RegisterRlzPingHandler(JNIEnv* env) { | 140 bool RegisterRlzPingHandler(JNIEnv* env) { |
| 141 return RegisterNativesImpl(env); | 141 return RegisterNativesImpl(env); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace android | 144 } // namespace android |
| 145 } // namespace chrome | 145 } // namespace chrome |
| OLD | NEW |