Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / extensions / browser / api / mime_handler_private / mime_handler_private.h
blob045264a18a79d9a79efd4579efe0cce4b48892cb
1 // Copyright 2015 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.
5 #ifndef EXTENSIONS_BROWSER_API_MIME_HANDLER_PRIVATE_MIME_HANDLER_PRIVATE_H_
6 #define EXTENSIONS_BROWSER_API_MIME_HANDLER_PRIVATE_MIME_HANDLER_PRIVATE_H_
8 #include "base/memory/weak_ptr.h"
9 #include "extensions/common/api/mime_handler.mojom.h"
11 namespace extensions {
12 class StreamContainer;
13 class MimeHandlerServiceImplTest;
15 class MimeHandlerServiceImpl
16 : public mojo::InterfaceImpl<mime_handler::MimeHandlerService> {
17 public:
18 static void Create(
19 base::WeakPtr<StreamContainer> stream_container,
20 mojo::InterfaceRequest<mime_handler::MimeHandlerService> request);
22 private:
23 friend class MimeHandlerServiceImplTest;
25 explicit MimeHandlerServiceImpl(
26 base::WeakPtr<StreamContainer> stream_container);
27 ~MimeHandlerServiceImpl() override;
29 // mime_handler::MimeHandlerService overrides.
30 void GetStreamInfo(const mojo::Callback<void(mime_handler::StreamInfoPtr)>&
31 callback) override;
32 void AbortStream(const mojo::Callback<void()>& callback) override;
34 // Invoked by the callback used to abort |stream_|.
35 void OnStreamClosed(const mojo::Callback<void()>& callback);
37 // A handle to the stream being handled by the MimeHandlerViewGuest.
38 base::WeakPtr<StreamContainer> stream_;
40 base::WeakPtrFactory<MimeHandlerServiceImpl> weak_factory_;
43 } // namespace extensions
45 namespace mojo {
47 template <>
48 struct TypeConverter<extensions::mime_handler::StreamInfoPtr,
49 extensions::StreamContainer> {
50 static extensions::mime_handler::StreamInfoPtr Convert(
51 const extensions::StreamContainer& stream);
54 } // namespace mojo
56 #endif // EXTENSIONS_BROWSER_API_MIME_HANDLER_PRIVATE_MIME_HANDLER_PRIVATE_H_