Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: trunk/src/mojo/spy/spy.cc

Issue 296453021: Revert 272458 "Adding more guts to the mojo spy." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/mojo/spy/spy.h ('k') | trunk/src/mojo/spy/spy_server_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/mojo/spy/spy.cc
===================================================================
--- trunk/src/mojo/spy/spy.cc (revision 272462)
+++ trunk/src/mojo/spy/spy.cc (working copy)
@@ -4,13 +4,10 @@
#include "mojo/spy/spy.h"
-#include <vector>
-
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/threading/thread.h"
@@ -18,10 +15,7 @@
#include "mojo/public/cpp/system/core.h"
#include "mojo/service_manager/service_manager.h"
-#include "mojo/spy/public/spy.mojom.h"
-#include "mojo/spy/spy_server_impl.h"
#include "mojo/spy/websocket_server.h"
-#include "url/gurl.h"
namespace {
@@ -39,9 +33,11 @@
class MessageProcessor :
public base::RefCountedThreadSafe<MessageProcessor> {
public:
+
MessageProcessor()
: last_result_(MOJO_RESULT_OK),
bytes_transfered_(0) {
+
message_count_[0] = 0;
message_count_[1] = 0;
handle_count_[0] = 0;
@@ -111,30 +107,24 @@
}
private:
- friend class base::RefCountedThreadSafe<MessageProcessor>;
- virtual ~MessageProcessor() {}
+ friend class base::RefCountedThreadSafe<MessageProcessor>;
+ virtual ~MessageProcessor() {}
- bool CheckResult(MojoResult mr) {
- if (mr == MOJO_RESULT_OK)
- return true;
- last_result_ = mr;
- return false;
- }
+ bool CheckResult(MojoResult mr) {
+ if (mr == MOJO_RESULT_OK)
+ return true;
+ last_result_ = mr;
+ return false;
+ }
- MojoResult last_result_;
- uint32_t bytes_transfered_;
- uint32_t message_count_[2];
- uint32_t handle_count_[2];
+ MojoResult last_result_;
+ uint32_t bytes_transfered_;
+ uint32_t message_count_[2];
+ uint32_t handle_count_[2];
};
// In charge of intercepting access to the service manager.
class SpyInterceptor : public mojo::ServiceManager::Interceptor {
- public:
- explicit SpyInterceptor(scoped_refptr<mojo::SpyServerImpl> spy_server)
- : spy_server_(spy_server),
- proxy_(base::MessageLoopProxy::current()) {
- }
-
private:
virtual mojo::ScopedMessagePipeHandle OnConnectToClient(
const GURL& url, mojo::ScopedMessagePipeHandle real_client) OVERRIDE {
@@ -163,21 +153,15 @@
bool MustIntercept(const GURL& url) {
// TODO(cpu): manage who and when to intercept.
- proxy_->PostTask(
- FROM_HERE,
- base::Bind(&mojo::SpyServerImpl::OnIntercept, spy_server_, url));
return true;
}
-
- scoped_refptr<mojo::SpyServerImpl> spy_server_;
- scoped_refptr<base::MessageLoopProxy> proxy_;
};
-mojo::WebSocketServer* ws_server = NULL;
+spy::WebSocketServer* ws_server = NULL;
-void StartWebServer(int port, mojo::ScopedMessagePipeHandle pipe) {
+void StartServer(int port) {
// TODO(cpu) figure out lifetime of the server. See Spy() dtor.
- ws_server = new mojo::WebSocketServer(port, pipe.Pass());
+ ws_server = new spy::WebSocketServer(port);
ws_server->Start();
}
@@ -212,23 +196,18 @@
Spy::Spy(mojo::ServiceManager* service_manager, const std::string& options) {
SpyOptions spy_options = ProcessOptions(options);
-
- spy_server_ = new SpyServerImpl();
-
// Start the tread what will accept commands from the frontend.
control_thread_.reset(new base::Thread("mojo_spy_control_thread"));
base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
control_thread_->StartWithOptions(thread_options);
control_thread_->message_loop_proxy()->PostTask(
- FROM_HERE, base::Bind(&StartWebServer,
- spy_options.websocket_port,
- base::Passed(spy_server_->ServerPipe())));
+ FROM_HERE, base::Bind(&StartServer, spy_options.websocket_port));
// Start intercepting mojo services.
- service_manager->SetInterceptor(new SpyInterceptor(spy_server_));
+ service_manager->SetInterceptor(new SpyInterceptor());
}
-Spy::~Spy() {
+Spy::~Spy(){
// TODO(cpu): Do not leak the interceptor. Lifetime between the
// service_manager and the spy is still unclear hence the leak.
}
« no previous file with comments | « trunk/src/mojo/spy/spy.h ('k') | trunk/src/mojo/spy/spy_server_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698