ping_manager.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2014 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. #ifndef COMPONENTS_UPDATE_CLIENT_PING_MANAGER_H_
  5. #define COMPONENTS_UPDATE_CLIENT_PING_MANAGER_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. #include "base/memory/ref_counted.h"
  9. #include "base/threading/thread_checker.h"
  10. namespace update_client {
  11. class Configurator;
  12. class Component;
  13. class PersistedData;
  14. class PingManager : public base::RefCountedThreadSafe<PingManager> {
  15. public:
  16. // |error| is 0 if the ping was sent successfully, otherwise |error| contains
  17. // a value with no particular meaning for the caller.
  18. using Callback =
  19. base::OnceCallback<void(int error, const std::string& response)>;
  20. explicit PingManager(scoped_refptr<Configurator> config);
  21. PingManager(const PingManager&) = delete;
  22. PingManager& operator=(const PingManager&) = delete;
  23. // Sends a ping for the |item|. |callback| is invoked after the ping is sent
  24. // or an error has occured. The ping itself is not persisted and it will
  25. // be discarded if it has not been sent for any reason.
  26. virtual void SendPing(const Component& component,
  27. const PersistedData& metadata,
  28. Callback callback);
  29. protected:
  30. virtual ~PingManager();
  31. private:
  32. friend class base::RefCountedThreadSafe<PingManager>;
  33. THREAD_CHECKER(thread_checker_);
  34. const scoped_refptr<Configurator> config_;
  35. };
  36. } // namespace update_client
  37. #endif // COMPONENTS_UPDATE_CLIENT_PING_MANAGER_H_