| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_SPY_SPY_SERVER_IMPL_H_ | 5 #ifndef MOJO_SPY_SPY_SERVER_IMPL_H_ |
| 6 #define MOJO_SPY_SPY_SERVER_IMPL_H_ | 6 #define MOJO_SPY_SPY_SERVER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
| 12 #include "mojo/spy/public/spy.mojom.h" | 12 #include "mojo/spy/public/spy.mojom.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 | 16 |
| 17 class SpyServerImpl : | 17 class SpyServerImpl : |
| 18 public base::RefCounted<SpyServerImpl>, | 18 public base::RefCounted<SpyServerImpl>, |
| 19 public InterfaceImpl<spy_api::SpyServer> { | 19 public InterfaceImpl<spy_api::SpyServer> { |
| 20 public: | 20 public: |
| 21 SpyServerImpl(); | 21 SpyServerImpl(); |
| 22 | 22 |
| 23 // spy_api::SpyServer implementation. | 23 // spy_api::SpyServer implementation. |
| 24 virtual void StartSession( | 24 void StartSession(spy_api::VersionPtr version, |
| 25 spy_api::VersionPtr version, | 25 const mojo::Callback<void(spy_api::Result, mojo::String)>& |
| 26 const mojo::Callback<void(spy_api::Result, | 26 callback) override; |
| 27 mojo::String)>& callback) override; | |
| 28 | 27 |
| 29 virtual void StopSession( | 28 void StopSession( |
| 30 const mojo::Callback<void(spy_api::Result)>& callback) override; | 29 const mojo::Callback<void(spy_api::Result)>& callback) override; |
| 31 | 30 |
| 32 virtual void TrackConnection( | 31 void TrackConnection( |
| 33 uint32_t id, | 32 uint32_t id, |
| 34 spy_api::ConnectionOptions options, | 33 spy_api::ConnectionOptions options, |
| 35 const mojo::Callback<void(spy_api::Result)>& callback) override; | 34 const mojo::Callback<void(spy_api::Result)>& callback) override; |
| 36 | 35 |
| 37 virtual void OnConnectionError() override; | 36 void OnConnectionError() override; |
| 38 | 37 |
| 39 // SpyServerImpl own methods. | 38 // SpyServerImpl own methods. |
| 40 void OnIntercept(const GURL& url); | 39 void OnIntercept(const GURL& url); |
| 41 | 40 |
| 42 ScopedMessagePipeHandle ServerPipe(); | 41 ScopedMessagePipeHandle ServerPipe(); |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 friend class base::RefCounted<SpyServerImpl>; | 44 friend class base::RefCounted<SpyServerImpl>; |
| 46 virtual ~SpyServerImpl(); | 45 ~SpyServerImpl() override; |
| 47 | 46 |
| 48 // Item models the entities that we track by IDs. | 47 // Item models the entities that we track by IDs. |
| 49 struct Item; | 48 struct Item; |
| 50 | 49 |
| 51 MessagePipe pipe_; | 50 MessagePipe pipe_; |
| 52 bool has_session_; | 51 bool has_session_; |
| 53 std::map<uint32_t, Item*> items_; | 52 std::map<uint32_t, Item*> items_; |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 } // namespace mojo | 55 } // namespace mojo |
| 57 | 56 |
| 58 #endif // MOJO_SPY_SPY_SERVER_IMPL_H_ | 57 #endif // MOJO_SPY_SPY_SERVER_IMPL_H_ |
| OLD | NEW |