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

Side by Side Diff: content/browser/devtools/devtools_http_handler_unittest.cc

Issue 20142003: Remove ref-counting from StreamListenSocket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test/test_server.cc ('k') | content/browser/devtools/tethering_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/browser/browser_thread_impl.h" 7 #include "content/browser/browser_thread_impl.h"
8 #include "content/public/browser/devtools_http_handler.h" 8 #include "content/public/browser/devtools_http_handler.h"
9 #include "content/public/browser/devtools_http_handler_delegate.h" 9 #include "content/public/browser/devtools_http_handler_delegate.h"
10 #include "net/socket/stream_listen_socket.h" 10 #include "net/socket/stream_listen_socket.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace content { 13 namespace content {
14 namespace { 14 namespace {
15 15
16 using net::StreamListenSocket; 16 using net::StreamListenSocket;
17 17
18 class DummyListenSocket : public StreamListenSocket, 18 class DummyListenSocket : public StreamListenSocket,
19 public StreamListenSocket::Delegate { 19 public StreamListenSocket::Delegate {
20 public: 20 public:
21 DummyListenSocket() 21 DummyListenSocket()
22 : StreamListenSocket(0, this) {} 22 : StreamListenSocket(0, this) {}
23 23
24 // StreamListenSocket::Delegate "implementation" 24 // StreamListenSocket::Delegate "implementation"
25 virtual void DidAccept(StreamListenSocket* server, 25 virtual void DidAccept(StreamListenSocket* server,
26 StreamListenSocket* connection) OVERRIDE {} 26 scoped_ptr<StreamListenSocket> connection) OVERRIDE {}
27 virtual void DidRead(StreamListenSocket* connection, 27 virtual void DidRead(StreamListenSocket* connection,
28 const char* data, 28 const char* data,
29 int len) OVERRIDE {} 29 int len) OVERRIDE {}
30 virtual void DidClose(StreamListenSocket* sock) OVERRIDE {} 30 virtual void DidClose(StreamListenSocket* sock) OVERRIDE {}
31 protected: 31 protected:
32 virtual ~DummyListenSocket() {} 32 virtual ~DummyListenSocket() {}
33 virtual void Accept() OVERRIDE {} 33 virtual void Accept() OVERRIDE {}
34 }; 34 };
35 35
36 class DummyListenSocketFactory : public net::StreamListenSocketFactory { 36 class DummyListenSocketFactory : public net::StreamListenSocketFactory {
37 public: 37 public:
38 DummyListenSocketFactory( 38 DummyListenSocketFactory(
39 base::Closure quit_closure_1, base::Closure quit_closure_2) 39 base::Closure quit_closure_1, base::Closure quit_closure_2)
40 : quit_closure_1_(quit_closure_1), quit_closure_2_(quit_closure_2) {} 40 : quit_closure_1_(quit_closure_1), quit_closure_2_(quit_closure_2) {}
41 virtual ~DummyListenSocketFactory() { 41 virtual ~DummyListenSocketFactory() {
42 BrowserThread::PostTask( 42 BrowserThread::PostTask(
43 BrowserThread::UI, FROM_HERE, quit_closure_2_); 43 BrowserThread::UI, FROM_HERE, quit_closure_2_);
44 } 44 }
45 45
46 virtual scoped_refptr<StreamListenSocket> CreateAndListen( 46 virtual scoped_ptr<StreamListenSocket> CreateAndListen(
47 StreamListenSocket::Delegate* delegate) const OVERRIDE { 47 StreamListenSocket::Delegate* delegate) const OVERRIDE {
48 BrowserThread::PostTask( 48 BrowserThread::PostTask(
49 BrowserThread::UI, FROM_HERE, quit_closure_1_); 49 BrowserThread::UI, FROM_HERE, quit_closure_1_);
50 return new DummyListenSocket(); 50 return scoped_ptr<net::StreamListenSocket>(new DummyListenSocket());
51 } 51 }
52 private: 52 private:
53 base::Closure quit_closure_1_; 53 base::Closure quit_closure_1_;
54 base::Closure quit_closure_2_; 54 base::Closure quit_closure_2_;
55 }; 55 };
56 56
57 class DummyDelegate : public DevToolsHttpHandlerDelegate { 57 class DummyDelegate : public DevToolsHttpHandlerDelegate {
58 public: 58 public:
59 virtual std::string GetDiscoveryPageHTML() OVERRIDE { return std::string(); } 59 virtual std::string GetDiscoveryPageHTML() OVERRIDE { return std::string(); }
60 virtual bool BundlesFrontendResources() OVERRIDE { return true; } 60 virtual bool BundlesFrontendResources() OVERRIDE { return true; }
61 virtual base::FilePath GetDebugFrontendDir() OVERRIDE { 61 virtual base::FilePath GetDebugFrontendDir() OVERRIDE {
62 return base::FilePath(); 62 return base::FilePath();
63 } 63 }
64 virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE { 64 virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE {
65 return std::string(); 65 return std::string();
66 } 66 }
67 virtual RenderViewHost* CreateNewTarget() OVERRIDE { return NULL; } 67 virtual RenderViewHost* CreateNewTarget() OVERRIDE { return NULL; }
68 virtual TargetType GetTargetType(RenderViewHost*) OVERRIDE { 68 virtual TargetType GetTargetType(RenderViewHost*) OVERRIDE {
69 return kTargetTypeTab; 69 return kTargetTypeTab;
70 } 70 }
71 virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE { 71 virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE {
72 return std::string(); 72 return std::string();
73 } 73 }
74 virtual scoped_refptr<net::StreamListenSocket> CreateSocketForTethering( 74 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
75 net::StreamListenSocket::Delegate* delegate, 75 net::StreamListenSocket::Delegate* delegate,
76 std::string* name) OVERRIDE { 76 std::string* name) OVERRIDE {
77 return NULL; 77 return scoped_ptr<net::StreamListenSocket>();
78 } 78 }
79 }; 79 };
80 80
81 } 81 }
82 82
83 class DevToolsHttpHandlerTest : public testing::Test { 83 class DevToolsHttpHandlerTest : public testing::Test {
84 public: 84 public:
85 DevToolsHttpHandlerTest() 85 DevToolsHttpHandlerTest()
86 : ui_thread_(BrowserThread::UI, &message_loop_) { 86 : ui_thread_(BrowserThread::UI, &message_loop_) {
87 } 87 }
(...skipping 21 matching lines...) Expand all
109 new DummyDelegate()); 109 new DummyDelegate());
110 // Our dummy socket factory will post a quit message once the server will 110 // Our dummy socket factory will post a quit message once the server will
111 // become ready. 111 // become ready.
112 run_loop.Run(); 112 run_loop.Run();
113 devtools_http_handler_->Stop(); 113 devtools_http_handler_->Stop();
114 // Make sure the handler actually stops. 114 // Make sure the handler actually stops.
115 run_loop_2.Run(); 115 run_loop_2.Run();
116 } 116 }
117 117
118 } // namespace content 118 } // namespace content
OLDNEW
« no previous file with comments | « chrome_frame/test/test_server.cc ('k') | content/browser/devtools/tethering_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698