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

Unified Diff: remoting/jingle_glue/iq_request.h

Issue 8432009: Refactor IqRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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
Index: remoting/jingle_glue/iq_request.h
diff --git a/remoting/jingle_glue/iq_request.h b/remoting/jingle_glue/iq_request.h
deleted file mode 100644
index d94e4d21d3ab8f1f957686922aa86ebd6d41b5a2..0000000000000000000000000000000000000000
--- a/remoting/jingle_glue/iq_request.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2011 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 REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
-#define REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
-
-#include <map>
-#include <string>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "remoting/jingle_glue/iq_request.h"
-
-namespace buzz {
-class XmlElement;
-} // namespace buzz
-
-namespace remoting {
-
-class IqRequest;
-class SignalStrategy;
-
-// IqRegistry handles routing of iq responses to corresponding
-// IqRequest objects. Created in SignalStrategy and should not be used
-// directly.
-//
-// TODO(sergeyu): Separate IqRegistry and IqRequest from
-// SignalStrategy and remove CreateIqRequest() method from SignalStrategy.
-class IqRegistry {
- public:
- IqRegistry();
- ~IqRegistry();
-
- // Dispatches the response to the IqRequest callback immediately.
- //
- // Does not take ownership of stanza.
- void DispatchResponse(buzz::XmlElement* stanza);
-
- // Registers |request| with the specified |id|.
- void RegisterRequest(IqRequest* request, const std::string& id);
-
- // Removes all entries in the registry that refer to |request|.
- void RemoveAllRequests(IqRequest* request);
-
- void SetDefaultHandler(IqRequest* default_request);
-
- // Called by SignalStrategy implementation. Returns true if the
- // stanza was handled and should not be processed further.
- bool OnIncomingStanza(const buzz::XmlElement* stanza);
-
- private:
- typedef std::map<std::string, IqRequest*> IqRequestMap;
-
- IqRequestMap requests_;
-
- DISALLOW_COPY_AND_ASSIGN(IqRegistry);
-};
-
-// This call must only be used on the thread it was created on.
-class IqRequest {
- public:
- typedef base::Callback<void(const buzz::XmlElement*)> ReplyCallback;
-
- static buzz::XmlElement* MakeIqStanza(const std::string& type,
- const std::string& addressee,
- buzz::XmlElement* iq_body);
-
- IqRequest(); // Should be used for tests only.
- IqRequest(SignalStrategy* signal_strategy, IqRegistry* registry);
- virtual ~IqRequest();
-
- // Sends Iq stanza. Takes ownership of |stanza|.
- virtual void SendIq(buzz::XmlElement* stanza);
-
- // Sets callback that is called when reply stanza is received.
- virtual void set_callback(const ReplyCallback& callback);
-
- private:
- friend class IqRegistry;
- FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza);
-
- ReplyCallback callback_;
- SignalStrategy* signal_strategy_;
- IqRegistry* registry_;
-
- DISALLOW_COPY_AND_ASSIGN(IqRequest);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_JINGLE_GLUE_IQ_REQUEST_H_

Powered by Google App Engine
This is Rietveld 408576698