diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 16:07:14 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 16:07:14 +0000 |
commit | 6314e6f6d7ac203479afe79a46a3e592a2a8da69 (patch) | |
tree | 46f6de1466dfa7f7172045333d26063c3405c1dd | |
parent | 8b98be9556c88fb7cc231305fa707a6a18595738 (diff) | |
download | chromium_src-6314e6f6d7ac203479afe79a46a3e592a2a8da69.zip chromium_src-6314e6f6d7ac203479afe79a46a3e592a2a8da69.tar.gz chromium_src-6314e6f6d7ac203479afe79a46a3e592a2a8da69.tar.bz2 |
Fix a bunch of minor Coverity issues.
- pass more things by const reference
- check return codes (minor severity)
Review URL: http://codereview.chromium.org/149643
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20731 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 6 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 2 | ||||
-rw-r--r-- | chrome/browser/net/dns_master_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/net/referrer.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/referrer.h | 2 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_protect.cc | 5 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_protect.h | 4 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/net/url_fixer_upper.cc | 5 | ||||
-rw-r--r-- | chrome/common/ipc_sync_channel_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/common/page_action.h | 4 | ||||
-rw-r--r-- | chrome/common/worker_thread_ticker.cc | 3 |
12 files changed, 22 insertions, 20 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 0ddd745..3668328 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -334,12 +334,12 @@ void ChromeURLRequestContext::Observe(NotificationType type, &ChromeURLRequestContext::OnAcceptLanguageChange, accept_language)); } else if (*pref_name_in == prefs::kCookieBehavior) { - net::CookiePolicy::Type type = net::CookiePolicy::FromInt( + net::CookiePolicy::Type policy_type = net::CookiePolicy::FromInt( prefs_->GetInteger(prefs::kCookieBehavior)); g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &ChromeURLRequestContext::OnCookiePolicyChange, - type)); + policy_type)); } } else if (NotificationType::EXTENSIONS_LOADED == type) { ExtensionPaths* new_paths = new ExtensionPaths; @@ -418,7 +418,7 @@ bool ChromeURLRequestContext::allowSendingCookies(const URLRequest* request) } void ChromeURLRequestContext::OnAcceptLanguageChange( - std::string accept_language) { + const std::string& accept_language) { DCHECK(MessageLoop::current() == ChromeThread::GetMessageLoop(ChromeThread::IO)); accept_language_ = diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index c709858..49564b7 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -86,7 +86,7 @@ private: const NotificationDetails& details); // Callback for when the accept language changes. - void OnAcceptLanguageChange(std::string accept_language); + void OnAcceptLanguageChange(const std::string& accept_language); // Callback for when the cookie policy changes. void OnCookiePolicyChange(net::CookiePolicy::Type type); diff --git a/chrome/browser/net/dns_master_unittest.cc b/chrome/browser/net/dns_master_unittest.cc index c2b3d27..61ffd68 100644 --- a/chrome/browser/net/dns_master_unittest.cc +++ b/chrome/browser/net/dns_master_unittest.cc @@ -582,7 +582,6 @@ TEST_F(DnsMasterTest, PriorityQueuePushPopTest) { EXPECT_TRUE(queue.IsEmpty()); // Then check low priority queue FIFO functionality. - queue.IsEmpty(); queue.Push("a", DnsHostInfo::PAGE_SCAN_MOTIVATED); EXPECT_FALSE(queue.IsEmpty()); queue.Push("b", DnsHostInfo::OMNIBOX_MOTIVATED); diff --git a/chrome/browser/net/referrer.cc b/chrome/browser/net/referrer.cc index 283faf6..bf171e5 100644 --- a/chrome/browser/net/referrer.cc +++ b/chrome/browser/net/referrer.cc @@ -65,7 +65,7 @@ void Referrer::DeleteLeastUseful() { } void Referrer::AccrueValue(const base::TimeDelta& delta, - const std::string host) { + const std::string& host) { HostNameMap::iterator it = find(host); // Be careful that we weren't evicted from this referrer in DeleteLeastUseful. if (it != end()) diff --git a/chrome/browser/net/referrer.h b/chrome/browser/net/referrer.h index 69c0278..8c252b6 100644 --- a/chrome/browser/net/referrer.h +++ b/chrome/browser/net/referrer.h @@ -69,7 +69,7 @@ class Referrer : public HostNameMap { // Record additional usefulness of having this host name in the list. // Value is expressed as positive latency of amount delta. - void AccrueValue(const base::TimeDelta& delta, const std::string host); + void AccrueValue(const base::TimeDelta& delta, const std::string& host); // Trim the Referrer, by first diminishing (scaling down) the latency for each // ReferredValue. diff --git a/chrome/browser/net/url_fetcher_protect.cc b/chrome/browser/net/url_fetcher_protect.cc index 8798b5a..748a675 100644 --- a/chrome/browser/net/url_fetcher_protect.cc +++ b/chrome/browser/net/url_fetcher_protect.cc @@ -144,7 +144,8 @@ URLFetcherProtectManager* URLFetcherProtectManager::GetInstance() { return protect_manager_.get(); } -URLFetcherProtectEntry* URLFetcherProtectManager::Register(std::string id) { +URLFetcherProtectEntry* URLFetcherProtectManager::Register( + const std::string& id) { AutoLock lock(lock_); ProtectService::iterator i = services_.find(id); @@ -161,7 +162,7 @@ URLFetcherProtectEntry* URLFetcherProtectManager::Register(std::string id) { } URLFetcherProtectEntry* URLFetcherProtectManager::Register( - std::string id, URLFetcherProtectEntry* entry) { + const std::string& id, URLFetcherProtectEntry* entry) { AutoLock lock(lock_); ProtectService::iterator i = services_.find(id); diff --git a/chrome/browser/net/url_fetcher_protect.h b/chrome/browser/net/url_fetcher_protect.h index 9b121b7..5e069fa 100644 --- a/chrome/browser/net/url_fetcher_protect.h +++ b/chrome/browser/net/url_fetcher_protect.h @@ -124,9 +124,9 @@ class URLFetcherProtectManager { // Registers a new entry in this service. If the entry already exists, // just returns it. - URLFetcherProtectEntry* Register(std::string id); + URLFetcherProtectEntry* Register(const std::string& id); // Always registers the entry even when it exists. - URLFetcherProtectEntry* Register(std::string id, + URLFetcherProtectEntry* Register(const std::string& id, URLFetcherProtectEntry* entry); private: diff --git a/chrome/browser/net/url_fetcher_unittest.cc b/chrome/browser/net/url_fetcher_unittest.cc index 4216eb0..91deec0 100644 --- a/chrome/browser/net/url_fetcher_unittest.cc +++ b/chrome/browser/net/url_fetcher_unittest.cc @@ -357,7 +357,7 @@ TEST_F(URLFetcherTest, DifferentThreadsTest) { // message loop will be shut down automatically as the thread goes out of // scope. base::Thread t("URLFetcher test thread"); - t.Start(); + ASSERT_TRUE(t.Start()); t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, GURL(server->TestServerPage("defaultresponse")))); @@ -456,7 +456,7 @@ TEST_F(URLFetcherCancelTest, ReleasesContext) { // message loop will be shut down automatically as the thread goes out of // scope. base::Thread t("URLFetcher test thread"); - t.Start(); + ASSERT_TRUE(t.Start()); t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); MessageLoop::current()->Run(); diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 4097b88..fa572c3 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -29,7 +29,7 @@ namespace { // UTF8 to UTF16. Instead of this after-the-fact adjustment, we should parse it // in the correct string format to begin with. url_parse::Component UTF8ComponentToWideComponent( - string text_utf8, + const string& text_utf8, const url_parse::Component& component_utf8) { if (component_utf8.len == -1) return url_parse::Component(); @@ -44,7 +44,8 @@ url_parse::Component UTF8ComponentToWideComponent( return component_w; } -void UTF8PartsToWideParts(string text_utf8, const url_parse::Parsed& parts_utf8, +void UTF8PartsToWideParts(const string& text_utf8, + const url_parse::Parsed& parts_utf8, url_parse::Parsed* parts) { if (IsStringASCII(text_utf8)) { *parts = parts_utf8; diff --git a/chrome/common/ipc_sync_channel_unittest.cc b/chrome/common/ipc_sync_channel_unittest.cc index 6566fb5..8d4cd80 100644 --- a/chrome/common/ipc_sync_channel_unittest.cc +++ b/chrome/common/ipc_sync_channel_unittest.cc @@ -595,7 +595,7 @@ void Multiple(bool server_pump, bool client_pump) { // A shared worker thread so that server1 and server2 run on one thread. base::Thread worker_thread("Multiple"); - worker_thread.Start(); + ASSERT_TRUE(worker_thread.Start()); // Server1 sends a sync msg to client1, which blocks the reply until // server2 (which runs on the same worker thread as server1) responds @@ -713,7 +713,7 @@ void QueuedReply(bool server_pump, bool client_pump) { // A shared worker thread so that server1 and server2 run on one thread. base::Thread worker_thread("QueuedReply"); - worker_thread.Start(); + ASSERT_TRUE(worker_thread.Start()); WaitableEvent client1_msg_received(false, false); WaitableEvent server2_can_reply(false, false); diff --git a/chrome/common/page_action.h b/chrome/common/page_action.h index 3331f8e..7a68eef 100644 --- a/chrome/common/page_action.h +++ b/chrome/common/page_action.h @@ -22,13 +22,13 @@ class PageAction { } PageActionType; std::string id() const { return id_; } - void set_id(std::string id) { id_ = id; } + void set_id(const std::string& id) { id_ = id; } PageActionType type() const { return type_; } void set_type(PageActionType type) { type_ = type; } std::string extension_id() const { return extension_id_; } - void set_extension_id(std::string extension_id) { + void set_extension_id(const std::string& extension_id) { extension_id_ = extension_id; } diff --git a/chrome/common/worker_thread_ticker.cc b/chrome/common/worker_thread_ticker.cc index 4351cae..6d0619f 100644 --- a/chrome/common/worker_thread_ticker.cc +++ b/chrome/common/worker_thread_ticker.cc @@ -76,8 +76,9 @@ bool WorkerThreadTicker::Start() { AutoLock lock(lock_); if (IsRunning()) return false; + if (!timer_thread_.Start()) + return false; is_running_ = true; - timer_thread_.Start(); ScheduleTimerTask(); return true; } |