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"
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
12 namespace extensions
{
13 class StreamContainer
;
14 class MimeHandlerServiceImplTest
;
16 class MimeHandlerServiceImpl
: public mime_handler::MimeHandlerService
{
19 base::WeakPtr
<StreamContainer
> stream_container
,
20 mojo::InterfaceRequest
<mime_handler::MimeHandlerService
> request
);
23 friend class MimeHandlerServiceImplTest
;
25 MimeHandlerServiceImpl(
26 base::WeakPtr
<StreamContainer
> stream_container
,
27 mojo::InterfaceRequest
<mime_handler::MimeHandlerService
> request
);
28 ~MimeHandlerServiceImpl() override
;
30 // mime_handler::MimeHandlerService overrides.
31 void GetStreamInfo(const mojo::Callback
<void(mime_handler::StreamInfoPtr
)>&
33 void AbortStream(const mojo::Callback
<void()>& callback
) override
;
35 // Invoked by the callback used to abort |stream_|.
36 void OnStreamClosed(const mojo::Callback
<void()>& callback
);
38 // A handle to the stream being handled by the MimeHandlerViewGuest.
39 base::WeakPtr
<StreamContainer
> stream_
;
41 mojo::StrongBinding
<mime_handler::MimeHandlerService
> binding_
;
43 base::WeakPtrFactory
<MimeHandlerServiceImpl
> weak_factory_
;
46 } // namespace extensions
51 struct TypeConverter
<extensions::mime_handler::StreamInfoPtr
,
52 extensions::StreamContainer
> {
53 static extensions::mime_handler::StreamInfoPtr
Convert(
54 const extensions::StreamContainer
& stream
);
59 #endif // EXTENSIONS_BROWSER_API_MIME_HANDLER_PRIVATE_MIME_HANDLER_PRIVATE_H_