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
> {
19 base::WeakPtr
<StreamContainer
> stream_container
,
20 mojo::InterfaceRequest
<mime_handler::MimeHandlerService
> request
);
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
)>&
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
48 struct TypeConverter
<extensions::mime_handler::StreamInfoPtr
,
49 extensions::StreamContainer
> {
50 static extensions::mime_handler::StreamInfoPtr
Convert(
51 const extensions::StreamContainer
& stream
);
56 #endif // EXTENSIONS_BROWSER_API_MIME_HANDLER_PRIVATE_MIME_HANDLER_PRIVATE_H_