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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 3524012: Rename ChromeThread to BrowserThread Part 2: (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include "app/message_box_flags.h" 7 #include "app/message_box_flags.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 DISALLOW_COPY_AND_ASSIGN(GetCookiesTask); 91 DISALLOW_COPY_AND_ASSIGN(GetCookiesTask);
92 }; 92 };
93 93
94 std::string GetCookiesForURL( 94 std::string GetCookiesForURL(
95 const GURL& url, 95 const GURL& url,
96 URLRequestContextGetter* context_getter) { 96 URLRequestContextGetter* context_getter) {
97 std::string cookies; 97 std::string cookies;
98 base::WaitableEvent event(true /* manual reset */, 98 base::WaitableEvent event(true /* manual reset */,
99 false /* not initially signaled */); 99 false /* not initially signaled */);
100 CHECK(ChromeThread::PostTask( 100 CHECK(BrowserThread::PostTask(
101 ChromeThread::IO, FROM_HERE, 101 BrowserThread::IO, FROM_HERE,
102 new GetCookiesTask(url, context_getter, &event, &cookies))); 102 new GetCookiesTask(url, context_getter, &event, &cookies)));
103 event.Wait(); 103 event.Wait();
104 return cookies; 104 return cookies;
105 } 105 }
106 106
107 class SetCookieTask : public Task { 107 class SetCookieTask : public Task {
108 public: 108 public:
109 SetCookieTask(const GURL& url, 109 SetCookieTask(const GURL& url,
110 const std::string& value, 110 const std::string& value,
111 URLRequestContextGetter* context_getter, 111 URLRequestContextGetter* context_getter,
(...skipping 20 matching lines...) Expand all
132 DISALLOW_COPY_AND_ASSIGN(SetCookieTask); 132 DISALLOW_COPY_AND_ASSIGN(SetCookieTask);
133 }; 133 };
134 134
135 bool SetCookieForURL( 135 bool SetCookieForURL(
136 const GURL& url, 136 const GURL& url,
137 const std::string& value, 137 const std::string& value,
138 URLRequestContextGetter* context_getter) { 138 URLRequestContextGetter* context_getter) {
139 base::WaitableEvent event(true /* manual reset */, 139 base::WaitableEvent event(true /* manual reset */,
140 false /* not initially signaled */); 140 false /* not initially signaled */);
141 bool rv = false; 141 bool rv = false;
142 CHECK(ChromeThread::PostTask( 142 CHECK(BrowserThread::PostTask(
143 ChromeThread::IO, FROM_HERE, 143 BrowserThread::IO, FROM_HERE,
144 new SetCookieTask(url, value, context_getter, &event, &rv))); 144 new SetCookieTask(url, value, context_getter, &event, &rv)));
145 event.Wait(); 145 event.Wait();
146 return rv; 146 return rv;
147 } 147 }
148 148
149 class DeleteCookieTask : public Task { 149 class DeleteCookieTask : public Task {
150 public: 150 public:
151 DeleteCookieTask(const GURL& url, 151 DeleteCookieTask(const GURL& url,
152 const std::string& name, 152 const std::string& name,
153 const scoped_refptr<URLRequestContextGetter>& context_getter) 153 const scoped_refptr<URLRequestContextGetter>& context_getter)
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 *response_value = 1; 566 *response_value = 1;
567 } 567 }
568 } 568 }
569 569
570 void TestingAutomationProvider::DeleteCookie(const GURL& url, 570 void TestingAutomationProvider::DeleteCookie(const GURL& url,
571 const std::string& cookie_name, 571 const std::string& cookie_name,
572 int handle, bool* success) { 572 int handle, bool* success) {
573 *success = false; 573 *success = false;
574 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { 574 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) {
575 NavigationController* tab = tab_tracker_->GetResource(handle); 575 NavigationController* tab = tab_tracker_->GetResource(handle);
576 ChromeThread::PostTask( 576 BrowserThread::PostTask(
577 ChromeThread::IO, FROM_HERE, 577 BrowserThread::IO, FROM_HERE,
578 new DeleteCookieTask(url, cookie_name, 578 new DeleteCookieTask(url, cookie_name,
579 tab->profile()->GetRequestContext())); 579 tab->profile()->GetRequestContext()));
580 *success = true; 580 *success = true;
581 } 581 }
582 } 582 }
583 583
584 void TestingAutomationProvider::ShowCollectedCookiesDialog( 584 void TestingAutomationProvider::ShowCollectedCookiesDialog(
585 int handle, bool* success) { 585 int handle, bool* success) {
586 *success = false; 586 *success = false;
587 if (tab_tracker_->ContainsHandle(handle)) { 587 if (tab_tracker_->ContainsHandle(handle)) {
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 // honor the semantics of BrowserChildProcessHost. 2269 // honor the semantics of BrowserChildProcessHost.
2270 // Used by AutomationProvider::GetBrowserInfo(). 2270 // Used by AutomationProvider::GetBrowserInfo().
2271 class GetChildProcessHostInfoTask : public Task { 2271 class GetChildProcessHostInfoTask : public Task {
2272 public: 2272 public:
2273 GetChildProcessHostInfoTask(base::WaitableEvent* event, 2273 GetChildProcessHostInfoTask(base::WaitableEvent* event,
2274 ListValue* child_processes) 2274 ListValue* child_processes)
2275 : event_(event), 2275 : event_(event),
2276 child_processes_(child_processes) {} 2276 child_processes_(child_processes) {}
2277 2277
2278 virtual void Run() { 2278 virtual void Run() {
2279 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 2279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2280 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { 2280 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
2281 // Only add processes which are already started, 2281 // Only add processes which are already started,
2282 // since we need their handle. 2282 // since we need their handle.
2283 if ((*iter)->handle() == base::kNullProcessHandle) { 2283 if ((*iter)->handle() == base::kNullProcessHandle) {
2284 continue; 2284 continue;
2285 } 2285 }
2286 ChildProcessInfo* info = *iter; 2286 ChildProcessInfo* info = *iter;
2287 DictionaryValue* item = new DictionaryValue; 2287 DictionaryValue* item = new DictionaryValue;
2288 item->SetString("name", WideToUTF16Hack(info->name())); 2288 item->SetString("name", WideToUTF16Hack(info->name()));
2289 item->SetString("type", 2289 item->SetString("type",
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 return_value->Set("windows", windows); 2381 return_value->Set("windows", windows);
2382 2382
2383 return_value->SetString("child_process_path", 2383 return_value->SetString("child_process_path",
2384 ChildProcessHost::GetChildPath(true).value()); 2384 ChildProcessHost::GetChildPath(true).value());
2385 // Child processes are the processes for plugins and other workers. 2385 // Child processes are the processes for plugins and other workers.
2386 // Add all child processes in a list of dictionaries, one dictionary item 2386 // Add all child processes in a list of dictionaries, one dictionary item
2387 // per child process. 2387 // per child process.
2388 ListValue* child_processes = new ListValue; 2388 ListValue* child_processes = new ListValue;
2389 base::WaitableEvent event(true /* manual reset */, 2389 base::WaitableEvent event(true /* manual reset */,
2390 false /* not initially signaled */); 2390 false /* not initially signaled */);
2391 CHECK(ChromeThread::PostTask( 2391 CHECK(BrowserThread::PostTask(
2392 ChromeThread::IO, FROM_HERE, 2392 BrowserThread::IO, FROM_HERE,
2393 new GetChildProcessHostInfoTask(&event, child_processes))); 2393 new GetChildProcessHostInfoTask(&event, child_processes)));
2394 event.Wait(); 2394 event.Wait();
2395 return_value->Set("child_processes", child_processes); 2395 return_value->Set("child_processes", child_processes);
2396 2396
2397 // Add all extension processes in a list of dictionaries, one dictionary 2397 // Add all extension processes in a list of dictionaries, one dictionary
2398 // item per extension process. 2398 // item per extension process.
2399 ListValue* extension_processes = new ListValue; 2399 ListValue* extension_processes = new ListValue;
2400 ProfileManager* profile_manager = g_browser_process->profile_manager(); 2400 ProfileManager* profile_manager = g_browser_process->profile_manager();
2401 for (ProfileManager::const_iterator it = profile_manager->begin(); 2401 for (ProfileManager::const_iterator it = profile_manager->begin();
2402 it != profile_manager->end(); ++it) { 2402 it != profile_manager->end(); ++it) {
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 DCHECK(type == NotificationType::SESSION_END); 3903 DCHECK(type == NotificationType::SESSION_END);
3904 // OnBrowserRemoving does a ReleaseLater. When session end is received we exit 3904 // OnBrowserRemoving does a ReleaseLater. When session end is received we exit
3905 // before the task runs resulting in this object not being deleted. This 3905 // before the task runs resulting in this object not being deleted. This
3906 // Release balance out the Release scheduled by OnBrowserRemoving. 3906 // Release balance out the Release scheduled by OnBrowserRemoving.
3907 Release(); 3907 Release();
3908 } 3908 }
3909 3909
3910 void TestingAutomationProvider::OnRemoveProvider() { 3910 void TestingAutomationProvider::OnRemoveProvider() {
3911 AutomationProviderList::GetInstance()->RemoveProvider(this); 3911 AutomationProviderList::GetInstance()->RemoveProvider(this);
3912 } 3912 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698