mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 02:09:05 +02:00 
			
		
		
		
	Bug 1901387 - Part 1: Ensure URLInfo is safe to use OMT, r=extension-reviewers,robwu
Previously accessing Scheme() on a URLInfo was main-thread-only. As more extension methods are used OMT, this needs to be switched to the threadsafe NS_Atomize method instead. Differential Revision: https://phabricator.services.mozilla.com/D215024
This commit is contained in:
		
							parent
							
								
									ecd9936d55
								
							
						
					
					
						commit
						d189a217e9
					
				
					 2 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -119,7 +119,7 @@ nsAtom* URLInfo::Scheme() const {
 | 
				
			||||||
  if (!mScheme) {
 | 
					  if (!mScheme) {
 | 
				
			||||||
    nsCString scheme;
 | 
					    nsCString scheme;
 | 
				
			||||||
    if (NS_SUCCEEDED(mURI->GetScheme(scheme))) {
 | 
					    if (NS_SUCCEEDED(mURI->GetScheme(scheme))) {
 | 
				
			||||||
      mScheme = NS_AtomizeMainThread(NS_ConvertASCIItoUTF16(scheme));
 | 
					      mScheme = NS_Atomize(scheme);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return mScheme;
 | 
					  return mScheme;
 | 
				
			||||||
| 
						 | 
					@ -196,6 +196,7 @@ bool URLInfo::InheritsPrincipal() const {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool URLInfo::IsNonOpaqueURL() const {
 | 
					bool URLInfo::IsNonOpaqueURL() const {
 | 
				
			||||||
 | 
					  MOZ_ASSERT(NS_IsMainThread());
 | 
				
			||||||
  if (!mIsNonOpaqueURL.isSome()) {
 | 
					  if (!mIsNonOpaqueURL.isSome()) {
 | 
				
			||||||
    RefPtr<AtomSet> nonOpaqueSchemes = NonOpaqueSchemes();
 | 
					    RefPtr<AtomSet> nonOpaqueSchemes = NonOpaqueSchemes();
 | 
				
			||||||
    mIsNonOpaqueURL.emplace(nonOpaqueSchemes->Contains(Scheme()));
 | 
					    mIsNonOpaqueURL.emplace(nonOpaqueSchemes->Contains(Scheme()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,6 +112,8 @@ class URLInfo final {
 | 
				
			||||||
  // that document were to have an opaque origin (null principal).
 | 
					  // that document were to have an opaque origin (null principal).
 | 
				
			||||||
  // These URLs are more verbose than the precursor (origin) of a null
 | 
					  // These URLs are more verbose than the precursor (origin) of a null
 | 
				
			||||||
  // principal, and therefore preferred for matching purposes.
 | 
					  // principal, and therefore preferred for matching purposes.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // NOTE: This method is main-thread only
 | 
				
			||||||
  bool IsNonOpaqueURL() const;
 | 
					  bool IsNonOpaqueURL() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 private:
 | 
					 private:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue