summaryrefslogtreecommitdiffstats
path: root/sync/js
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 22:45:16 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 22:45:16 +0000
commit00b4017c941b45a3305f02cba1eaf56a7ab05bc5 (patch)
treeaf24bb16a84430654510ab60e5cac16e831bf522 /sync/js
parentd5d60089a9dd4d5220fe547866dd547d376ed251 (diff)
downloadchromium_src-00b4017c941b45a3305f02cba1eaf56a7ab05bc5.zip
chromium_src-00b4017c941b45a3305f02cba1eaf56a7ab05bc5.tar.gz
chromium_src-00b4017c941b45a3305f02cba1eaf56a7ab05bc5.tar.bz2
Remove Sync JS generic request/reply framework
With the conversion of GetAllNodes in r262193, there are no longer any uses of the Sync JS framework's request + reply framework. The generic framework was useful when we could guarantee that the requests would be handled in order, in the SyncManager, and on the sync thread, but new requirements have forced us to re-implement much of this functionality in other ways. Since no one uses this code, and no one plans to use this code, and it depends on some semi-deprecated concepts (WeakHandle), the best course of action seems to be to delete it. We can always fetch it from SVN history and clean it up if we find another use for it. BUG=328606,357821 Review URL: https://codereview.chromium.org/231013003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/js')
-rw-r--r--sync/js/README.js64
-rw-r--r--sync/js/js_arg_list.cc27
-rw-r--r--sync/js/js_arg_list.h44
-rw-r--r--sync/js/js_arg_list_unittest.cc40
-rw-r--r--sync/js/js_backend.h8
-rw-r--r--sync/js/js_controller.h8
-rw-r--r--sync/js/js_reply_handler.h29
-rw-r--r--sync/js/js_test_util.cc47
-rw-r--r--sync/js/js_test_util.h26
-rw-r--r--sync/js/sync_js_controller.cc29
-rw-r--r--sync/js/sync_js_controller.h22
-rw-r--r--sync/js/sync_js_controller_unittest.cc86
12 files changed, 16 insertions, 414 deletions
diff --git a/sync/js/README.js b/sync/js/README.js
index 0fbfa66..3a99d1e 100644
--- a/sync/js/README.js
+++ b/sync/js/README.js
@@ -1,48 +1,16 @@
-Overview of chrome://sync-internals
------------------------------------
-
-This note explains how chrome://sync-internals (also known as
-about:sync) interacts with the sync service/backend.
-
-Basically, chrome://sync-internals sends messages to the sync backend
-and the sync backend sends the reply asynchronously. The sync backend
-also asynchronously raises events which chrome://sync-internals listen
-to.
-
-A message and its reply has a name and a list of arguments, which is
-basically a wrapper around an immutable ListValue.
-
-An event has a name and a details object, which is represented by a
-JsEventDetails (js_event_details.h) object, which is basically a
-wrapper around an immutable DictionaryValue.
-
-Message/event flow
-------------------
-
-chrome://sync-internals is represented by SyncInternalsUI
-(chrome/browser/ui/webui/sync_internals_ui.h). SyncInternalsUI
-interacts with the sync service via a JsController (js_controller.h)
-object, which has a ProcessJsMessage() method that just delegates to
-an underlying JsBackend instance (js_backend.h). The SyncInternalsUI
-object also registers itself (as a JsEventHandler
-[js_event_handler.h]) to the JsController object, and any events
-raised by the JsBackend are propagated to the JsController and then to
-the registered JsEventHandlers.
-
-The ProcessJsMessage() takes a WeakHandle (weak_handle.h) to a
-JsReplyHandler (js_reply_handler.h), which the backend uses to send
-replies safely across threads. SyncInternalsUI implements
-JsReplyHandler, so it simply passes itself as the reply handler when
-it calls ProcessJsMessage() on the JsController.
-
-The following objects live on the UI thread:
-
-- SyncInternalsUI (implements JsEventHandler, JsReplyHandler)
-- SyncJsController (implements JsController, JsEventHandler)
-
-The following objects live on the sync thread:
-
-- SyncManager::SyncInternal (implements JsBackend)
-
-Of course, none of these objects need to know where the other objects
-live, since they interact via WeakHandles.
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+This framework was once used to implement an asynchronous request/reply
+protocol between the chrome://sync-internals page and the sync backend thread.
+Much of it has been removed in favor of an ad-hoc system that allows us to
+offer better safety guarantees, and to dispatch requests to different threads.
+
+All that remains are some WeakHandles that allow us to send JsEvents from the
+sync backend to about:sync. The SyncInternalsUI implements JsEventHandler in
+order to receive these events. The SyncManager implements JsBackend in order
+to send them. The SyncJsController acts as an intermediary between them.
+
+The old framework may still be useful to someone. Feel free to retrieve it
+from SVN history if you feel you can make use of it.
diff --git a/sync/js/js_arg_list.cc b/sync/js/js_arg_list.cc
deleted file mode 100644
index e3317e5..0000000
--- a/sync/js/js_arg_list.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/js/js_arg_list.h"
-
-#include "base/json/json_writer.h"
-
-namespace syncer {
-
-JsArgList::JsArgList() {}
-
-JsArgList::JsArgList(base::ListValue* args) : args_(args) {}
-
-JsArgList::~JsArgList() {}
-
-const base::ListValue& JsArgList::Get() const {
- return args_.Get();
-}
-
-std::string JsArgList::ToString() const {
- std::string str;
- base::JSONWriter::Write(&Get(), &str);
- return str;
-}
-
-} // namespace syncer
diff --git a/sync/js/js_arg_list.h b/sync/js/js_arg_list.h
deleted file mode 100644
index 34a0cf6..0000000
--- a/sync/js/js_arg_list.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_JS_JS_ARG_LIST_H_
-#define SYNC_JS_JS_ARG_LIST_H_
-
-// See README.js for design comments.
-
-#include <string>
-
-#include "base/values.h"
-#include "sync/base/sync_export.h"
-#include "sync/internal_api/public/util/immutable.h"
-
-namespace syncer {
-
-// A thin wrapper around Immutable<ListValue>. Used for passing
-// around argument lists to different threads.
-class SYNC_EXPORT JsArgList {
- public:
- // Uses an empty argument list.
- JsArgList();
-
- // Takes over the data in |args|, leaving |args| empty.
- explicit JsArgList(base::ListValue* args);
-
- ~JsArgList();
-
- const base::ListValue& Get() const;
-
- std::string ToString() const;
-
- // Copy constructor and assignment operator welcome.
-
- private:
- typedef Immutable<base::ListValue, HasSwapMemFnByPtr<base::ListValue> >
- ImmutableListValue;
- ImmutableListValue args_;
-};
-
-} // namespace syncer
-
-#endif // SYNC_JS_JS_ARG_LIST_H_
diff --git a/sync/js/js_arg_list_unittest.cc b/sync/js/js_arg_list_unittest.cc
deleted file mode 100644
index 2a10286..0000000
--- a/sync/js/js_arg_list_unittest.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/js/js_arg_list.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace syncer {
-namespace {
-
-class JsArgListTest : public testing::Test {};
-
-TEST_F(JsArgListTest, EmptyList) {
- JsArgList arg_list;
- EXPECT_TRUE(arg_list.Get().empty());
- EXPECT_EQ("[]", arg_list.ToString());
-}
-
-TEST_F(JsArgListTest, FromList) {
- scoped_ptr<base::ListValue> list(new base::ListValue());
- list->Append(new base::FundamentalValue(false));
- list->Append(new base::FundamentalValue(5));
- base::DictionaryValue* dict = new base::DictionaryValue();
- list->Append(dict);
- dict->SetString("foo", "bar");
- dict->Set("baz", new base::ListValue());
-
- scoped_ptr<base::ListValue> list_copy(list->DeepCopy());
-
- JsArgList arg_list(list.get());
-
- // |arg_list| should take over |list|'s data.
- EXPECT_TRUE(list->empty());
- EXPECT_TRUE(arg_list.Get().Equals(list_copy.get()));
-}
-
-} // namespace
-} // namespace syncer
diff --git a/sync/js/js_backend.h b/sync/js/js_backend.h
index e39600a..a0ef317 100644
--- a/sync/js/js_backend.h
+++ b/sync/js/js_backend.h
@@ -13,9 +13,7 @@
namespace syncer {
-class JsArgList;
class JsEventHandler;
-class JsReplyHandler;
template <typename T> class WeakHandle;
// Interface representing the backend of chrome://sync-internals. A
@@ -27,12 +25,6 @@ class SYNC_EXPORT_PRIVATE JsBackend {
virtual void SetJsEventHandler(
const WeakHandle<JsEventHandler>& event_handler) = 0;
- // Processes the given message and replies via the given handler, if
- // initialized.
- virtual void ProcessJsMessage(
- const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler) = 0;
-
protected:
virtual ~JsBackend() {}
};
diff --git a/sync/js/js_controller.h b/sync/js/js_controller.h
index 08432bf..482c8c1 100644
--- a/sync/js/js_controller.h
+++ b/sync/js/js_controller.h
@@ -13,9 +13,7 @@
namespace syncer {
-class JsArgList;
class JsEventHandler;
-class JsReplyHandler;
template <typename T> class WeakHandle;
// An interface for objects that JsEventHandlers directly interact
@@ -36,12 +34,6 @@ class SYNC_EXPORT JsController {
// immediately stop receiving any JS events.
virtual void RemoveJsEventHandler(JsEventHandler* event_handler) = 0;
- // Processes a JS message. The reply (if any) will be sent to
- // |reply_handler| if it is initialized.
- virtual void ProcessJsMessage(
- const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler) = 0;
-
protected:
virtual ~JsController() {}
};
diff --git a/sync/js/js_reply_handler.h b/sync/js/js_reply_handler.h
deleted file mode 100644
index 3026b7b..0000000
--- a/sync/js/js_reply_handler.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_JS_JS_REPLY_HANDLER_H_
-#define SYNC_JS_JS_REPLY_HANDLER_H_
-
-// See README.js for design comments.
-
-#include <string>
-
-namespace syncer {
-
-class JsArgList;
-
-// An interface for objects that handle Javascript message replies
-// (e.g., WebUIs).
-class JsReplyHandler {
- public:
- virtual void HandleJsReply(
- const std::string& name, const JsArgList& args) = 0;
-
- protected:
- virtual ~JsReplyHandler() {}
-};
-
-} // namespace syncer
-
-#endif // SYNC_JS_JS_REPLY_HANDLER_H_
diff --git a/sync/js/js_test_util.cc b/sync/js/js_test_util.cc
index 7d40289..f596136 100644
--- a/sync/js/js_test_util.cc
+++ b/sync/js/js_test_util.cc
@@ -6,51 +6,16 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "sync/js/js_arg_list.h"
#include "sync/js/js_event_details.h"
namespace syncer {
-void PrintTo(const JsArgList& args, ::std::ostream* os) {
- *os << args.ToString();
-}
-
void PrintTo(const JsEventDetails& details, ::std::ostream* os) {
*os << details.ToString();
}
namespace {
-// Matcher implementation for HasArgs().
-class HasArgsMatcher
- : public ::testing::MatcherInterface<const JsArgList&> {
- public:
- explicit HasArgsMatcher(const JsArgList& expected_args)
- : expected_args_(expected_args) {}
-
- virtual ~HasArgsMatcher() {}
-
- virtual bool MatchAndExplain(
- const JsArgList& args,
- ::testing::MatchResultListener* listener) const {
- // No need to annotate listener since we already define PrintTo().
- return args.Get().Equals(&expected_args_.Get());
- }
-
- virtual void DescribeTo(::std::ostream* os) const {
- *os << "has args " << expected_args_.ToString();
- }
-
- virtual void DescribeNegationTo(::std::ostream* os) const {
- *os << "doesn't have args " << expected_args_.ToString();
- }
-
- private:
- const JsArgList expected_args_;
-
- DISALLOW_COPY_AND_ASSIGN(HasArgsMatcher);
-};
-
// Matcher implementation for HasDetails().
class HasDetailsMatcher
: public ::testing::MatcherInterface<const JsEventDetails&> {
@@ -83,10 +48,6 @@ class HasDetailsMatcher
} // namespace
-::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args) {
- return ::testing::MakeMatcher(new HasArgsMatcher(expected_args));
-}
-
::testing::Matcher<const JsEventDetails&> HasDetails(
const JsEventDetails& expected_details) {
return ::testing::MakeMatcher(new HasDetailsMatcher(expected_details));
@@ -119,13 +80,5 @@ WeakHandle<JsEventHandler> MockJsEventHandler::AsWeakHandle() {
MockJsEventHandler::~MockJsEventHandler() {}
-MockJsReplyHandler::MockJsReplyHandler() {}
-
-MockJsReplyHandler::~MockJsReplyHandler() {}
-
-WeakHandle<JsReplyHandler> MockJsReplyHandler::AsWeakHandle() {
- return MakeWeakHandle(AsWeakPtr());
-}
-
} // namespace syncer
diff --git a/sync/js/js_test_util.h b/sync/js/js_test_util.h
index 8f98248..b5ae4e8 100644
--- a/sync/js/js_test_util.h
+++ b/sync/js/js_test_util.h
@@ -13,7 +13,6 @@
#include "sync/js/js_backend.h"
#include "sync/js/js_controller.h"
#include "sync/js/js_event_handler.h"
-#include "sync/js/js_reply_handler.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace base {
@@ -23,18 +22,11 @@ class ListValue;
namespace syncer {
-class JsArgList;
class JsEventDetails;
// Defined for googletest. Equivalent to "*os << args.ToString()".
-void PrintTo(const JsArgList& args, ::std::ostream* os);
void PrintTo(const JsEventDetails& details, ::std::ostream* os);
-// A gmock matcher for JsArgList. Use like:
-//
-// EXPECT_CALL(mock, HandleJsReply("foo", HasArgs(expected_args)));
-::testing::Matcher<const JsArgList&> HasArgs(const JsArgList& expected_args);
-
// A gmock matcher for JsEventDetails. Use like:
//
// EXPECT_CALL(mock, HandleJsEvent("foo", HasArgs(expected_details)));
@@ -56,8 +48,6 @@ class MockJsBackend : public JsBackend,
WeakHandle<JsBackend> AsWeakHandle();
MOCK_METHOD1(SetJsEventHandler, void(const WeakHandle<JsEventHandler>&));
- MOCK_METHOD3(ProcessJsMessage, void(const ::std::string&, const JsArgList&,
- const WeakHandle<JsReplyHandler>&));
};
class MockJsController : public JsController,
@@ -68,9 +58,6 @@ class MockJsController : public JsController,
MOCK_METHOD1(AddJsEventHandler, void(JsEventHandler*));
MOCK_METHOD1(RemoveJsEventHandler, void(JsEventHandler*));
- MOCK_METHOD3(ProcessJsMessage,
- void(const ::std::string&, const JsArgList&,
- const WeakHandle<JsReplyHandler>&));
};
class MockJsEventHandler
@@ -86,19 +73,6 @@ class MockJsEventHandler
void(const ::std::string&, const JsEventDetails&));
};
-class MockJsReplyHandler
- : public JsReplyHandler,
- public base::SupportsWeakPtr<MockJsReplyHandler> {
- public:
- MockJsReplyHandler();
- virtual ~MockJsReplyHandler();
-
- WeakHandle<JsReplyHandler> AsWeakHandle();
-
- MOCK_METHOD2(HandleJsReply,
- void(const ::std::string&, const JsArgList&));
-};
-
} // namespace syncer
#endif // SYNC_JS_JS_TEST_UTIL_H_
diff --git a/sync/js/sync_js_controller.cc b/sync/js/sync_js_controller.cc
index 4d3148f..42199d2 100644
--- a/sync/js/sync_js_controller.cc
+++ b/sync/js/sync_js_controller.cc
@@ -10,13 +10,6 @@
namespace syncer {
-SyncJsController::PendingJsMessage::PendingJsMessage(
- const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler)
- : name(name), args(args), reply_handler(reply_handler) {}
-
-SyncJsController::PendingJsMessage::~PendingJsMessage() {}
-
SyncJsController::SyncJsController() {}
SyncJsController::~SyncJsController() {
@@ -37,28 +30,6 @@ void SyncJsController::AttachJsBackend(
const WeakHandle<JsBackend>& js_backend) {
js_backend_ = js_backend;
UpdateBackendEventHandler();
-
- if (js_backend_.IsInitialized()) {
- // Process any queued messages.
- for (PendingJsMessageList::const_iterator it =
- pending_js_messages_.begin();
- it != pending_js_messages_.end(); ++it) {
- js_backend_.Call(FROM_HERE, &JsBackend::ProcessJsMessage,
- it->name, it->args, it->reply_handler);
- }
- }
-}
-
-void SyncJsController::ProcessJsMessage(
- const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler) {
- if (js_backend_.IsInitialized()) {
- js_backend_.Call(FROM_HERE, &JsBackend::ProcessJsMessage,
- name, args, reply_handler);
- } else {
- pending_js_messages_.push_back(
- PendingJsMessage(name, args, reply_handler));
- }
}
void SyncJsController::HandleJsEvent(const std::string& name,
diff --git a/sync/js/sync_js_controller.h b/sync/js/sync_js_controller.h
index 0e259f8..f0bb423 100644
--- a/sync/js/sync_js_controller.h
+++ b/sync/js/sync_js_controller.h
@@ -14,7 +14,6 @@
#include "base/observer_list.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/util/weak_handle.h"
-#include "sync/js/js_arg_list.h"
#include "sync/js/js_controller.h"
#include "sync/js/js_event_handler.h"
@@ -39,39 +38,18 @@ class SYNC_EXPORT SyncJsController
// JsController implementation.
virtual void AddJsEventHandler(JsEventHandler* event_handler) OVERRIDE;
virtual void RemoveJsEventHandler(JsEventHandler* event_handler) OVERRIDE;
- // Queues up any messages that are sent when there is no attached
- // initialized backend.
- virtual void ProcessJsMessage(
- const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE;
// JsEventHandler implementation.
virtual void HandleJsEvent(const std::string& name,
const JsEventDetails& details) OVERRIDE;
private:
- // A struct used to hold the arguments to ProcessJsMessage() for
- // future invocation.
- struct PendingJsMessage {
- std::string name;
- JsArgList args;
- WeakHandle<JsReplyHandler> reply_handler;
-
- PendingJsMessage(const std::string& name, const JsArgList& args,
- const WeakHandle<JsReplyHandler>& reply_handler);
-
- ~PendingJsMessage();
- };
-
- typedef std::vector<PendingJsMessage> PendingJsMessageList;
-
// Sets |js_backend_|'s event handler depending on how many
// underlying event handlers we have.
void UpdateBackendEventHandler();
WeakHandle<JsBackend> js_backend_;
ObserverList<JsEventHandler> js_event_handlers_;
- PendingJsMessageList pending_js_messages_;
DISALLOW_COPY_AND_ASSIGN(SyncJsController);
};
diff --git a/sync/js/sync_js_controller_unittest.cc b/sync/js/sync_js_controller_unittest.cc
index eca617c..f6f1abf 100644
--- a/sync/js/sync_js_controller_unittest.cc
+++ b/sync/js/sync_js_controller_unittest.cc
@@ -6,7 +6,6 @@
#include "base/message_loop/message_loop.h"
#include "base/values.h"
-#include "sync/js/js_arg_list.h"
#include "sync/js/js_event_details.h"
#include "sync/js/js_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -30,91 +29,6 @@ class SyncJsControllerTest : public testing::Test {
base::MessageLoop message_loop_;
};
-ACTION_P(ReplyToMessage, reply_name) {
- arg2.Call(FROM_HERE, &JsReplyHandler::HandleJsReply, reply_name, JsArgList());
-}
-
-TEST_F(SyncJsControllerTest, Messages) {
- InSequence dummy;
- // |mock_backend| needs to outlive |sync_js_controller|.
- StrictMock<MockJsBackend> mock_backend;
- StrictMock<MockJsReplyHandler> mock_reply_handler;
- SyncJsController sync_js_controller;
-
- base::ListValue arg_list1, arg_list2;
- arg_list1.Append(new base::FundamentalValue(false));
- arg_list2.Append(new base::FundamentalValue(5));
- JsArgList args1(&arg_list1), args2(&arg_list2);
-
- EXPECT_CALL(mock_backend, SetJsEventHandler(_));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _))
- .WillOnce(ReplyToMessage("test1_reply"));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _))
- .WillOnce(ReplyToMessage("test2_reply"));
-
- sync_js_controller.AttachJsBackend(mock_backend.AsWeakHandle());
- sync_js_controller.ProcessJsMessage("test1",
- args2,
- mock_reply_handler.AsWeakHandle());
- sync_js_controller.ProcessJsMessage("test2",
- args1,
- mock_reply_handler.AsWeakHandle());
-
- // The replies should be waiting on our message loop.
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test1_reply", _));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test2_reply", _));
- PumpLoop();
-
- // Let destructor of |sync_js_controller| call RemoveBackend().
-}
-
-TEST_F(SyncJsControllerTest, QueuedMessages) {
- // |mock_backend| needs to outlive |sync_js_controller|.
- StrictMock<MockJsBackend> mock_backend;
- StrictMock<MockJsReplyHandler> mock_reply_handler;
- SyncJsController sync_js_controller;
-
- base::ListValue arg_list1, arg_list2;
- arg_list1.Append(new base::FundamentalValue(false));
- arg_list2.Append(new base::FundamentalValue(5));
- JsArgList args1(&arg_list1), args2(&arg_list2);
-
- // Should queue messages.
- sync_js_controller.ProcessJsMessage(
- "test1",
- args2,
- mock_reply_handler.AsWeakHandle());
- sync_js_controller.ProcessJsMessage(
- "test2",
- args1,
- mock_reply_handler.AsWeakHandle());
-
- // Should do nothing.
- PumpLoop();
- Mock::VerifyAndClearExpectations(&mock_backend);
-
-
- // Should call the queued messages.
- EXPECT_CALL(mock_backend, SetJsEventHandler(_));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _))
- .WillOnce(ReplyToMessage("test1_reply"));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _))
- .WillOnce(ReplyToMessage("test2_reply"));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test1_reply", _));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test2_reply", _));
-
- sync_js_controller.AttachJsBackend(mock_backend.AsWeakHandle());
- PumpLoop();
-
- // Should do nothing.
- sync_js_controller.AttachJsBackend(WeakHandle<JsBackend>());
- PumpLoop();
-
- // Should also do nothing.
- sync_js_controller.AttachJsBackend(WeakHandle<JsBackend>());
- PumpLoop();
-}
-
TEST_F(SyncJsControllerTest, Events) {
InSequence dummy;
SyncJsController sync_js_controller;