forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftl_services_playground.h
89 lines (68 loc) · 2.93 KB
/
ftl_services_playground.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_TEST_FTL_SERVICES_PLAYGROUND_H_
#define REMOTING_TEST_FTL_SERVICES_PLAYGROUND_H_
#include <memory>
#include <string>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "remoting/base/oauth_token_getter.h"
#include "remoting/signaling/ftl_messaging_client.h"
#include "remoting/signaling/ftl_registration_manager.h"
namespace network {
class TransitionalURLLoaderFactoryOwner;
} // namespace network
namespace remoting {
namespace test {
class TestOAuthTokenGetter;
class TestTokenStorage;
} // namespace test
class FtlServicesPlayground {
public:
FtlServicesPlayground();
~FtlServicesPlayground();
bool ShouldPrintHelp();
void PrintHelp();
void StartAndAuthenticate();
private:
void StartLoop();
void ResetServices(base::OnceClosure on_done);
void SignInGaia(base::OnceClosure on_done);
void OnSignInGaiaResponse(base::OnceClosure on_done,
const ProtobufHttpStatus& status);
void PullMessages(base::OnceClosure on_done);
void OnPullMessagesResponse(base::OnceClosure on_done,
const ProtobufHttpStatus& status);
void SendMessage(base::OnceClosure on_done);
void DoSendMessage(const std::string& receiver_id,
const std::string& registration_id,
base::OnceClosure on_done,
bool should_keep_running);
void OnSendMessageResponse(base::OnceCallback<void(bool)> on_continue,
const ProtobufHttpStatus& status);
void StartReceivingMessages(base::OnceClosure on_done);
void StopReceivingMessages(base::OnceClosure on_done);
void OnMessageReceived(const ftl::Id& sender_id,
const std::string& sender_registration_id,
const ftl::ChromotingMessage& message);
void OnReceiveMessagesStreamReady();
void OnReceiveMessagesStreamClosed(const ProtobufHttpStatus& status);
void HandleStatusError(base::OnceClosure on_done,
const ProtobufHttpStatus& status);
std::unique_ptr<test::TestTokenStorage> storage_;
std::unique_ptr<test::TestOAuthTokenGetter> token_getter_;
std::unique_ptr<network::TransitionalURLLoaderFactoryOwner>
url_loader_factory_owner_;
std::unique_ptr<FtlRegistrationManager> registration_manager_;
// Subscription must be deleted before |messaging_client_|.
std::unique_ptr<FtlMessagingClient> messaging_client_;
std::unique_ptr<FtlMessagingClient::MessageCallbackSubscription>
message_subscription_;
base::OnceClosure receive_messages_done_callback_;
base::WeakPtrFactory<FtlServicesPlayground> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(FtlServicesPlayground);
};
} // namespace remoting
#endif // REMOTING_TEST_FTL_SERVICES_PLAYGROUND_H_