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.
5 #ifndef EXTENSIONS_BROWSER_MOJO_STASH_BACKEND_H_
6 #define EXTENSIONS_BROWSER_MOJO_STASH_BACKEND_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/weak_ptr.h"
11 #include "extensions/common/mojo/stash.mojom.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
14 namespace extensions
{
16 // A backend that provides access to StashService for a single extension.
19 explicit StashBackend(const base::Closure
& on_handle_readable
);
22 // Creates a StashService that forwards calls to this StashBackend and bind it
24 void BindToRequest(mojo::InterfaceRequest
<StashService
> request
);
26 // Adds the StashedObjects contained within |stash| to the stash.
27 void AddToStash(mojo::Array
<StashedObjectPtr
> stash
);
29 // Returns all StashedObjects added to the stash since the last call to
31 mojo::Array
<StashedObjectPtr
> RetrieveStash();
36 // Invoked when a handle is readable.
39 // The objects that have been stashed.
40 ScopedVector
<StashEntry
> stashed_objects_
;
42 // The callback to call when a handle is readable.
43 const base::Closure on_handle_readable_
;
45 // Whether a handle has become readable since the last RetrieveStash() call.
48 base::WeakPtrFactory
<StashBackend
> weak_factory_
;
50 DISALLOW_COPY_AND_ASSIGN(StashBackend
);
53 } // namespace extensions
55 #endif // EXTENSIONS_BROWSER_MOJO_STASH_BACKEND_H_