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

Side by Side Diff: content/browser/webui/web_ui_mojo_browsertest.cc

Issue 1832813002: Add mojom module suffix in .mojom files in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Tom's comment Created 4 years, 9 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
OLDNEW
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 #include <limits> 5 #include <limits>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 CHECK(base::PathService::Get(content::DIR_TEST_DATA, &path)); 58 CHECK(base::PathService::Get(content::DIR_TEST_DATA, &path));
59 path = path.AppendASCII(id.substr(0, id.find("?"))); 59 path = path.AppendASCII(id.substr(0, id.find("?")));
60 std::string contents; 60 std::string contents;
61 CHECK(base::ReadFileToString(path, &contents)) << path.value(); 61 CHECK(base::ReadFileToString(path, &contents)) << path.value();
62 base::RefCountedString* ref_contents = new base::RefCountedString; 62 base::RefCountedString* ref_contents = new base::RefCountedString;
63 ref_contents->data() = contents; 63 ref_contents->data() = contents;
64 callback.Run(ref_contents); 64 callback.Run(ref_contents);
65 return true; 65 return true;
66 } 66 }
67 67
68 class BrowserTargetImpl : public BrowserTarget { 68 class BrowserTargetImpl : public mojom::BrowserTarget {
69 public: 69 public:
70 BrowserTargetImpl(base::RunLoop* run_loop, 70 BrowserTargetImpl(base::RunLoop* run_loop,
71 mojo::InterfaceRequest<BrowserTarget> request) 71 mojo::InterfaceRequest<mojom::BrowserTarget> request)
72 : run_loop_(run_loop), binding_(this, std::move(request)) {} 72 : run_loop_(run_loop), binding_(this, std::move(request)) {}
73 73
74 ~BrowserTargetImpl() override {} 74 ~BrowserTargetImpl() override {}
75 75
76 // BrowserTarget overrides: 76 // mojom::BrowserTarget overrides:
77 void Start(const mojo::Closure& closure) override { 77 void Start(const mojo::Closure& closure) override {
78 closure.Run(); 78 closure.Run();
79 } 79 }
80 void Stop() override { 80 void Stop() override {
81 got_message = true; 81 got_message = true;
82 run_loop_->Quit(); 82 run_loop_->Quit();
83 } 83 }
84 84
85 protected: 85 protected:
86 base::RunLoop* run_loop_; 86 base::RunLoop* run_loop_;
87 87
88 private: 88 private:
89 mojo::Binding<BrowserTarget> binding_; 89 mojo::Binding<mojom::BrowserTarget> binding_;
90 DISALLOW_COPY_AND_ASSIGN(BrowserTargetImpl); 90 DISALLOW_COPY_AND_ASSIGN(BrowserTargetImpl);
91 }; 91 };
92 92
93 // WebUIController that sets up mojo bindings. 93 // WebUIController that sets up mojo bindings.
94 class TestWebUIController : public WebUIController { 94 class TestWebUIController : public WebUIController {
95 public: 95 public:
96 TestWebUIController(WebUI* web_ui, base::RunLoop* run_loop) 96 TestWebUIController(WebUI* web_ui, base::RunLoop* run_loop)
97 : WebUIController(web_ui), run_loop_(run_loop) { 97 : WebUIController(web_ui), run_loop_(run_loop) {
98 content::WebUIDataSource* data_source = 98 content::WebUIDataSource* data_source =
99 WebUIDataSource::Create("mojo-web-ui"); 99 WebUIDataSource::Create("mojo-web-ui");
(...skipping 14 matching lines...) Expand all
114 // implementation at the right time. 114 // implementation at the right time.
115 class PingTestWebUIController : public TestWebUIController { 115 class PingTestWebUIController : public TestWebUIController {
116 public: 116 public:
117 PingTestWebUIController(WebUI* web_ui, base::RunLoop* run_loop) 117 PingTestWebUIController(WebUI* web_ui, base::RunLoop* run_loop)
118 : TestWebUIController(web_ui, run_loop) { 118 : TestWebUIController(web_ui, run_loop) {
119 } 119 }
120 ~PingTestWebUIController() override {} 120 ~PingTestWebUIController() override {}
121 121
122 // WebUIController overrides: 122 // WebUIController overrides:
123 void RenderViewCreated(RenderViewHost* render_view_host) override { 123 void RenderViewCreated(RenderViewHost* render_view_host) override {
124 render_view_host->GetMainFrame()->GetServiceRegistry()-> 124 render_view_host->GetMainFrame()->GetServiceRegistry()->AddService(
125 AddService<BrowserTarget>(base::Bind( 125 base::Bind(&PingTestWebUIController::CreateHandler,
126 &PingTestWebUIController::CreateHandler, base::Unretained(this))); 126 base::Unretained(this)));
127 } 127 }
128 128
129 void CreateHandler(mojo::InterfaceRequest<BrowserTarget> request) { 129 void CreateHandler(mojo::InterfaceRequest<mojom::BrowserTarget> request) {
130 browser_target_.reset(new BrowserTargetImpl(run_loop_, std::move(request))); 130 browser_target_.reset(new BrowserTargetImpl(run_loop_, std::move(request)));
131 } 131 }
132 132
133 private: 133 private:
134 DISALLOW_COPY_AND_ASSIGN(PingTestWebUIController); 134 DISALLOW_COPY_AND_ASSIGN(PingTestWebUIController);
135 }; 135 };
136 136
137 // WebUIControllerFactory that creates TestWebUIController. 137 // WebUIControllerFactory that creates TestWebUIController.
138 class TestWebUIControllerFactory : public WebUIControllerFactory { 138 class TestWebUIControllerFactory : public WebUIControllerFactory {
139 public: 139 public:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html")); 240 GURL("chrome://mojo-web-ui/web_ui_mojo_shell_test.html"));
241 241
242 DOMMessageQueue message_queue; 242 DOMMessageQueue message_queue;
243 std::string message; 243 std::string message;
244 ASSERT_TRUE(message_queue.WaitForMessage(&message)); 244 ASSERT_TRUE(message_queue.WaitForMessage(&message));
245 EXPECT_EQ("true", message); 245 EXPECT_EQ("true", message);
246 } 246 }
247 247
248 } // namespace 248 } // namespace
249 } // namespace content 249 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/wake_lock/wake_lock_service_impl.cc ('k') | content/child/permissions/permission_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698