nsCOMPtr<nsIAtom> atom; res = ccMan->GetCharsetAtom(aCharset, getter_AddRefs(atom)); if (NS_FAILED(res)) return res;  res = AddCharsetToCache(ccMan, atom, &mBrowserMenu, kNC_BrowserCharsetMenuRoot, mBrowserCacheStart, mBrowserCacheSize, mBrowserMenuRDFPosition); if (NS_FAILED(res)) return res;    res = WriteCacheToPrefs(&mBrowserMenu, mBrowserCacheStart, kBrowserCachePrefKey);
res = WriteCacheToPrefs(&mBrowserMenu, mBrowserCacheStart, kBrowserCachePrefKey); } else { UpdateCachePrefs(kBrowserCachePrefKey, kBrowserCacheSizePrefKey, kBrowserStaticPrefKey, aCharset); } NS_TIMELINE_STOP_TIMER("nsCharsetMenu:SetCurrentCharset"); NS_TIMELINE_MARK_TIMER("nsCharsetMenu:SetCurrentCharset");
NS_IMETHODIMP nsCharsetMenu::SetCurrentCharset(const PRUnichar * aCharset){  nsresult res;  NS_WITH_SERVICE(nsICharsetConverterManager2, ccMan, kCharsetConverterManagerCID, &res);  if (NS_FAILED(res)) return res;  nsCOMPtr<nsIAtom> atom;  res = ccMan->GetCharsetAtom(aCharset, getter_AddRefs(atom));  if (NS_FAILED(res)) return res;  res = AddCharsetToCache(ccMan, atom, &mBrowserMenu,     kNC_BrowserCharsetMenuRoot, mBrowserCacheStart, mBrowserCacheSize, 	mBrowserMenuRDFPosition);  if (NS_FAILED(res)) return res;  // XXX maybe we should write out this string only when the application is   // being closed and only if the cache has changed? Or maybe IPref does that.  res = WriteCacheToPrefs(&mBrowserMenu, mBrowserCacheStart,     kBrowserCachePrefKey);  return res;}