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

Side by Side Diff: chrome/browser/signin/signin_manager.cc

Issue 126033004: Clean up ChildProcessHost unique id generation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 6 years, 11 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) 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 "chrome/browser/signin/signin_manager.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/signin/signin_manager_cookie_helper.h" 26 #include "chrome/browser/signin/signin_manager_cookie_helper.h"
27 #include "chrome/browser/signin/signin_manager_delegate.h" 27 #include "chrome/browser/signin/signin_manager_delegate.h"
28 #include "chrome/browser/signin/signin_manager_factory.h" 28 #include "chrome/browser/signin/signin_manager_factory.h"
29 #include "chrome/browser/ui/global_error/global_error_service.h" 29 #include "chrome/browser/ui/global_error/global_error_service.h"
30 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 30 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/common/profile_management_switches.h" 32 #include "chrome/common/profile_management_switches.h"
33 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/notification_service.h" 34 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/render_process_host.h" 35 #include "content/public/browser/render_process_host.h"
36 #include "content/public/common/child_process_host.h"
36 #include "google_apis/gaia/gaia_auth_fetcher.h" 37 #include "google_apis/gaia/gaia_auth_fetcher.h"
37 #include "google_apis/gaia/gaia_auth_util.h" 38 #include "google_apis/gaia/gaia_auth_util.h"
38 #include "google_apis/gaia/gaia_constants.h" 39 #include "google_apis/gaia/gaia_constants.h"
39 #include "google_apis/gaia/gaia_urls.h" 40 #include "google_apis/gaia/gaia_urls.h"
40 #include "net/base/escape.h" 41 #include "net/base/escape.h"
41 #include "net/url_request/url_request_context.h" 42 #include "net/url_request/url_request_context.h"
42 #include "third_party/icu/source/i18n/unicode/regex.h" 43 #include "third_party/icu/source/i18n/unicode/regex.h"
43 44
44 using namespace signin_internals_util; 45 using namespace signin_internals_util;
45 46
46 using content::BrowserThread; 47 using content::BrowserThread;
48 using content::ChildProcessHost;
47 49
48 namespace { 50 namespace {
49 51
50 const char kGetInfoDisplayEmailKey[] = "displayEmail"; 52 const char kGetInfoDisplayEmailKey[] = "displayEmail";
51 const char kGetInfoEmailKey[] = "email"; 53 const char kGetInfoEmailKey[] = "email";
52 54
53 const int kInvalidProcessId = -1;
54
55 const char kChromiumSyncService[] = "service=chromiumsync"; 55 const char kChromiumSyncService[] = "service=chromiumsync";
56 56
57 } // namespace 57 } // namespace
58 58
59 // Under the covers, we use a dummy chrome-extension ID to serve the purposes 59 // Under the covers, we use a dummy chrome-extension ID to serve the purposes
60 // outlined in the .h file comment for this string. 60 // outlined in the .h file comment for this string.
61 const char* SigninManager::kChromeSigninEffectiveSite = 61 const char* SigninManager::kChromeSigninEffectiveSite =
62 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih"; 62 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih";
63 63
64 // static 64 // static
(...skipping 14 matching lines...) Expand all
79 return net::UnescapeURLComponent( 79 return net::UnescapeURLComponent(
80 url.query(), net::UnescapeRule::URL_SPECIAL_CHARS) 80 url.query(), net::UnescapeRule::URL_SPECIAL_CHARS)
81 .find(kChromiumSyncService) != std::string::npos; 81 .find(kChromiumSyncService) != std::string::npos;
82 } 82 }
83 83
84 SigninManager::SigninManager(scoped_ptr<SigninManagerDelegate> delegate) 84 SigninManager::SigninManager(scoped_ptr<SigninManagerDelegate> delegate)
85 : prohibit_signout_(false), 85 : prohibit_signout_(false),
86 had_two_factor_error_(false), 86 had_two_factor_error_(false),
87 type_(SIGNIN_TYPE_NONE), 87 type_(SIGNIN_TYPE_NONE),
88 weak_pointer_factory_(this), 88 weak_pointer_factory_(this),
89 signin_process_id_(kInvalidProcessId), 89 signin_host_id_(ChildProcessHost::kInvalidUniqueID),
90 delegate_(delegate.Pass()) { 90 delegate_(delegate.Pass()) {
91 } 91 }
92 92
93 void SigninManager::SetSigninProcess(int process_id) { 93 void SigninManager::SetSigninProcess(int process_id) {
94 if (process_id == signin_process_id_) 94 if (process_id == signin_host_id_)
95 return; 95 return;
96 DLOG_IF(WARNING, signin_process_id_ != kInvalidProcessId) << 96 DLOG_IF(WARNING,
97 "Replacing in-use signin process."; 97 signin_host_id_ != ChildProcessHost::kInvalidUniqueID)
98 signin_process_id_ = process_id; 98 << "Replacing in-use signin process.";
99 signin_host_id_ = process_id;
99 const content::RenderProcessHost* process = 100 const content::RenderProcessHost* process =
100 content::RenderProcessHost::FromID(process_id); 101 content::RenderProcessHost::FromID(process_id);
101 DCHECK(process); 102 DCHECK(process);
102 registrar_.Add(this, 103 registrar_.Add(this,
103 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 104 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
104 content::Source<content::RenderProcessHost>(process)); 105 content::Source<content::RenderProcessHost>(process));
105 } 106 }
106 107
107 void SigninManager::ClearSigninProcess() { 108 void SigninManager::ClearSigninProcess() {
108 signin_process_id_ = kInvalidProcessId; 109 signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
109 } 110 }
110 111
111 bool SigninManager::IsSigninProcess(int process_id) const { 112 bool SigninManager::IsSigninProcess(int process_id) const {
112 return process_id == signin_process_id_; 113 return process_id == signin_host_id_;
113 } 114 }
114 115
115 bool SigninManager::HasSigninProcess() const { 116 bool SigninManager::HasSigninProcess() const {
116 return signin_process_id_ != kInvalidProcessId; 117 return signin_host_id_ != ChildProcessHost::kInvalidUniqueID;
117 } 118 }
118 119
119 SigninManager::~SigninManager() { 120 SigninManager::~SigninManager() {
120 } 121 }
121 122
122 void SigninManager::InitTokenService() { 123 void SigninManager::InitTokenService() {
123 ProfileOAuth2TokenService* token_service = 124 ProfileOAuth2TokenService* token_service =
124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 125 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
125 if (token_service && !GetAuthenticatedUsername().empty()) 126 if (token_service && !GetAuthenticatedUsername().empty())
126 token_service->LoadCredentials(); 127 token_service->LoadCredentials();
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 OnClientLoginFailure(error); 600 OnClientLoginFailure(error);
600 } 601 }
601 602
602 void SigninManager::Observe(int type, 603 void SigninManager::Observe(int type,
603 const content::NotificationSource& source, 604 const content::NotificationSource& source,
604 const content::NotificationDetails& details) { 605 const content::NotificationDetails& details) {
605 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type); 606 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type);
606 607
607 // It's possible we're listening to a "stale" renderer because it was 608 // It's possible we're listening to a "stale" renderer because it was
608 // replaced with a new process by process-per-site. In either case, 609 // replaced with a new process by process-per-site. In either case,
609 // stop listening to it, but only reset signin_process_id_ tracking 610 // stop listening to it, but only reset signin_host_id_ tracking
610 // if this was from the current signin process. 611 // if this was from the current signin process.
611 registrar_.Remove(this, 612 registrar_.Remove(this,
612 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 613 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
613 source); 614 source);
614 if (signin_process_id_ == 615 if (signin_host_id_ ==
615 content::Source<content::RenderProcessHost>(source)->GetID()) { 616 content::Source<content::RenderProcessHost>(source)->GetID()) {
616 signin_process_id_ = kInvalidProcessId; 617 signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
617 } 618 }
618 } 619 }
619 620
620 void SigninManager::ProhibitSignout(bool prohibit_signout) { 621 void SigninManager::ProhibitSignout(bool prohibit_signout) {
621 prohibit_signout_ = prohibit_signout; 622 prohibit_signout_ = prohibit_signout;
622 } 623 }
623 624
624 bool SigninManager::IsSignoutProhibited() const { 625 bool SigninManager::IsSignoutProhibited() const {
625 return prohibit_signout_; 626 return prohibit_signout_;
626 } 627 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | content/browser/dom_storage/dom_storage_namespace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698