Adding Baseframework of the ResourceManager (all hooks and observers)
[chromium-blink-merge.git] / mojo / spy / spy_server_impl.h
blob368e69a96097c1f2748903a6f2d4e50837c7b966
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 MOJO_SPY_SPY_SERVER_IMPL_H_
6 #define MOJO_SPY_SPY_SERVER_IMPL_H_
8 #include <map>
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "mojo/public/cpp/system/core.h"
13 #include "mojo/spy/public/spy.mojom.h"
14 #include "url/gurl.h"
16 namespace mojo {
18 class SpyServerImpl :
19 public base::RefCounted<SpyServerImpl>,
20 public InterfaceImpl<spy_api::SpyServer> {
21 public:
22 SpyServerImpl();
24 // spy_api::SpyServer implementation.
25 virtual void StartSession(
26 spy_api::VersionPtr version,
27 const mojo::Callback<void(spy_api::Result,
28 mojo::String)>& callback) OVERRIDE;
30 virtual void StopSession(
31 const mojo::Callback<void(spy_api::Result)>& callback) OVERRIDE;
33 virtual void TrackConnection(
34 uint32_t id,
35 spy_api::ConnectionOptions options,
36 const mojo::Callback<void(spy_api::Result)>& callback) OVERRIDE;
38 virtual void OnConnectionError() OVERRIDE;
40 // SpyServerImpl own methods.
41 void OnIntercept(const GURL& url);
43 ScopedMessagePipeHandle ServerPipe();
45 private:
46 friend class base::RefCounted<SpyServerImpl>;
47 virtual ~SpyServerImpl();
49 // Item models the entities that we track by IDs.
50 struct Item;
52 MessagePipe pipe_;
53 bool has_session_;
54 std::map<uint32_t, Item*> items_;
57 } // namespace mojo
59 #endif // MOJO_SPY_SPY_SERVER_IMPL_H_