network_context.h 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2020 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_OPENSCREEN_PLATFORM_NETWORK_CONTEXT_H_
  5. #define COMPONENTS_OPENSCREEN_PLATFORM_NETWORK_CONTEXT_H_
  6. #include "base/bind.h"
  7. #include "services/network/public/mojom/network_context.mojom.h"
  8. namespace openscreen_platform {
  9. using NetworkContextGetter =
  10. base::RepeatingCallback<network::mojom::NetworkContext*()>;
  11. void SetNetworkContextGetter(NetworkContextGetter network_context_getter);
  12. void ClearNetworkContextGetter();
  13. bool HasNetworkContextGetter();
  14. // This and all subsequent NetworkContext calls made must obey the thread safety
  15. // requirements of |network_context_getter|. This must be called each time a
  16. // mojom::NetworkContext is needed; any returned pointer should not be stored
  17. // beyond the scope in which it is received.
  18. //
  19. // In Chrome, the |network_context_getter| will always return the NetworkContext
  20. // from the SystemNetworkContextManager; therefore, GetNetworkContext must be
  21. // called on the UI thread.
  22. network::mojom::NetworkContext* GetNetworkContext();
  23. } // namespace openscreen_platform
  24. #endif // COMPONENTS_OPENSCREEN_PLATFORM_NETWORK_CONTEXT_H_