blob: a58c81535fc59152e7bcd8af296d7c892b86b475 [file] [log] [blame]
yusufocac912f12017-05-09 16:09:511// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_ANDROID_RLZ_RLZ_PING_HANDLER_H_
6#define CHROME_BROWSER_ANDROID_RLZ_RLZ_PING_HANDLER_H_
7
8#include <jni.h>
Mark Pilgrim2e9fedc2018-05-02 21:08:459#include <memory>
10#include <string>
yusufocac912f12017-05-09 16:09:5111#include "base/android/scoped_java_ref.h"
Mark Pilgrim2e9fedc2018-05-02 21:08:4512#include "base/memory/ref_counted.h"
13
14namespace network {
15class SimpleURLLoader;
16class SharedURLLoaderFactory;
17} // namespace network
yusufocac912f12017-05-09 16:09:5118
19namespace chrome {
20namespace android {
21
22// JNI bridge for RlzPingHandler.java
Mark Pilgrim2e9fedc2018-05-02 21:08:4523class RlzPingHandler {
yusufocac912f12017-05-09 16:09:5124 public:
Torne (Richard Coles)0a108752017-07-25 15:08:4125 explicit RlzPingHandler(const base::android::JavaRef<jobject>& jprofile);
Mark Pilgrim2e9fedc2018-05-02 21:08:4526 ~RlzPingHandler();
yusufocac912f12017-05-09 16:09:5127
28 // Makes a GET request to the designated web end point with the given
29 // parameters. |j_brand| is a 4 character priorly designated brand value.
30 // |j_language| is the 2 letter lower case language. |events| is a single
31 // string where multiple 4 character long events are concatenated with ,
32 // and |id| is a unique id for the device that is 50 characters long.
33 void Ping(const base::android::JavaParamRef<jstring>& j_brand,
34 const base::android::JavaParamRef<jstring>& j_language,
35 const base::android::JavaParamRef<jstring>& j_events,
36 const base::android::JavaParamRef<jstring>& j_id,
37 const base::android::JavaParamRef<jobject>& j_callback);
38
39 private:
Mark Pilgrim2e9fedc2018-05-02 21:08:4540 void OnSimpleLoaderComplete(std::unique_ptr<std::string> response_body);
yusufocac912f12017-05-09 16:09:5141
Mark Pilgrim2e9fedc2018-05-02 21:08:4542 scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
43 std::unique_ptr<network::SimpleURLLoader> simple_url_loader_;
yusufocac912f12017-05-09 16:09:5144 base::android::ScopedJavaGlobalRef<jobject> j_callback_;
45
46 DISALLOW_COPY_AND_ASSIGN(RlzPingHandler);
47};
48
yusufocac912f12017-05-09 16:09:5149} // namespace android
50} // namespace chrome
51
52#endif // CHROME_BROWSER_ANDROID_RLZ_RLZ_PING_HANDLER_H_