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: chrome/browser/idbbindingutilities_browsertest.cc

Issue 6805008: Remove RDH from UtilityProcessHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix presubmit. Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/utility_process_host.h" 7 #include "chrome/browser/utility_process_host.h"
8 #include "chrome/test/in_process_browser_test.h" 8 #include "chrome/test/in_process_browser_test.h"
9 #include "chrome/test/ui_test_utils.h" 9 #include "chrome/test/ui_test_utils.h"
10 #include "content/browser/renderer_host/resource_dispatcher_host.h" 10 #include "content/browser/renderer_host/resource_dispatcher_host.h"
11 #include "content/common/indexed_db_key.h" 11 #include "content/common/indexed_db_key.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 class IDBKeyPathHelper : public UtilityProcessHost::Client { 62 class IDBKeyPathHelper : public UtilityProcessHost::Client {
63 public: 63 public:
64 IDBKeyPathHelper() 64 IDBKeyPathHelper()
65 : expected_id_(0), 65 : expected_id_(0),
66 utility_process_host_(NULL), 66 utility_process_host_(NULL),
67 value_for_key_path_failed_(false) { 67 value_for_key_path_failed_(false) {
68 } 68 }
69 69
70 void CreateUtilityProcess(ResourceDispatcherHost* resource_dispatcher_host) { 70 void CreateUtilityProcess() {
71 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 71 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
72 BrowserThread::PostTask( 72 BrowserThread::PostTask(
73 BrowserThread::IO, FROM_HERE, 73 BrowserThread::IO, FROM_HERE,
74 NewRunnableMethod(this, &IDBKeyPathHelper::CreateUtilityProcess, 74 NewRunnableMethod(this, &IDBKeyPathHelper::CreateUtilityProcess));
75 resource_dispatcher_host));
76 return; 75 return;
77 } 76 }
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
79 utility_process_host_ = 78 utility_process_host_ =
80 new UtilityProcessHost(resource_dispatcher_host, this, 79 new UtilityProcessHost(this, BrowserThread::IO);
81 BrowserThread::IO);
82 utility_process_host_->StartBatchMode(); 80 utility_process_host_->StartBatchMode();
83 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 81 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
84 new MessageLoop::QuitTask()); 82 new MessageLoop::QuitTask());
85 } 83 }
86 84
87 void DestroyUtilityProcess() { 85 void DestroyUtilityProcess() {
88 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 86 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
89 BrowserThread::PostTask( 87 BrowserThread::PostTask(
90 BrowserThread::IO, FROM_HERE, 88 BrowserThread::IO, FROM_HERE,
91 NewRunnableMethod(this, &IDBKeyPathHelper::DestroyUtilityProcess)); 89 NewRunnableMethod(this, &IDBKeyPathHelper::DestroyUtilityProcess));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 184
187 // This test fixture runs in the UI thread. However, most of the work done by 185 // This test fixture runs in the UI thread. However, most of the work done by
188 // UtilityProcessHost (and wrapped by IDBKeyPathHelper above) happens on the IO 186 // UtilityProcessHost (and wrapped by IDBKeyPathHelper above) happens on the IO
189 // thread. This fixture delegates to IDBKeyPathHelper and blocks via 187 // thread. This fixture delegates to IDBKeyPathHelper and blocks via
190 // "ui_test_utils::RunMessageLoop()", until IDBKeyPathHelper posts a quit 188 // "ui_test_utils::RunMessageLoop()", until IDBKeyPathHelper posts a quit
191 // message the MessageLoop. 189 // message the MessageLoop.
192 class ScopedIDBKeyPathHelper { 190 class ScopedIDBKeyPathHelper {
193 public: 191 public:
194 ScopedIDBKeyPathHelper() { 192 ScopedIDBKeyPathHelper() {
195 key_path_helper_ = new IDBKeyPathHelper(); 193 key_path_helper_ = new IDBKeyPathHelper();
196 key_path_helper_->CreateUtilityProcess( 194 key_path_helper_->CreateUtilityProcess();
197 g_browser_process->resource_dispatcher_host());
198 ui_test_utils::RunMessageLoop(); 195 ui_test_utils::RunMessageLoop();
199 } 196 }
200 197
201 ~ScopedIDBKeyPathHelper() { 198 ~ScopedIDBKeyPathHelper() {
202 key_path_helper_->DestroyUtilityProcess(); 199 key_path_helper_->DestroyUtilityProcess();
203 ui_test_utils::RunMessageLoop(); 200 ui_test_utils::RunMessageLoop();
204 } 201 }
205 202
206 void SetExpectedKeys(int id, const std::vector<IndexedDBKey>& expected_keys, 203 void SetExpectedKeys(int id, const std::vector<IndexedDBKey>& expected_keys,
207 bool failed) { 204 bool failed) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 string16(expected_data, 320 string16(expected_data,
324 arraysize(expected_data))); 321 arraysize(expected_data)));
325 322
326 ScopedIDBKeyPathHelper scoped_helper; 323 ScopedIDBKeyPathHelper scoped_helper;
327 scoped_helper.SetExpectedValue(expected_value); 324 scoped_helper.SetExpectedValue(expected_value);
328 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar")); 325 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar"));
329 326
330 scoped_helper.SetExpectedValue(SerializedScriptValue()); // Expect null. 327 scoped_helper.SetExpectedValue(SerializedScriptValue()); // Expect null.
331 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bad.key.path")); 328 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bad.key.path"));
332 } 329 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_extension_unpacker.cc ('k') | chrome/browser/utility_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698