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
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_ASH_COMPONENTS_BOCA_INVALIDATIONS_INVALIDATION_SERVICE_IMPL_H_
#define CHROMEOS_ASH_COMPONENTS_BOCA_INVALIDATIONS_INVALIDATION_SERVICE_IMPL_H_
#include <memory>
#include "base/time/time.h"
#include "base/types/expected.h"
#include "chromeos/ash/components/boca/invalidations/fcm_handler.h"
#include "components/account_id/account_id.h"
#include "google_apis/common/api_error_codes.h"
#include "net/base/backoff_entry.h"
namespace instance_id {
class InstanceIDDriver;
}
namespace gcm {
class GCMDriver;
}
namespace ash::boca {
class BocaSessionManager;
class SessionClientImpl;
class InvalidationServiceImpl : public InvalidationsListener,
FCMRegistrationTokenObserver {
public:
inline static constexpr char kSenderId[] = "947897361853";
inline static constexpr char kApplicationId[] =
"com.google.chrome.boca.fcm.invalidations";
InvalidationServiceImpl(gcm::GCMDriver* gcm_driver,
instance_id::InstanceIDDriver* instance_id_driver,
AccountId account_id,
BocaSessionManager* boca_session_manager_,
SessionClientImpl* session_client_impl_,
std::string base_url);
~InvalidationServiceImpl() override;
// InvalidationsListener implementation.
void OnInvalidationReceived(const std::string& payload) override;
// FCMRegistrationTokenObserver implementation.
void OnFCMRegistrationTokenChanged() override;
void UploadToken();
void OnTokenUploaded(base::expected<bool, google_apis::ApiErrorCode> result);
virtual void ShutDown();
FCMHandler* fcm_handler() { return fcm_handler_.get(); }
private:
SEQUENCE_CHECKER(sequence_checker_);
const std::string school_tools_base_url_;
net::BackoffEntry upload_retry_backoff_;
base::OneShotTimer token_refresh_timer_;
std::unique_ptr<FCMHandler> fcm_handler_;
AccountId account_id_;
raw_ptr<BocaSessionManager> boca_session_manager_;
raw_ptr<SessionClientImpl> session_client_impl_;
base::WeakPtrFactory<InvalidationServiceImpl> weak_factory_{this};
};
} // namespace ash::boca
#endif // CHROMEOS_ASH_COMPONENTS_BOCA_INVALIDATIONS_INVALIDATION_SERVICE_IMPL_H_
|