Add testing/scripts/OWNERS
[chromium-blink-merge.git] / extensions / browser / mojo / stash_backend.h
blobb90e43d013c0c446b01823d2fa9afd860589b979
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 <vector>
10 #include "base/memory/linked_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "extensions/common/mojo/stash.mojom.h"
13 #include "mojo/public/cpp/bindings/interface_request.h"
15 namespace extensions {
17 // A backend that provides access to StashService for a single extension.
18 class StashBackend {
19 public:
20 StashBackend();
21 ~StashBackend();
23 // Creates a StashService that forwards calls to this StashBackend and bind it
24 // to |request|.
25 void BindToRequest(mojo::InterfaceRequest<StashService> request);
27 // Adds the StashedObjects contained within |stash| to the stash.
28 void AddToStash(mojo::Array<StashedObjectPtr> stash);
30 // Returns all StashedObjects added to the stash since the last call to
31 // RetrieveStash.
32 mojo::Array<StashedObjectPtr> RetrieveStash();
34 private:
35 // The objects that have been stashed.
36 mojo::Array<StashedObjectPtr> stashed_objects_;
38 base::WeakPtrFactory<StashBackend> weak_factory_;
40 DISALLOW_COPY_AND_ASSIGN(StashBackend);
43 } // namespace extensions
45 #endif // EXTENSIONS_BROWSER_MOJO_STASH_BACKEND_H_