summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoridana@chromium.org <idana@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 18:34:07 +0000
committeridana@chromium.org <idana@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 18:34:07 +0000
commit5af80facfb9fa87d213ad45366cba6e83d5a7f97 (patch)
treed9b17db4f8189af5febc9f16d7ff17896f22c321 /chrome
parent9ac7fcb5fdf8aa1c31e0c7665e567e59255235e8 (diff)
downloadchromium_src-5af80facfb9fa87d213ad45366cba6e83d5a7f97.zip
chromium_src-5af80facfb9fa87d213ad45366cba6e83d5a7f97.tar.gz
chromium_src-5af80facfb9fa87d213ad45366cba6e83d5a7f97.tar.bz2
Made some style fixes in the remaining code under chrom/browser/sync and under chrome/test/sync.
Review URL: http://codereview.chromium.org/203043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sync/engine/net/gaia_authenticator.cc14
-rw-r--r--chrome/browser/sync/engine/net/gaia_authenticator.h6
-rw-r--r--chrome/browser/sync/engine/net/server_connection_manager.cc2
-rw-r--r--chrome/browser/sync/engine/net/server_connection_manager.h2
-rw-r--r--chrome/browser/sync/notifier/base/async_dns_lookup.cc29
-rw-r--r--chrome/browser/sync/notifier/base/async_dns_lookup.h4
-rw-r--r--chrome/browser/sync/notifier/base/async_network_alive.h5
-rw-r--r--chrome/browser/sync/notifier/base/linux/network_status_detector_task_linux.cc2
-rw-r--r--chrome/browser/sync/notifier/base/nethelpers.h2
-rw-r--r--chrome/browser/sync/notifier/base/network_status_detector_task.cc6
-rw-r--r--chrome/browser/sync/notifier/base/network_status_detector_task.h7
-rw-r--r--chrome/browser/sync/notifier/base/network_status_detector_task_mt.cc8
-rw-r--r--chrome/browser/sync/notifier/base/posix/time_posix.cc2
-rw-r--r--chrome/browser/sync/notifier/base/signal_thread_task.h12
-rw-r--r--chrome/browser/sync/notifier/base/string.cc104
-rw-r--r--chrome/browser/sync/notifier/base/string.h97
-rw-r--r--chrome/browser/sync/notifier/base/string_unittest.cc14
-rw-r--r--chrome/browser/sync/notifier/base/task_pump.cc4
-rw-r--r--chrome/browser/sync/notifier/base/task_pump.h2
-rw-r--r--chrome/browser/sync/notifier/base/time.cc24
-rw-r--r--chrome/browser/sync/notifier/base/time.h15
-rw-r--r--chrome/browser/sync/notifier/base/time_unittest.cc4
-rw-r--r--chrome/browser/sync/notifier/base/timer.h3
-rw-r--r--chrome/browser/sync/notifier/base/utils.h35
-rw-r--r--chrome/browser/sync/notifier/base/win32/time_win32.cc29
-rw-r--r--chrome/browser/sync/notifier/communicator/auth_task.cc1
-rw-r--r--chrome/browser/sync/notifier/communicator/auth_task.h14
-rw-r--r--chrome/browser/sync/notifier/communicator/auto_reconnect.cc36
-rw-r--r--chrome/browser/sync/notifier/communicator/auto_reconnect.h18
-rw-r--r--chrome/browser/sync/notifier/communicator/connection_options.cc1
-rw-r--r--chrome/browser/sync/notifier/communicator/connection_options.h7
-rw-r--r--chrome/browser/sync/notifier/communicator/connection_settings.h8
-rw-r--r--chrome/browser/sync/notifier/communicator/const_communicator.h4
-rw-r--r--chrome/browser/sync/notifier/communicator/login.cc54
-rw-r--r--chrome/browser/sync/notifier/communicator/login.h37
-rw-r--r--chrome/browser/sync/notifier/communicator/login_failure.cc1
-rw-r--r--chrome/browser/sync/notifier/communicator/login_failure.h12
-rw-r--r--chrome/browser/sync/notifier/communicator/login_settings.cc8
-rw-r--r--chrome/browser/sync/notifier/communicator/mailbox.cc109
-rw-r--r--chrome/browser/sync/notifier/communicator/mailbox.h10
-rw-r--r--chrome/browser/sync/notifier/communicator/mailbox_unittest.cc2
-rw-r--r--chrome/browser/sync/notifier/communicator/product_info.h1
-rw-r--r--chrome/browser/sync/notifier/communicator/single_login_attempt.cc111
-rw-r--r--chrome/browser/sync/notifier/communicator/single_login_attempt.h39
-rw-r--r--chrome/browser/sync/notifier/communicator/talk_auth_task.cc1
-rw-r--r--chrome/browser/sync/notifier/communicator/talk_auth_task.h10
-rw-r--r--chrome/browser/sync/notifier/communicator/xml_parse_helpers.cc18
-rw-r--r--chrome/browser/sync/notifier/communicator/xml_parse_helpers.h1
-rw-r--r--chrome/browser/sync/notifier/communicator/xmpp_connection_generator.cc26
-rw-r--r--chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h24
-rw-r--r--chrome/browser/sync/notifier/communicator/xmpp_log.cc5
-rw-r--r--chrome/browser/sync/notifier/communicator/xmpp_log.h1
-rw-r--r--chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.cc78
-rw-r--r--chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h6
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc60
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiaauth.h10
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc36
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiahelper.h2
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/inet_aton.h2
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h125
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/win32window.cc2
-rw-r--r--chrome/browser/sync/notifier/listener/listen_task.h2
-rw-r--r--chrome/browser/sync/notifier/listener/mediator_thread.h1
-rw-r--r--chrome/browser/sync/notifier/listener/mediator_thread_impl.cc26
-rw-r--r--chrome/browser/sync/notifier/listener/mediator_thread_impl.h31
-rw-r--r--chrome/browser/sync/notifier/listener/send_update_task.cc5
-rw-r--r--chrome/browser/sync/notifier/listener/send_update_task.h4
-rw-r--r--chrome/browser/sync/notifier/listener/subscribe_task.cc5
-rw-r--r--chrome/browser/sync/notifier/listener/subscribe_task.h8
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator.h26
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_impl.cc4
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_impl.h3
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc3
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store.cc17
-rw-r--r--chrome/browser/sync/syncable/directory_event.h8
-rw-r--r--chrome/browser/sync/syncable/directory_manager.cc8
-rw-r--r--chrome/browser/sync/syncable/directory_manager.h2
-rw-r--r--chrome/browser/sync/syncable/syncable-inl.h1
-rw-r--r--chrome/browser/sync/syncable/syncable.cc36
-rw-r--r--chrome/browser/sync/syncable/syncable.h49
-rw-r--r--chrome/browser/sync/syncable/syncable_id.cc1
-rw-r--r--chrome/browser/sync/syncable/syncable_id.h10
-rw-r--r--chrome/browser/sync/syncable/syncable_unittest.cc26
-rw-r--r--chrome/browser/sync/util/character_set_converters-win32.cc2
-rw-r--r--chrome/browser/sync/util/compat-file.h2
-rw-r--r--chrome/browser/sync/util/compat-pthread.h2
-rw-r--r--chrome/browser/sync/util/crypto_helpers.cc4
-rw-r--r--chrome/browser/sync/util/event_sys-inl.h2
-rw-r--r--chrome/browser/sync/util/event_sys_unittest.cc10
-rw-r--r--chrome/browser/sync/util/highres_timer-linux.cc4
-rw-r--r--chrome/browser/sync/util/highres_timer_unittest.cc4
-rw-r--r--chrome/browser/sync/util/path_helpers-linux.cc6
-rw-r--r--chrome/browser/sync/util/path_helpers-posix.cc11
-rw-r--r--chrome/browser/sync/util/path_helpers.cc14
-rw-r--r--chrome/browser/sync/util/path_helpers.h4
-rw-r--r--chrome/browser/sync/util/pthread_helpers.cc8
-rw-r--r--chrome/browser/sync/util/query_helpers.cc9
-rw-r--r--chrome/browser/sync/util/user_settings-posix.cc4
-rw-r--r--chrome/browser/sync/util/user_settings-win32.cc3
-rw-r--r--chrome/browser/sync/util/user_settings.cc34
-rw-r--r--chrome/browser/sync/util/user_settings.h15
-rw-r--r--chrome/browser/sync/util/user_settings_unittest.cc6
-rw-r--r--chrome/test/sync/engine/mock_gaia_authenticator.cc3
-rw-r--r--chrome/test/sync/engine/mock_gaia_authenticator.h3
-rw-r--r--chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc3
-rw-r--r--chrome/test/sync/engine/mock_server_connection.cc11
-rw-r--r--chrome/test/sync/engine/mock_server_connection.h21
-rw-r--r--chrome/test/sync/engine/test_directory_setter_upper.cc4
-rw-r--r--chrome/test/sync/engine/test_directory_setter_upper.h7
109 files changed, 892 insertions, 892 deletions
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.cc b/chrome/browser/sync/engine/net/gaia_authenticator.cc
index 435579f..382048f 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator.cc
+++ b/chrome/browser/sync/engine/net/gaia_authenticator.cc
@@ -244,8 +244,7 @@ bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params,
string message_text;
unsigned long server_response_code;
- if (!Post(gaia_auth_url, post_body, &server_response_code,
- &message_text)) {
+ if (!Post(gaia_auth_url, post_body, &server_response_code, &message_text)) {
results->auth_error = ConnectionUnavailable;
return false;
}
@@ -274,9 +273,9 @@ bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params,
bool GaiaAuthenticator::LookupEmail(AuthResults* results) {
// Use the provided Gaia server, but change the path to what V1 expects.
- GURL url(gaia_url_); // Gaia server
+ GURL url(gaia_url_); // Gaia server.
GURL::Replacements repl;
- // Needs to stay in scope till GURL is out of scope
+ // Needs to stay in scope till GURL is out of scope.
string path(kGetUserInfoPath);
repl.SetPathStr(path);
url = url.ReplaceComponents(repl);
@@ -320,9 +319,9 @@ bool GaiaAuthenticator::IssueAuthToken(AuthResults* results,
const string& service_id,
bool long_lived) {
// Use the provided Gaia server, but change the path to what V1 expects.
- GURL url(gaia_url_); // Gaia server
+ GURL url(gaia_url_); // Gaia server.
GURL::Replacements repl;
- // Needs to stay in scope till GURL is out of scope
+ // Needs to stay in scope till GURL is out of scope.
string path(kGaiaV1IssueAuthTokenPath);
repl.SetPathStr(path);
url = url.ReplaceComponents(repl);
@@ -337,8 +336,7 @@ bool GaiaAuthenticator::IssueAuthToken(AuthResults* results,
unsigned long server_response_code;
string message_text;
- if (!Post(url, post_body,
- &server_response_code, &message_text)) {
+ if (!Post(url, post_body, &server_response_code, &message_text)) {
return false;
}
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.h b/chrome/browser/sync/engine/net/gaia_authenticator.h
index e18984c..895303a 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator.h
+++ b/chrome/browser/sync/engine/net/gaia_authenticator.h
@@ -192,7 +192,7 @@ class GaiaAuthenticator {
bool LaunchAuthenticate(const AuthParams& params, bool synchronous);
static void *ThreadMain(void *arg);
- // virtual for testing purposes
+ // virtual for testing purposes.
virtual bool Post(const GURL& url, const std::string& post_body,
unsigned long* response_code, std::string* response_body) {
return false;
@@ -203,13 +203,13 @@ class GaiaAuthenticator {
bool LookupEmail(AuthResults* results);
public:
- // Retrieve email
+ // Retrieve email.
inline std::string email() const {
PThreadScopedLock<PThreadMutex> enter(&mutex_);
return auth_results_.email;
}
- // Retrieve password
+ // Retrieve password.
inline std::string password() const {
PThreadScopedLock<PThreadMutex> enter(&mutex_);
return auth_results_.password;
diff --git a/chrome/browser/sync/engine/net/server_connection_manager.cc b/chrome/browser/sync/engine/net/server_connection_manager.cc
index ab3f51f..34cb3f2 100644
--- a/chrome/browser/sync/engine/net/server_connection_manager.cc
+++ b/chrome/browser/sync/engine/net/server_connection_manager.cc
@@ -110,7 +110,7 @@ int ServerConnectionManager::Post::ReadResponse(string* out_buffer,
return bytes_read;
}
-// A helper class that automatically notifies when the status changes:
+// A helper class that automatically notifies when the status changes.
struct WatchServerStatus {
WatchServerStatus(ServerConnectionManager* conn_mgr, HttpResponse* response)
: conn_mgr_(conn_mgr), response_(response),
diff --git a/chrome/browser/sync/engine/net/server_connection_manager.h b/chrome/browser/sync/engine/net/server_connection_manager.h
index 8093d45..a6641bc 100644
--- a/chrome/browser/sync/engine/net/server_connection_manager.h
+++ b/chrome/browser/sync/engine/net/server_connection_manager.h
@@ -327,7 +327,7 @@ class ServerConnectionManager {
private:
mutable PThreadMutex terminate_all_io_mutex_;
- bool terminate_all_io_; // when set to true, terminate all connections asap
+ bool terminate_all_io_; // When set to true, terminate all connections asap.
DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager);
};
diff --git a/chrome/browser/sync/notifier/base/async_dns_lookup.cc b/chrome/browser/sync/notifier/base/async_dns_lookup.cc
index 0d3ce87..ca39525 100644
--- a/chrome/browser/sync/notifier/base/async_dns_lookup.cc
+++ b/chrome/browser/sync/notifier/base/async_dns_lookup.cc
@@ -6,9 +6,9 @@
#ifdef POSIX
#include <arpa/inet.h>
+#include <netdb.h>
#include <netinet/in.h>
#include <netinet/ip.h>
-#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#endif // POSIX
@@ -26,7 +26,7 @@
enum { MSG_TIMEOUT = talk_base::SignalThread::ST_MSG_FIRST_AVAILABLE };
#ifndef WIN32
-const int WSAHOST_NOT_FOUND = 11001; // follows the format in winsock2.h
+const int WSAHOST_NOT_FOUND = 11001; // Follows the format in winsock2.h.
#endif // WIN32
namespace notifier {
@@ -64,7 +64,7 @@ void AsyncDNSLookup::DoWork() {
if (error_ == 0) {
for (int index = 0; true; ++index) {
uint32* addr = reinterpret_cast<uint32*>(host->h_addr_list[index]);
- if (addr == 0) { // 0 = end of list
+ if (addr == 0) { // 0 = end of list.
break;
}
uint32 ip = talk_base::NetworkToHost32(*addr);
@@ -72,9 +72,8 @@ void AsyncDNSLookup::DoWork() {
<< talk_base::SocketAddress::IPToString(ip);
ip_list_.push_back(ip);
}
- // Maintain the invariant that either the list is not empty
- // or the error is non zero when we are done with processing
- // the dnslookup.
+ // Maintain the invariant that either the list is not empty or the
+ // error is non zero when we are done with processing the dnslookup.
if (ip_list_.empty() && error_ == 0) {
error_ = WSAHOST_NOT_FOUND;
}
@@ -104,10 +103,10 @@ void AsyncDNSLookup::OnMessage(talk_base::Message* message) {
}
void AsyncDNSLookup::OnTimeout() {
- // Allow the scope for the critical section to be the whole
- // method, just to be sure that the worker thread can't exit
- // while we are doing SignalWorkDone (because that could possibly
- // cause the class to be deleted).
+ // Allow the scope for the critical section to be the whole method, just to
+ // be sure that the worker thread can't exit while we are doing
+ // SignalWorkDone (because that could possibly cause the class to be
+ // deleted).
talk_base::CritScope scope(&cs_);
// Check to see if the ip list was already filled (or errored out).
@@ -120,14 +119,14 @@ void AsyncDNSLookup::OnTimeout() {
// Rely on the caller to do the Release/Destroy.
//
- // Doing this signal while holding cs_ won't cause a deadlock because
- // the AsyncDNSLookup::DoWork thread doesn't have any locks at this point,
- // and it is the only thread being held up by this.
+ // Doing this signal while holding cs_ won't cause a deadlock because the
+ // AsyncDNSLookup::DoWork thread doesn't have any locks at this point, and it
+ // is the only thread being held up by this.
SignalWorkDone(this);
// Ensure that no more "WorkDone" signaling is done.
- // Don't call Release or Destroy since that was already done
- // by the callback.
+ // Don't call Release or Destroy since that was already done by the callback.
SignalWorkDone.disconnect_all();
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/base/async_dns_lookup.h b/chrome/browser/sync/notifier/base/async_dns_lookup.h
index 123d311..c62aa1f 100644
--- a/chrome/browser/sync/notifier/base/async_dns_lookup.h
+++ b/chrome/browser/sync/notifier/base/async_dns_lookup.h
@@ -31,7 +31,7 @@ class AsyncDNSLookup : public talk_base::SignalThread {
}
protected:
- // SignalThread Interface
+ // SignalThread Interface.
virtual void DoWork();
virtual void OnMessage(talk_base::Message* message);
@@ -45,5 +45,7 @@ class AsyncDNSLookup : public talk_base::SignalThread {
DISALLOW_COPY_AND_ASSIGN(AsyncDNSLookup);
};
+
} // namespace notifier
+
#endif // CHROME_BROWSER_SYNC_NOTIFIER_BASE_ASYNC_DNS_LOOKUP_H_
diff --git a/chrome/browser/sync/notifier/base/async_network_alive.h b/chrome/browser/sync/notifier/base/async_network_alive.h
index 330348d..59538f3 100644
--- a/chrome/browser/sync/notifier/base/async_network_alive.h
+++ b/chrome/browser/sync/notifier/base/async_network_alive.h
@@ -9,7 +9,7 @@
namespace notifier {
-// System specific info needed for changes
+// System specific info needed for changes.
class PlatformNetworkInfo;
class AsyncNetworkAlive : public talk_base::SignalThread {
@@ -40,7 +40,6 @@ class AsyncNetworkAlive : public talk_base::SignalThread {
AsyncNetworkAlive() : network_info_(NULL), alive_(false), error_(false) {
}
- protected:
PlatformNetworkInfo* network_info_;
bool alive_;
bool error_;
@@ -48,5 +47,7 @@ class AsyncNetworkAlive : public talk_base::SignalThread {
private:
DISALLOW_COPY_AND_ASSIGN(AsyncNetworkAlive);
};
+
} // namespace notifier
+
#endif // CHROME_BROWSER_SYNC_NOTIFIER_BASE_ASYNC_NETWORK_ALIVE_H_
diff --git a/chrome/browser/sync/notifier/base/linux/network_status_detector_task_linux.cc b/chrome/browser/sync/notifier/base/linux/network_status_detector_task_linux.cc
index e232bcb..3d135be 100644
--- a/chrome/browser/sync/notifier/base/linux/network_status_detector_task_linux.cc
+++ b/chrome/browser/sync/notifier/base/linux/network_status_detector_task_linux.cc
@@ -8,7 +8,7 @@ namespace notifier {
NetworkStatusDetectorTask* NetworkStatusDetectorTask::Create(
talk_base::Task* parent) {
- // TODO(sync): No implementation for linux
+ // TODO(sync): No implementation for linux.
return NULL;
}
diff --git a/chrome/browser/sync/notifier/base/nethelpers.h b/chrome/browser/sync/notifier/base/nethelpers.h
index d2b9fd4..604e69df 100644
--- a/chrome/browser/sync/notifier/base/nethelpers.h
+++ b/chrome/browser/sync/notifier/base/nethelpers.h
@@ -6,8 +6,8 @@
#define CHROME_BROWSER_SYNC_NOTIFIER_BASE_NETHELPERS_H_
#ifdef POSIX
-#include <netdb.h>
#include <cstddef>
+#include <netdb.h>
#elif WIN32
#include <winsock2.h>
#endif
diff --git a/chrome/browser/sync/notifier/base/network_status_detector_task.cc b/chrome/browser/sync/notifier/base/network_status_detector_task.cc
index f9acd88..a061c0f 100644
--- a/chrome/browser/sync/notifier/base/network_status_detector_task.cc
+++ b/chrome/browser/sync/notifier/base/network_status_detector_task.cc
@@ -7,9 +7,9 @@
namespace notifier {
void NetworkStatusDetectorTask::DetectNetworkState() {
- // If the detection has been finished, then just broadcast the current
- // state. Otherwise, allow the signal to be sent when the initial
- // detection is finished.
+ // If the detection has been finished, then just broadcast the current state.
+ // Otherwise, allow the signal to be sent when the initial detection is
+ // finished.
if (initial_detection_done_) {
SignalNetworkStateDetected(is_alive_, is_alive_);
}
diff --git a/chrome/browser/sync/notifier/base/network_status_detector_task.h b/chrome/browser/sync/notifier/base/network_status_detector_task.h
index 4cf190e..cedee75 100644
--- a/chrome/browser/sync/notifier/base/network_status_detector_task.h
+++ b/chrome/browser/sync/notifier/base/network_status_detector_task.h
@@ -10,6 +10,7 @@
#include "talk/base/task.h"
namespace notifier {
+
class AsyncNetworkAlive;
// Detects the current network state and any changes to that.
@@ -19,8 +20,8 @@ class NetworkStatusDetectorTask : public talk_base::Task,
// Create an instance of (a subclass of) this class.
static NetworkStatusDetectorTask* Create(talk_base::Task* parent);
- // Determines the current network state and
- // then calls SignalNetworkStateDetected.
+ // Determines the current network state and then calls
+ // SignalNetworkStateDetected.
void DetectNetworkState();
// Fires whenever the network state is detected.
@@ -51,5 +52,7 @@ class NetworkStatusDetectorTask : public talk_base::Task,
DISALLOW_COPY_AND_ASSIGN(NetworkStatusDetectorTask);
};
+
} // namespace notifier
+
#endif // CHROME_BROWSER_SYNC_NOTIFIER_BASE_NETWORK_STATUS_DETECTOR_TASK_H_
diff --git a/chrome/browser/sync/notifier/base/network_status_detector_task_mt.cc b/chrome/browser/sync/notifier/base/network_status_detector_task_mt.cc
index d4e406c..e9f5971 100644
--- a/chrome/browser/sync/notifier/base/network_status_detector_task_mt.cc
+++ b/chrome/browser/sync/notifier/base/network_status_detector_task_mt.cc
@@ -15,8 +15,8 @@ void NetworkStatusDetectorTaskMT::OnNetworkAliveDone(
AsyncNetworkAlive* network_alive) {
ASSERT(network_alive);
SetNetworkAlive(network_alive->alive());
- // If we got an error from detecting the network alive state,
- // then stop retrying the detection.
+ // If we got an error from detecting the network alive state, then stop
+ // retrying the detection.
if (network_alive->error()) {
return;
}
@@ -25,8 +25,8 @@ void NetworkStatusDetectorTaskMT::OnNetworkAliveDone(
void NetworkStatusDetectorTaskMT::StartAsyncDetection(
PlatformNetworkInfo* previous_info) {
- // Use the AsyncNetworkAlive to determine the network state (and
- // changes in the network state).
+ // Use the AsyncNetworkAlive to determine the network state (and changes in
+ // the network state).
AsyncNetworkAlive* network_alive = AsyncNetworkAlive::Create();
if (previous_info) {
diff --git a/chrome/browser/sync/notifier/base/posix/time_posix.cc b/chrome/browser/sync/notifier/base/posix/time_posix.cc
index 849f802..cda2769 100644
--- a/chrome/browser/sync/notifier/base/posix/time_posix.cc
+++ b/chrome/browser/sync/notifier/base/posix/time_posix.cc
@@ -3,9 +3,9 @@
// found in the LICENSE file.
#include <assert.h>
-#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/time.h>
#include "chrome/browser/sync/notifier/base/time.h"
diff --git a/chrome/browser/sync/notifier/base/signal_thread_task.h b/chrome/browser/sync/notifier/base/signal_thread_task.h
index 93059d8..ebee005 100644
--- a/chrome/browser/sync/notifier/base/signal_thread_task.h
+++ b/chrome/browser/sync/notifier/base/signal_thread_task.h
@@ -54,18 +54,18 @@ class SignalThreadTask : public talk_base::Task,
sigslot::signal1<T*> SignalWorkDone;
private:
- // Takes ownership of signal_thread
+ // Takes ownership of signal_thread.
void SetSignalThread(T** signal_thread) {
ASSERT(!signal_thread_ && signal_thread && *signal_thread);
- // Verify that no one is listening to the signal thread
- // for work done. They should be using this class instead.
+ // Verify that no one is listening to the signal thread for work done.
+ // They should be using this class instead.
ASSERT((*signal_thread)->SignalWorkDone.is_empty());
signal_thread_ = *signal_thread;
- // Helps callers not to use signal thread after this point
- // since this class has taken ownership (and avoid the
- // error of doing signal_thread->Start()).
+ // Helps callers not to use signal thread after this point since this class
+ // has taken ownership (and avoid the error of doing
+ // signal_thread->Start()).
*signal_thread = NULL;
}
diff --git a/chrome/browser/sync/notifier/base/string.cc b/chrome/browser/sync/notifier/base/string.cc
index c3ef54d..4c441f8 100644
--- a/chrome/browser/sync/notifier/base/string.cc
+++ b/chrome/browser/sync/notifier/base/string.cc
@@ -72,8 +72,8 @@ int CharToHexValue(char hex) {
}
}
-// Template function to convert a string to an int/int64
-// If strict is true, check for the validity and overflow
+// Template function to convert a string to an int/int64. If strict is true,
+// check for the validity and overflow
template<typename T>
bool ParseStringToIntTemplate(const char* str,
T* value,
@@ -82,47 +82,47 @@ bool ParseStringToIntTemplate(const char* str,
ASSERT(str);
ASSERT(value);
- // Skip spaces
+ // Skip spaces.
while (*str == ' ') {
++str;
}
- // Process sign
- int c = static_cast<int>(*str++); // current char
- int possible_sign = c; // save sign indication
+ // Process sign.
+ int c = static_cast<int>(*str++); // current char
+ int possible_sign = c; // save sign indication
if (c == '-' || c == '+') {
c = static_cast<int>(*str++);
}
- // Process numbers
+ // Process numbers.
T total = 0;
while (c && (c = CharToDigit(static_cast<char>(c))) != -1) {
- // Check for overflow
+ // Check for overflow.
if (strict && (total < min_value / 10 ||
(total == min_value / 10 &&
c > ((-(min_value + 10)) % 10)))) {
return false;
}
- // Accumulate digit
+ // Accumulate digit.
// Note that we accumulate in the negative direction so that we will not
// blow away with the largest negative number
total = 10 * total - c;
- // Get next char
+ // Get next char.
c = static_cast<int>(*str++);
}
- // Fail if encountering non-numeric character
+ // Fail if encountering non-numeric character.
if (strict && c == -1) {
return false;
}
- // Negate the number if needed
+ // Negate the number if needed.
if (possible_sign == '-') {
*value = total;
} else {
- // Check for overflow
+ // Check for overflow.
if (strict && total == min_value) {
return false;
}
@@ -133,22 +133,22 @@ bool ParseStringToIntTemplate(const char* str,
return true;
}
-// Convert a string to an int
-// If strict is true, check for the validity and overflow
+// Convert a string to an int. If strict is true, check for the validity and
+// overflow.
bool ParseStringToInt(const char* str, int* value, bool strict) {
return ParseStringToIntTemplate<int>(str, value, strict, kint32min);
}
-// Convert a string to an int
-// This version does not check for the validity and overflow
+// Convert a string to an int. This version does not check for the validity and
+// overflow
int StringToInt(const char* str) {
int value = 0;
ParseStringToInt(str, &value, false);
return value;
}
-// Convert a string to an unsigned int.
-// If strict is true, check for the validity and overflow
+// Convert a string to an unsigned int. If strict is true, check for the
+// validity and overflow
bool ParseStringToUint(const char* str, uint32* value, bool strict) {
ASSERT(str);
ASSERT(value);
@@ -165,88 +165,88 @@ bool ParseStringToUint(const char* str, uint32* value, bool strict) {
return true;
}
-// Convert a string to an int
-// This version does not check for the validity and overflow
+// Convert a string to an int. This version does not check for the validity and
+// overflow.
uint32 StringToUint(const char* str) {
uint32 value = 0;
ParseStringToUint(str, &value, false);
return value;
}
-// Convert a string to an int64
-// If strict is true, check for the validity and overflow
+// Convert a string to an int64. If strict is true, check for the validity and
+// overflow.
bool ParseStringToInt64(const char* str, int64* value, bool strict) {
return ParseStringToIntTemplate<int64>(str, value, strict, kint64min);
}
-// Convert a string to an int64
-// This version does not check for the validity and overflow
+// Convert a string to an int64. This version does not check for the validity
+// and overflow.
int64 StringToInt64(const char* str) {
int64 value = 0;
ParseStringToInt64(str, &value, false);
return value;
}
-// Convert a string to a double
-// If strict is true, check for the validity and overflow
+// Convert a string to a double. If strict is true, check for the validity and
+// overflow.
bool ParseStringToDouble(const char* str, double* value, bool strict) {
ASSERT(str);
ASSERT(value);
- // Skip spaces
+ // Skip spaces.
while (*str == ' ') {
++str;
}
- // Process sign
- int c = static_cast<int>(*str++); // current char
- int sign = c; // save sign indication
+ // Process sign.
+ int c = static_cast<int>(*str++); // Current char.
+ int sign = c; // save sign indication
if (c == '-' || c == '+') {
c = static_cast<int>(*str++);
}
- // Process numbers before "."
+ // Process numbers before ".".
double total = 0.0;
while (c && (c != '.') && (c = CharToDigit(static_cast<char>(c))) != -1) {
- // Check for overflow
+ // Check for overflow.
if (strict && total >= DBL_MAX / 10) {
return false;
}
- // Accumulate digit
+ // Accumulate digit.
total = 10.0 * total + c;
- // Get next char
+ // Get next char.
c = static_cast<int>(*str++);
}
- // Process "."
+ // Process ".".
if (c == '.') {
c = static_cast<int>(*str++);
} else {
- // Fail if encountering non-numeric character
+ // Fail if encountering non-numeric character.
if (strict && c == -1) {
return false;
}
}
- // Process numbers after "."
+ // Process numbers after ".".
double power = 1.0;
while ((c = CharToDigit(static_cast<char>(c))) != -1) {
- // Check for overflow
+ // Check for overflow.
if (strict && total >= DBL_MAX / 10) {
return false;
}
- // Accumulate digit
+ // Accumulate digit.
total = 10.0 * total + c;
power *= 10.0;
- // Get next char
+ // Get next char.
c = static_cast<int>(*str++);
}
- // Get the final number
+ // Get the final number.
*value = total / power;
if (sign == '-') {
*value = -(*value);
@@ -255,15 +255,15 @@ bool ParseStringToDouble(const char* str, double* value, bool strict) {
return true;
}
-// Convert a string to a double
-// This version does not check for the validity and overflow
+// Convert a string to a double. This version does not check for the validity
+// and overflow.
double StringToDouble(const char* str) {
double value = 0;
ParseStringToDouble(str, &value, false);
return value;
}
-// Convert a float to a string
+// Convert a float to a string.
std::string FloatToString(float f) {
char buf[80];
snprintf(buf, sizeof(buf), "%f", f);
@@ -308,11 +308,11 @@ std::string Int64ToHexString(int64 i64) {
return std::string(buf);
}
-// Parse a single "delim" delimited string from "*source"
-// Modify *source to point after the delimiter.
-// If no delimiter is present after the string, set *source to NULL.
+// Parse a single "delim" delimited string from "*source". Modify *source to
+// point after the delimiter. If no delimiter is present after the string, set
+// *source to NULL.
//
-// Mainly a stringified wrapper around strpbrk()
+// Mainly a stringified wrapper around strpbrk().
std::string SplitOneStringToken(const char** source, const char* delim) {
ASSERT(source);
ASSERT(delim);
@@ -358,7 +358,7 @@ std::string PascalCaseToLowerWithUnder(const char* pascal_case) {
for(; *pascal_case != '\0'; pascal_case++) {
char current_char = *pascal_case;
if (isupper(current_char)) {
- // DNSName should be dns_name
+ // DNSName should be dns_name.
if ((islower(pascal_case[1]) && !lower_with_under.empty()) ||
!previous_was_upper) {
lower_with_under.append(1, '_');
@@ -377,7 +377,7 @@ void StringReplace(std::string* s,
bool replace_all) {
ASSERT(s);
- // If old_sub is empty, nothing to do
+ // If old_sub is empty, nothing to do.
if (!old_sub || !*old_sub) {
return;
}
@@ -393,7 +393,7 @@ void StringReplace(std::string* s,
}
res.append(*s, start_pos, pos - start_pos);
res.append(new_sub);
- start_pos = pos + old_sub_size; // start searching again after the "old"
+ start_pos = pos + old_sub_size; // start searching again after the "old".
} while (replace_all);
res.append(*s, start_pos, s->length() - start_pos);
diff --git a/chrome/browser/sync/notifier/base/string.h b/chrome/browser/sync/notifier/base/string.h
index 725cc66..b40a60c 100644
--- a/chrome/browser/sync/notifier/base/string.h
+++ b/chrome/browser/sync/notifier/base/string.h
@@ -31,8 +31,8 @@ std::string UrlEncode(const std::string& src);
// Does url decoding of strings.
std::string UrlDecode(const std::string& src);
-// Convert a character to a digit
-// if the character is not a digit return -1 (same as CRT)
+// Convert a character to a digit. If the character is not a digit return -1
+// (same as CRT).
inline int CharToDigit(char c) {
return ((c) >= '0' && (c) <= '9' ? (c) - '0' : -1);
}
@@ -44,8 +44,9 @@ int CharToHexValue(char hex);
// ParseStringToUint()
// ParseStringToInt64()
// ParseStringToDouble()
-// Convert a string to an int/int64/double
-// If strict is true, check for the validity and overflow
+//
+// Convert a string to an int/int64/double.
+// If strict is true, check for the validity and overflow.
// ----------------------------------------------------------------------
bool ParseStringToInt(const char* str, int* value, bool strict);
@@ -61,8 +62,9 @@ bool ParseStringToDouble(const char* str, double* value, bool strict);
// StringToUint()
// StringToInt64()
// StringToDouble()
-// Convert a string to an int/int64/double
-// Note that these functions do not check for the validity or overflow
+//
+// Convert a string to an int/int64/double.
+// Note that these functions do not check for the validity or overflow.
// ----------------------------------------------------------------------
int StringToInt(const char* str);
@@ -80,8 +82,9 @@ double StringToDouble(const char* str);
// UIntToString()
// Int64ToString()
// UInt64ToString()
-// Convert various types to their string representation. These
-// all do the obvious, trivial thing.
+//
+// Convert various types to their string representation. These all do
+// the obvious, trivial thing.
// ----------------------------------------------------------------------
std::string FloatToString(float f);
@@ -98,7 +101,8 @@ std::string Int64ToHexString(int64 i64);
// ----------------------------------------------------------------------
// StringStartsWith()
// StringEndsWith()
-// Check if a string starts or ends with a pattern
+//
+// Check if a string starts or ends with a pattern.
// ----------------------------------------------------------------------
inline bool StringStartsWith(const std::string& s, const char* p) {
@@ -111,7 +115,8 @@ inline bool StringEndsWith(const std::string& s, const char* p) {
// ----------------------------------------------------------------------
// MakeStringEndWith()
-// If the string does not end with a pattern, make it end with it
+//
+// If the string does not end with a pattern, make it end with it.
// ----------------------------------------------------------------------
inline std::string MakeStringEndWith(const std::string& s, const char* p) {
@@ -124,19 +129,20 @@ inline std::string MakeStringEndWith(const std::string& s, const char* p) {
}
}
-// Convert a lower_case_string to LowerCaseString
+// Convert a lower_case_string to LowerCaseString.
std::string LowerWithUnderToPascalCase(const char* lower_with_under);
-// Convert a PascalCaseString to pascal_case_string
+// Convert a PascalCaseString to pascal_case_string.
std::string PascalCaseToLowerWithUnder(const char* pascal_case);
// ----------------------------------------------------------------------
// LowerString()
// LowerStringToBuf()
-// Convert the characters in "s" to lowercase.
-// Changes contents of "s". LowerStringToBuf copies at most
-// "n" characters (including the terminating '\0') from "s"
-// to another buffer.
+//
+// Convert the characters in "s" to lowercase.
+// Changes contents of "s". LowerStringToBuf copies at most "n"
+// characters (including the terminating '\0') from "s" to another
+// buffer.
// ----------------------------------------------------------------------
inline void LowerString(char* s) {
@@ -166,10 +172,11 @@ inline void LowerStringToBuf(const char* s, char* buf, int n) {
// ----------------------------------------------------------------------
// UpperString()
// UpperStringToBuf()
-// Convert the characters in "s" to uppercase.
-// UpperString changes "s". UpperStringToBuf copies at most
-// "n" characters (including the terminating '\0') from "s"
-// to another buffer.
+//
+// Convert the characters in "s" to uppercase.
+// UpperString changes "s". UpperStringToBuf copies at most "n"
+// characters (including the terminating '\0') from "s" to another
+// buffer.
// ----------------------------------------------------------------------
inline void UpperString(char* s) {
@@ -197,8 +204,9 @@ inline void UpperStringToBuf(const char* s, char* buf, int n) {
// ----------------------------------------------------------------------
// TrimStringLeft
-// Removes any occurrences of the characters in 'remove' from the start
-// of the string. Returns the number of chars trimmed.
+//
+// Removes any occurrences of the characters in 'remove' from the start
+// of the string. Returns the number of chars trimmed.
// ----------------------------------------------------------------------
inline int TrimStringLeft(std::string* s, const char* remove) {
int i = 0;
@@ -209,8 +217,9 @@ inline int TrimStringLeft(std::string* s, const char* remove) {
// ----------------------------------------------------------------------
// TrimStringRight
-// Removes any occurrences of the characters in 'remove' from the end
-// of the string. Returns the number of chars trimmed.
+//
+// Removes any occurrences of the characters in 'remove' from the end of
+// the string. Returns the number of chars trimmed.
// ----------------------------------------------------------------------
inline int TrimStringRight(std::string* s, const char* remove) {
int size = static_cast<int>(s->size());
@@ -224,8 +233,9 @@ inline int TrimStringRight(std::string* s, const char* remove) {
// ----------------------------------------------------------------------
// TrimString
-// Removes any occurrences of the characters in 'remove' from either
-// end of the string.
+//
+// Removes any occurrences of the characters in 'remove' from either end
+// of the string.
// ----------------------------------------------------------------------
inline int TrimString(std::string* s, const char* remove) {
return TrimStringRight(s, remove) + TrimStringLeft(s, remove);
@@ -233,8 +243,9 @@ inline int TrimString(std::string* s, const char* remove) {
// ----------------------------------------------------------------------
// StringReplace()
-// Replace the "old" pattern with the "new" pattern in a string. If
-// replace_all is false, it only replaces the first instance of "old."
+//
+// Replace the "old" pattern with the "new" pattern in a string. If
+// replace_all is false, it only replaces the first instance of "old."
// ----------------------------------------------------------------------
void StringReplace(std::string* s,
@@ -249,24 +260,25 @@ inline size_t HashString(const std::string &value) {
__gnu_cxx::hash<const char*> h;
return h(value.c_str());
#else
- // Compile time error because we don't return a value
+ // Compile time error because we don't return a value.
#endif
}
// ----------------------------------------------------------------------
// SplitOneStringToken()
-// Parse a single "delim" delimited string from "*source"
-// Modify *source to point after the delimiter.
-// If no delimiter is present after the string, set *source to NULL.
//
-// If the start of *source is a delimiter, return an empty string.
-// If *source is NULL, return an empty string.
+// Parse a single "delim" delimited string from "*source"
+// Modify *source to point after the delimiter.
+// If no delimiter is present after the string, set *source to NULL.
+//
+// If the start of *source is a delimiter, return an empty string.
+// If *source is NULL, return an empty string.
// ----------------------------------------------------------------------
std::string SplitOneStringToken(const char** source, const char* delim);
//----------------------------------------------------------------------
-// CharTraits provides wrappers with common function names for char/wchar_t
-// specific CRT functions
+// CharTraits provides wrappers with common function names for
+// char/wchar_t specific CRT functions
//----------------------------------------------------------------------
template <class CharT> struct CharTraits {
@@ -316,14 +328,15 @@ struct CharTraits<wchar_t> {
};
//----------------------------------------------------------------------
-// This class manages a fixed-size, null-terminated string buffer. It is
-// meant to be allocated on the stack, and it makes no use of the heap
-// internally. In most cases you'll just want to use a std::(w)string, but
-// when you need to avoid the heap, you can use this class instead.
+// This class manages a fixed-size, null-terminated string buffer. It
+// is meant to be allocated on the stack, and it makes no use of the
+// heap internally. In most cases you'll just want to use a
+// std::(w)string, but when you need to avoid the heap, you can use this
+// class instead.
//
// Methods are provided to read the null-terminated buffer and to append
-// data to the buffer, and once the buffer fills-up, it simply discards any
-// extra append calls.
+// data to the buffer, and once the buffer fills-up, it simply discards
+// any extra append calls.
//----------------------------------------------------------------------
template <class CharT, int MaxSize>
diff --git a/chrome/browser/sync/notifier/base/string_unittest.cc b/chrome/browser/sync/notifier/base/string_unittest.cc
index 9e89f5a..9c5c918 100644
--- a/chrome/browser/sync/notifier/base/string_unittest.cc
+++ b/chrome/browser/sync/notifier/base/string_unittest.cc
@@ -136,8 +136,8 @@ TEST_F(StringTest, TrimString) {
const char* white = " \n\t";
std::string s, c;
- // TrimStringLeft
- s = ""; // empty
+ // TrimStringLeft.
+ s = ""; // empty
c = "";
ASSERT_EQ(TrimStringLeft(&s, white), 0);
ASSERT_STREQ(s.c_str(), c.c_str());
@@ -147,7 +147,7 @@ TEST_F(StringTest, TrimString) {
ASSERT_EQ(TrimStringLeft(&s, white), 3);
ASSERT_STREQ(s.c_str(), c.c_str());
- s = "dog"; // nothing bad
+ s = "dog"; // nothing bad
c = "dog";
ASSERT_EQ(TrimStringLeft(&s, white), 0);
ASSERT_STREQ(s.c_str(), c.c_str());
@@ -162,7 +162,7 @@ TEST_F(StringTest, TrimString) {
ASSERT_EQ(TrimStringLeft(&s, white), 5);
ASSERT_STREQ(s.c_str(), c.c_str());
- // TrimStringRight
+ // TrimStringRight.
s = "";
c = "";
ASSERT_EQ(TrimStringRight(&s, white), 0);
@@ -188,7 +188,7 @@ TEST_F(StringTest, TrimString) {
ASSERT_EQ(TrimStringRight(&s, white), 4);
ASSERT_STREQ(s.c_str(), c.c_str());
- // TrimString
+ // TrimString.
s = "";
c = "";
ASSERT_EQ(TrimString(&s, white), 0);
@@ -346,8 +346,8 @@ TEST_F(StringTest, StringReplace) {
StringReplace(&s, "=", " = ", false);
EXPECT_STREQ(s.c_str(), "");
- // Input is an empty string and this is a request for repeated
- // string replaces.
+ // Input is an empty string and this is a request for repeated string
+ // replaces.
s = "";
StringReplace(&s, "=", " = ", true);
EXPECT_STREQ(s.c_str(), "");
diff --git a/chrome/browser/sync/notifier/base/task_pump.cc b/chrome/browser/sync/notifier/base/task_pump.cc
index 7e99fc1..0053d7a 100644
--- a/chrome/browser/sync/notifier/base/task_pump.cc
+++ b/chrome/browser/sync/notifier/base/task_pump.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/browser/sync/notifier/base/task_pump.h"
-
#include "chrome/browser/sync/notifier/base/time.h"
#include "talk/base/common.h"
#include "talk/base/thread.h"
@@ -30,7 +29,7 @@ void TaskPump::OnMessage(talk_base::Message* msg) {
void TaskPump::WakeTasks() {
if (!posted_) {
- // Do the requested wake up
+ // Do the requested wake up.
talk_base::Thread::Current()->Post(this, MSG_WAKE_UP);
posted_ = true;
}
@@ -39,4 +38,5 @@ void TaskPump::WakeTasks() {
int64 TaskPump::CurrentTime() {
return GetCurrent100NSTime();
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/base/task_pump.h b/chrome/browser/sync/notifier/base/task_pump.h
index b6c00ec..38f1689 100644
--- a/chrome/browser/sync/notifier/base/task_pump.h
+++ b/chrome/browser/sync/notifier/base/task_pump.h
@@ -18,7 +18,7 @@ class TaskPump : public talk_base::MessageHandler,
// MessageHandler interface.
virtual void OnMessage(talk_base::Message* msg);
- // TaskRunner interface
+ // TaskRunner interface.
virtual void WakeTasks();
virtual int64 CurrentTime();
diff --git a/chrome/browser/sync/notifier/base/time.cc b/chrome/browser/sync/notifier/base/time.cc
index ed3c414..139ca88 100644
--- a/chrome/browser/sync/notifier/base/time.cc
+++ b/chrome/browser/sync/notifier/base/time.cc
@@ -15,7 +15,7 @@
namespace notifier {
// Get the current time represented in 100NS granularity since epoch
-// (Jan 1, 1970)
+// (Jan 1, 1970).
time64 GetCurrent100NSTimeSinceEpoch() {
return GetCurrent100NSTime() - kStart100NsTimeToEpoch;
}
@@ -28,7 +28,7 @@ char* GetLocalTimeAsString() {
if (time_string) {
int time_len = strlen(time_string);
if (time_len > 0) {
- time_string[time_len - 1] = 0; // trim off terminating \n
+ time_string[time_len - 1] = 0; // trim off terminating \n.
}
}
return time_string;
@@ -102,7 +102,7 @@ const TimeZoneInfo kRFC822_TimeZone[] = {
{ "MDT", -6 },
{ "PST", -8 },
{ "PDT", -7 },
- { "A", -1 }, // Military time zones
+ { "A", -1 }, // Military time zones.
{ "B", -2 },
{ "C", -3 },
{ "D", -4 },
@@ -145,7 +145,7 @@ bool ParseRFC822DateTime(const char* str, struct tm* time,
for (int i = 0; i < kNumOfDays; ++i) {
if (str_token == kRFC822_Day[i]) {
- // Skip spaces after ','
+ // Skip spaces after ','.
while (*str_curr == ' ' && *str_curr != '\0') {
str_curr++;
}
@@ -171,11 +171,11 @@ bool ParseRFC822DateTime(const char* str, struct tm* time,
int month = -1;
for (int i = 0; i < kNumOfMonth; ++i) {
if (str_token == kRFC822_Month[i]) {
- month = i; // month is 0 based number
+ month = i; // Month is 0 based number.
break;
}
}
- if (month == -1) { // month not found
+ if (month == -1) { // Month not found.
return false;
}
@@ -188,7 +188,7 @@ bool ParseRFC822DateTime(const char* str, struct tm* time,
if (!ParseStringToInt(str_token.c_str(), &year, true)) {
return false;
}
- if (year < 100) { // two digit year format, convert to 1950 - 2050 range
+ if (year < 100) { // Two digit year format, convert to 1950 - 2050 range.
if (year < 50) {
year += 2000;
} else {
@@ -224,7 +224,7 @@ bool ParseRFC822DateTime(const char* str, struct tm* time,
}
int second = 0;
- // distingushed between XX:XX and XX:XX:XX time formats
+ // Distingushed between XX:XX and XX:XX:XX time formats.
if (str_token.size() == 2 && isdigit(str_token[0]) && isdigit(str_token[1])) {
second = 0;
if (!ParseStringToInt(str_token.c_str(), &second, true) ||
@@ -240,15 +240,15 @@ bool ParseRFC822DateTime(const char* str, struct tm* time,
int bias = 0;
if (str_token[0] == '+' || str_token[0] == '-' || isdigit(str_token[0])) {
- // numeric format
+ // Numeric format.
int zone = 0;
if (!ParseStringToInt(str_token.c_str(), &zone, true)) {
return false;
}
- // zone is in HHMM format, need to convert to the number of minutes
+ // Zone is in HHMM format, need to convert to the number of minutes.
bias = (zone / 100) * 60 + (zone % 100);
- } else { // text format
+ } else { // Text format.
for (size_t i = 0; i < sizeof(kRFC822_TimeZone) / sizeof(TimeZoneInfo);
++i) {
if (str_token == kRFC822_TimeZone[i].zone_name) {
@@ -282,7 +282,7 @@ bool ParseRFC822DateTime(const char* str, struct tm* time,
return true;
}
-// Parse a string to time span
+// Parse a string to time span.
//
// A TimeSpan value can be represented as
// [d.]hh:mm:ss
diff --git a/chrome/browser/sync/notifier/base/time.h b/chrome/browser/sync/notifier/base/time.h
index 9bdb6f6..4ea303f 100644
--- a/chrome/browser/sync/notifier/base/time.h
+++ b/chrome/browser/sync/notifier/base/time.h
@@ -23,10 +23,10 @@ const time64 kMaxTime100ns = UINT64_C(9223372036854775807);
// time and Jan 1, 1970.
#ifdef WIN32
// On Windows time64 is seconds since Jan 1, 1601.
-#define kStart100NsTimeToEpoch (116444736000000000uI64) // Jan 1, 1970 in time64
+#define kStart100NsTimeToEpoch (116444736000000000uI64)
#else
// On Unix time64 is seconds since Jan 1, 1970.
-#define kStart100NsTimeToEpoch (0) // Jan 1, 1970 in time64
+#define kStart100NsTimeToEpoch (0)
#endif
// Time difference in 100NS granularity between platform-dependent starting
@@ -38,9 +38,9 @@ const time64 kMaxTime100ns = UINT64_C(9223372036854775807);
namespace notifier {
-// Get the current time represented in 100NS granularity
-// Different platform might return the value since different starting time.
-// Win32 platform returns the value since Jan 1, 1601.
+// Get the current time represented in 100NS granularity. Different platform
+// might return the value since different starting time. Win32 platform returns
+// the value since Jan 1, 1601.
time64 GetCurrent100NSTime();
// Get the current time represented in 100NS granularity since epoch
@@ -59,7 +59,7 @@ bool UtcTimeToLocalTime(struct tm* tm);
// Convert from local time to UTC time.
bool LocalTimeToUtcTime(struct tm* tm);
-// Returns the local time as a string suitable for logging
+// Returns the local time as a string suitable for logging.
// Note: This is *not* threadsafe, so only call it from the main thread.
char* GetLocalTimeAsString();
@@ -96,7 +96,8 @@ char* GetLocalTimeAsString();
// / ( ("+" / "-") 4DIGIT ) ; Local differential
// ; hours+min. (HHMM)
// Return local time if ret_local_time == true, return UTC time otherwise
-bool ParseRFC822DateTime(const char* str, struct tm* time, bool ret_local_time);
+bool ParseRFC822DateTime(const char* str, struct tm* time,
+ bool ret_local_time);
// Parse a string to time span.
//
diff --git a/chrome/browser/sync/notifier/base/time_unittest.cc b/chrome/browser/sync/notifier/base/time_unittest.cc
index 0c440f9..9054798 100644
--- a/chrome/browser/sync/notifier/base/time_unittest.cc
+++ b/chrome/browser/sync/notifier/base/time_unittest.cc
@@ -24,7 +24,7 @@ TEST_F(TimeTest, ParseRFC822DateTime) {
EXPECT_EQ(t.tm_year, 2005 - 1900);
EXPECT_EQ(t.tm_mon, 4);
EXPECT_EQ(t.tm_mday, 16);
- EXPECT_TRUE(t.tm_hour == 15 || t.tm_hour == 14); // daylight saving time
+ EXPECT_TRUE(t.tm_hour == 15 || t.tm_hour == 14); // Daylight saving time.
EXPECT_EQ(t.tm_min, 44);
EXPECT_EQ(t.tm_sec , 18);
@@ -41,7 +41,7 @@ TEST_F(TimeTest, ParseRFC822DateTime) {
EXPECT_EQ(t.tm_year, 2005 - 1900);
EXPECT_EQ(t.tm_mon, 4);
EXPECT_EQ(t.tm_mday, 16);
- EXPECT_TRUE(t.tm_hour == 15 || t.tm_hour == 14); // daylight saving time
+ EXPECT_TRUE(t.tm_hour == 15 || t.tm_hour == 14); // Daylight saving time.
EXPECT_EQ(t.tm_min, 56);
EXPECT_EQ(t.tm_sec, 18);
}
diff --git a/chrome/browser/sync/notifier/base/timer.h b/chrome/browser/sync/notifier/base/timer.h
index dd68c73..c2894a1 100644
--- a/chrome/browser/sync/notifier/base/timer.h
+++ b/chrome/browser/sync/notifier/base/timer.h
@@ -17,8 +17,7 @@ class Timer : private talk_base::Task {
// Call Abort() to stop the timer.
using talk_base::Task::Abort;
- // Call to find out when the timer is set to go off
- // Returns int64
+ // Call to find out when the timer is set to go off. Returns int64.
using talk_base::Task::get_timeout_time;
// Call to set the timeout interval.
diff --git a/chrome/browser/sync/notifier/base/utils.h b/chrome/browser/sync/notifier/base/utils.h
index 2105233..5ca7705 100644
--- a/chrome/browser/sync/notifier/base/utils.h
+++ b/chrome/browser/sync/notifier/base/utils.h
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Utility functions
+// Utility functions.
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_BASE_UTILS_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_BASE_UTILS_H_
@@ -12,16 +12,15 @@
#include "chrome/browser/sync/notifier/base/static_assert.h"
-// return error if the first argument evaluates to false
+// Return error if the first argument evaluates to false.
#define RET_IF_FALSE(x) do { if (!(x)) return false; } while (false)
-// Protocol constants
+// Protocol constants.
const char kHttpProto[] = "http://";
const char kHttpsProto[] = "https://";
-// Initialize a POD to zero.
-// Using this function requires discipline. Don't use for types that have a
-// v-table or virtual bases.
+// Initialize a POD to zero. Using this function requires discipline. Don't
+// use for types that have a v-table or virtual bases.
template <typename T>
inline void SetZero(T& p) {
// Guard against the easy mistake of
@@ -37,18 +36,18 @@ inline void SetZero(T& p) {
// Test to see if the type has constructors.
union CtorTest {
- T t;
- int i;
+ T t;
+ int i;
};
- // TODO(sync) There might be a way to test if the type has virtuals
+ // TODO(sync) There might be a way to test if the type has virtuals.
// For now, if we zero a type with virtuals by mistake, it is going to crash
// predictable at run-time when the virtuals are called.
memset(&p, 0, sizeof(T));
}
-// Used to delete each element in a vector<T*>/deque<T*>
-// (and then empty the sequence).
+// Used to delete each element in a vector<T*>/deque<T*> (and then empty the
+// sequence).
template <class T>
void CleanupSequence(T* items) {
for (typename T::iterator it(items->begin()); it != items->end(); ++it) {
@@ -57,17 +56,17 @@ void CleanupSequence(T* items) {
items->clear();
}
-// Typically used to clean up values used in a hash_map
-// that had Type* as values.
+// Typically used to clean up values used in a hash_map that had Type* as
+// values.
//
// WARNING: This function assumes that T::clear will not access the values
-// (or the keys if they are the same as the values). This is true
-// for hash_map.
+// (or the keys if they are the same as the values). This is true for
+// hash_map.
template <class T>
void CleanupMap(T* items) {
// This is likely slower than a for loop, but we have to do it this way. In
- // some of the maps we use, deleting it->second causes it->first to be deleted
- // as well, and that seems to send the iterator in a tizzy.
+ // some of the maps we use, deleting it->second causes it->first to be
+ // deleted as well, and that seems to send the iterator in a tizzy.
typename T::iterator it = items->begin();
while (it != items->end()) {
items->erase(it->first);
@@ -76,7 +75,7 @@ void CleanupMap(T* items) {
}
}
-// Get the value of an element in the map with the specified name
+// Get the value of an element in the map with the specified name.
template <class T>
void GetMapElement(const std::map<const std::string, const T>& m,
const char* name,
diff --git a/chrome/browser/sync/notifier/base/win32/time_win32.cc b/chrome/browser/sync/notifier/base/win32/time_win32.cc
index 34a53fe..e5c5713 100644
--- a/chrome/browser/sync/notifier/base/win32/time_win32.cc
+++ b/chrome/browser/sync/notifier/base/win32/time_win32.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Time functions
+// Windows specific yime functions.
#include <time.h>
#include <windows.h>
@@ -17,7 +17,7 @@ namespace notifier {
time64 FileTimeToTime64(const FILETIME& file_time) {
return static_cast<time64>(file_time.dwHighDateTime) << 32 |
- file_time.dwLowDateTime;
+ file_time.dwLowDateTime;
}
void Time64ToFileTime(const time64& time, FILETIME* ft) {
@@ -31,9 +31,9 @@ void TmTimeToSystemTime(const struct tm& tm, SYSTEMTIME* sys_time) {
ASSERT(sys_time);
SetZero(*sys_time);
- // tm's year is 1900 based, systemtime's year is absolute
+ // tm's year is 1900 based, systemtime's year is absolute.
sys_time->wYear = tm.tm_year + 1900;
- // tm's month is 0 based, but systemtime's month is 1 based
+ // tm's month is 0 based, but systemtime's month is 1 based.
sys_time->wMonth = tm.tm_mon + 1;
sys_time->wDay = tm.tm_mday;
sys_time->wDayOfWeek = tm.tm_wday;
@@ -46,9 +46,9 @@ void SystemTimeToTmTime(const SYSTEMTIME& sys_time, struct tm* tm) {
ASSERT(tm);
SetZero(*tm);
- // tm's year is 1900 based, systemtime's year is absolute
+ // tm's year is 1900 based, systemtime's year is absolute.
tm->tm_year = sys_time.wYear - 1900;
- // tm's month is 0 based, but systemtime's month is 1 based
+ // tm's month is 0 based, but systemtime's month is 1 based.
tm->tm_mon = sys_time.wMonth - 1;
tm->tm_mday = sys_time.wDay;
tm->tm_wday = sys_time.wDayOfWeek;
@@ -58,12 +58,11 @@ void SystemTimeToTmTime(const SYSTEMTIME& sys_time, struct tm* tm) {
}
time64 GetCurrent100NSTime() {
- // In order to get the 100ns time we shouldn't use SystemTime
- // as it's granularity is 1 ms. Below is the correct implementation.
- // On the other hand the system clock granularity is 15 ms, so we
- // are not gaining much by having the timestamp in nano-sec
- // If we decise to go with ms, divide "time64 time" by 10000
-
+ // In order to get the 100ns time we shouldn't use SystemTime as it's
+ // granularity is 1 ms. Below is the correct implementation. On the other
+ // hand the system clock granularity is 15 ms, so we are not gaining much by
+ // having the timestamp in nano-sec. If we decide to go with ms, divide
+ // "time64 time" by 10000.
FILETIME file_time;
::GetSystemTimeAsFileTime(&file_time);
@@ -129,16 +128,16 @@ bool LocalTimeToUtcTime(struct tm* tm) {
SYSTEMTIME local_time;
TmTimeToSystemTime(*tm, &local_time);
- // Get the bias, which when added to local, gives UTC
+ // Get the bias, which when added to local, gives UTC.
TIME_ZONE_INFORMATION time_zone;
if (::GetTimeZoneInformation(&time_zone) == TIME_ZONE_ID_INVALID) {
return false;
}
- // By negating the biases, we can get translation from UTC to local
+ // By negating the biases, we can get translation from UTC to local.
time_zone.Bias *= -1;
time_zone.DaylightBias *= -1;
- time_zone.StandardBias *= -1; // this is 0 but negating for completness
+ time_zone.StandardBias *= -1; // This is 0 but negating for completness.
// We'll tell SystemTimeToTzSpecificLocalTime that the local time is actually
// UTC. With the negated bias, the "local" time that the API returns will
diff --git a/chrome/browser/sync/notifier/communicator/auth_task.cc b/chrome/browser/sync/notifier/communicator/auth_task.cc
index 11eba2d..ba98fe3 100644
--- a/chrome/browser/sync/notifier/communicator/auth_task.cc
+++ b/chrome/browser/sync/notifier/communicator/auth_task.cc
@@ -61,7 +61,6 @@ int AuthTask::ProcessResponse() {
return STATE_DONE;
}
-
void AuthTask::OnAuthDone() {
Wake();
}
diff --git a/chrome/browser/sync/notifier/communicator/auth_task.h b/chrome/browser/sync/notifier/communicator/auth_task.h
index b5141f8..b71bd92 100644
--- a/chrome/browser/sync/notifier/communicator/auth_task.h
+++ b/chrome/browser/sync/notifier/communicator/auth_task.h
@@ -15,18 +15,19 @@ class GaiaAuth;
}
namespace notifier {
+
class Login;
-// Create an authenticated talk url from an unauthenticated url
+// Create an authenticated talk url from an unauthenticated url.
class AuthTask : public talk_base::Task, public sigslot::has_slots<> {
public:
AuthTask(talk_base::Task* parent, Login* login, const char* url);
// An abort method which doesn't take any parameters.
- // (talk_base::Task::Abort() has a default parameter.)
+ // (talk_base::Task::Abort() has a default parameter).
//
- // The primary purpose of this method is to allow a
- // signal to be hooked up to abort this task.
+ // The primary purpose of this method is to allow a signal to be hooked up to
+ // abort this task.
void Abort() {
talk_base::Task::Abort();
}
@@ -62,9 +63,8 @@ class AuthTask : public talk_base::Task, public sigslot::has_slots<> {
std::string service_;
std::string url_;
- // the following members are used for cases where we don't want to
- // redirect through gaia, but rather via the end-site's mechanism
- // (We need this for orkut)
+ // The following members are used for cases where we don't want to redirect
+ // through gaia, but rather via the end-site's mechanism.
bool use_gaia_redirect_;
std::string redir_auth_prefix_;
std::string redir_continue_;
diff --git a/chrome/browser/sync/notifier/communicator/auto_reconnect.cc b/chrome/browser/sync/notifier/communicator/auto_reconnect.cc
index 108fc1d..2b737e9 100644
--- a/chrome/browser/sync/notifier/communicator/auto_reconnect.cc
+++ b/chrome/browser/sync/notifier/communicator/auto_reconnect.cc
@@ -10,6 +10,7 @@
#include "talk/base/common.h"
namespace notifier {
+
const int kResetReconnectInfoDelaySec = 2;
AutoReconnect::AutoReconnect(talk_base::Task* parent,
@@ -44,7 +45,7 @@ int AutoReconnect::seconds_until() const {
return 0;
}
- // Do a ceiling on the value (to avoid returning before its time)
+ // Do a ceiling on the value (to avoid returning before its time).
int64 result = (time_until_100ns + kSecsTo100ns - 1) / kSecsTo100ns;
return static_cast<int>(result);
}
@@ -54,17 +55,17 @@ void AutoReconnect::StartReconnectTimer() {
}
void AutoReconnect::StartReconnectTimerWithInterval(time64 interval_ns) {
- // Don't call StopReconnectTimer because we don't
- // want other classes to detect that the intermediate state of
- // the timer being stopped. (We're avoiding the call to SignalTimerStartStop
- // while reconnect_timer_ is NULL.)
+ // Don't call StopReconnectTimer because we don't want other classes to
+ // detect that the intermediate state of the timer being stopped.
+ // (We're avoiding the call to SignalTimerStartStop while reconnect_timer_ is
+ // NULL).
if (reconnect_timer_) {
reconnect_timer_->Abort();
reconnect_timer_ = NULL;
}
reconnect_timer_ = new Timer(parent_,
static_cast<int>(interval_ns / kSecsTo100ns),
- false); // repeat
+ false); // Repeat.
reconnect_timer_->SignalTimeout.connect(this,
&AutoReconnect::DoReconnect);
SignalTimerStartStop();
@@ -73,7 +74,7 @@ void AutoReconnect::StartReconnectTimerWithInterval(time64 interval_ns) {
void AutoReconnect::DoReconnect() {
reconnect_timer_ = NULL;
- // if timed out again, double autoreconnect time up to 30 minutes
+ // If timed out again, double autoreconnect time up to 30 minutes.
reconnect_interval_ns_ *= 2;
if (reconnect_interval_ns_ > 30 * kMinsTo100ns) {
reconnect_interval_ns_ = 30 * kMinsTo100ns;
@@ -114,8 +115,8 @@ void AutoReconnect::SetupReconnectInterval() {
void AutoReconnect::OnPowerSuspend(bool suspended) {
if (suspended) {
- // When the computer comes back on, ensure that the reconnect
- // happens quickly (5 - 25 seconds).
+ // When the computer comes back on, ensure that the reconnect happens
+ // quickly (5 - 25 seconds).
reconnect_interval_ns_ = (rand() % 20 + 5) * kSecsTo100ns;
}
}
@@ -125,13 +126,12 @@ void AutoReconnect::OnClientStateChange(Login::ConnectionState state) {
StopDelayedResetTimer();
switch (state) {
case Login::STATE_RETRYING:
- // do nothing
+ // Do nothing.
break;
case Login::STATE_CLOSED:
- // When the user has been logged out and no auto-reconnect
- // is happening, then the autoreconnect intervals should be
- // reset.
+ // When the user has been logged out and no auto-reconnect is happening,
+ // then the autoreconnect intervals should be reset.
ResetState();
break;
@@ -140,17 +140,17 @@ void AutoReconnect::OnClientStateChange(Login::ConnectionState state) {
break;
case Login::STATE_OPENED:
- // Reset autoreconnect timeout sequence after being connected
- // for a bit of time. This helps in the case that we are
- // connecting briefly and then getting disconnect like when
- // an account hits an abuse limit.
+ // Reset autoreconnect timeout sequence after being connected for a bit
+ // of time. This helps in the case that we are connecting briefly and
+ // then getting disconnect like when an account hits an abuse limit.
StopReconnectTimer();
delayed_reset_timer_ = new Timer(parent_,
kResetReconnectInfoDelaySec,
- false); // repeat
+ false); // Repeat.
delayed_reset_timer_->SignalTimeout.connect(this,
&AutoReconnect::ResetState);
break;
}
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/auto_reconnect.h b/chrome/browser/sync/notifier/communicator/auto_reconnect.h
index f4ee4ec..9a1a1e2 100644
--- a/chrome/browser/sync/notifier/communicator/auto_reconnect.h
+++ b/chrome/browser/sync/notifier/communicator/auto_reconnect.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_AUTO_RECONNECT_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_AUTO_RECONNECT_H_
+
#include <string>
#include "chrome/browser/sync/notifier/base/time.h"
@@ -15,6 +16,7 @@ class Task;
}
namespace notifier {
+
class NetworkStatusDetectorTask;
class Timer;
@@ -26,14 +28,14 @@ class AutoReconnect : public sigslot::has_slots<> {
void StopReconnectTimer();
void OnClientStateChange(Login::ConnectionState state);
- // Callback when power is suspended
+ // Callback when power is suspended.
void OnPowerSuspend(bool suspended);
void set_idle(bool idle) {
is_idle_ = idle;
}
- // Returns true if the auto-retry is to be done (pending a countdown)
+ // Returns true if the auto-retry is to be done (pending a countdown).
bool is_retrying() const {
return reconnect_timer_ != NULL;
}
@@ -41,6 +43,7 @@ class AutoReconnect : public sigslot::has_slots<> {
int seconds_until() const;
sigslot::signal0<> SignalTimerStartStop;
sigslot::signal0<> SignalStartConnection;
+
private:
void StartReconnectTimerWithInterval(time64 interval_ns);
void DoReconnect();
@@ -59,13 +62,14 @@ class AutoReconnect : public sigslot::has_slots<> {
DISALLOW_COPY_AND_ASSIGN(AutoReconnect);
};
-// Wait 2 seconds until after we actually connect to
-// reset reconnect related items.
+// Wait 2 seconds until after we actually connect to reset reconnect related
+// items.
//
-// The reason for this delay is to avoid the situation in which buzz
-// is trying to block the client due to abuse and the client responses
-// by going into rapid reconnect mode, which makes the problem more severe.
+// The reason for this delay is to avoid the situation in which buzz is trying
+// to block the client due to abuse and the client responses by going into
+// rapid reconnect mode, which makes the problem more severe.
extern const int kResetReconnectInfoDelaySec;
} // namespace notifier
+
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_AUTO_RECONNECT_H_
diff --git a/chrome/browser/sync/notifier/communicator/connection_options.cc b/chrome/browser/sync/notifier/communicator/connection_options.cc
index 2d49bb6..8231126 100644
--- a/chrome/browser/sync/notifier/communicator/connection_options.cc
+++ b/chrome/browser/sync/notifier/communicator/connection_options.cc
@@ -13,4 +13,5 @@ ConnectionOptions::ConnectionOptions()
use_proxy_auth_(0),
allow_unverified_certs_(false) {
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/connection_options.h b/chrome/browser/sync/notifier/communicator/connection_options.h
index 6b559f0..9e29ee6 100644
--- a/chrome/browser/sync/notifier/communicator/connection_options.h
+++ b/chrome/browser/sync/notifier/communicator/connection_options.h
@@ -33,8 +33,8 @@ class ConnectionOptions {
void set_auth_user(const std::string& val) { auth_user_ = val; }
void set_auth_pass(const talk_base::CryptString& val) { auth_pass_ = val; }
- // Setting this to true opens a security hole, so it is
- // *highly* recommended that you don't do this.
+ // Setting this to true opens a security hole, so it is *highly* recommended
+ // that you don't do this.
void set_allow_unverified_certs(bool allow_unverified_certs) {
allow_unverified_certs_ = allow_unverified_certs;
}
@@ -48,8 +48,9 @@ class ConnectionOptions {
std::string auth_user_;
talk_base::CryptString auth_pass_;
bool allow_unverified_certs_;
- // allow the copy constructor and operator=
+ // Allow the copy constructor and operator=.
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_OPTIONS_H_
diff --git a/chrome/browser/sync/notifier/communicator/connection_settings.h b/chrome/browser/sync/notifier/communicator/connection_settings.h
index d83b1fc..9dcfadb 100644
--- a/chrome/browser/sync/notifier/communicator/connection_settings.h
+++ b/chrome/browser/sync/notifier/communicator/connection_settings.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_
+
#include <deque>
#include <string>
#include <vector>
@@ -32,9 +33,9 @@ class ConnectionSettings {
private:
cricket::ProtocolType protocol_; // PROTO_TCP, PROTO_SSLTCP, etc.
- talk_base::SocketAddress server_; // Server
- talk_base::ProxyInfo proxy_; // Proxy info
- // need copy constructor due to use in stl deque
+ talk_base::SocketAddress server_; // Server.
+ talk_base::ProxyInfo proxy_; // Proxy info.
+ // Need copy constructor due to use in stl deque.
};
class ConnectionSettingsList {
@@ -73,6 +74,7 @@ class ConnectionSettingsList {
std::vector<uint32> iplist_seen_;
DISALLOW_COPY_AND_ASSIGN(ConnectionSettingsList);
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_
diff --git a/chrome/browser/sync/notifier/communicator/const_communicator.h b/chrome/browser/sync/notifier/communicator/const_communicator.h
index 79bb92e..5b78bd1 100644
--- a/chrome/browser/sync/notifier/communicator/const_communicator.h
+++ b/chrome/browser/sync/notifier/communicator/const_communicator.h
@@ -4,8 +4,10 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONST_COMMUNICATOR_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONST_COMMUNICATOR_H_
+
namespace notifier {
-// The default port for jabber/xmpp communications
+// The default port for jabber/xmpp communications.
const int kDefaultXmppPort = 5222;
} // namespace notifier
+
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONST_COMMUNICATOR_H_
diff --git a/chrome/browser/sync/notifier/communicator/login.cc b/chrome/browser/sync/notifier/communicator/login.cc
index 5614dba..4e2feb1 100644
--- a/chrome/browser/sync/notifier/communicator/login.cc
+++ b/chrome/browser/sync/notifier/communicator/login.cc
@@ -27,7 +27,7 @@
namespace notifier {
-// redirect valid for 5 minutes
+// Redirect valid for 5 minutes.
static const time64 kRedirectTimeoutNs = 5 * kMinsTo100ns;
// Disconnect if network stays down for more than 10 seconds.
@@ -86,9 +86,8 @@ Login::Login(talk_base::Task* parent,
&AutoReconnect::OnPowerSuspend);
}
-// defined so that the destructors are executed here (and
-// the corresponding classes don't need to be included in
-// the header file)
+// Defined so that the destructors are executed here (and the corresponding
+// classes don't need to be included in the header file).
Login::~Login() {
if (single_attempt_) {
single_attempt_->Abort();
@@ -99,7 +98,7 @@ Login::~Login() {
void Login::StartConnection() {
// If there is a server redirect, use it.
if (GetCurrent100NSTime() < redirect_time_ns_ + kRedirectTimeoutNs) {
- // Override server/port with redirect values
+ // Override server/port with redirect values.
talk_base::SocketAddress server_override;
server_override.SetIP(redirect_server_, false);
ASSERT(redirect_port_ != 0);
@@ -166,11 +165,10 @@ void Login::OnClientStateChange(buzz::XmppEngine::State state) {
switch (state) {
case buzz::XmppEngine::STATE_NONE:
case buzz::XmppEngine::STATE_CLOSED:
- // Ignore the closed state (because
- // we may be trying the next dns entry).
+ // Ignore the closed state (because we may be trying the next dns entry).
//
- // But we go to this state for other
- // signals when there is no retry happening.
+ // But we go to this state for other signals when there is no retry
+ // happening.
new_state = state_;
break;
@@ -218,7 +216,7 @@ void Login::HandleClientStateChange(ConnectionState new_state) {
reset_unexpected_timer_ = new Timer(parent_,
kResetReconnectInfoDelaySec,
- false); // repeat
+ false); // Repeat.
reset_unexpected_timer_->SignalTimeout.connect(
this,
&Login::ResetUnexpectedDisconnect);
@@ -248,8 +246,8 @@ int Login::seconds_until_reconnect() const {
void Login::UseNextConnection() {
if (!single_attempt_) {
- // Just in case, there is an obscure case that causes
- // this to get called when there is no single_attempt_.
+ // Just in case, there is an obscure case that causes this to get called
+ // when there is no single_attempt_.
return;
}
single_attempt_->UseNextConnection();
@@ -257,8 +255,8 @@ void Login::UseNextConnection() {
void Login::UseCurrentConnection() {
if (!single_attempt_) {
- // Just in case, there is an obscure case that causes
- // this to get called when there is no single_attempt_.
+ // Just in case, there is an obscure case that causes this to get called
+ // when there is no single_attempt_.
return;
}
single_attempt_->UseCurrentConnection();
@@ -271,7 +269,7 @@ void Login::OnRedirect(const std::string& redirect_server, int redirect_port) {
redirect_server_ = redirect_server;
redirect_port_ = redirect_port;
- // Drop the current connection, and start the login process again
+ // Drop the current connection, and start the login process again.
StartConnection();
}
@@ -281,13 +279,12 @@ void Login::OnUnexpectedDisconnect() {
reset_unexpected_timer_ = NULL;
}
- // Start the login process again
+ // Start the login process again.
if (unexpected_disconnect_occurred_) {
- // If we already have received an unexpected disconnect recently,
- // then our account may have be jailed due to abuse, so we shouldn't
- // make the situation worse by trying really hard to reconnect.
- // Instead, we'll do the autoreconnect route, which has exponential
- // back-off.
+ // If we already have received an unexpected disconnect recently, then our
+ // account may have be jailed due to abuse, so we shouldn't make the
+ // situation worse by trying really hard to reconnect. Instead, we'll do
+ // the autoreconnect route, which has exponential back-off.
DoAutoReconnect();
return;
}
@@ -303,11 +300,10 @@ void Login::ResetUnexpectedDisconnect() {
void Login::DoAutoReconnect() {
bool allow_auto_reconnect =
login_settings_->connection_options().auto_reconnect();
- // Start the reconnect time before aborting the connection
- // to ensure that AutoReconnect::is_retrying() is true, so
- // that the Login doesn't transition to the CLOSED state
- // (which would cause the reconnection timer to reset
- // and not double).
+ // Start the reconnect time before aborting the connection to ensure that
+ // AutoReconnect::is_retrying() is true, so that the Login doesn't
+ // transition to the CLOSED state (which would cause the reconnection timer
+ // to reset and not double).
if (allow_auto_reconnect) {
auto_reconnect_->StartReconnectTimer();
}
@@ -325,9 +321,9 @@ void Login::DoAutoReconnect() {
void Login::OnNetworkStateDetected(bool was_alive, bool is_alive) {
if (was_alive && !is_alive) {
- // Our network connection just went down.
- // Setup a timer to disconnect. Don't disconnect immediately to avoid
- // constant connection/disconnection due to flaky network interfaces.
+ // Our network connection just went down. Setup a timer to disconnect.
+ // Don't disconnect immediately to avoid constant
+ // connection/disconnection due to flaky network interfaces.
ASSERT(disconnect_timer_ == NULL);
disconnect_timer_ = new Timer(parent_, kDisconnectionDelaySecs, false);
disconnect_timer_->SignalTimeout.connect(this,
diff --git a/chrome/browser/sync/notifier/communicator/login.h b/chrome/browser/sync/notifier/communicator/login.h
index 480f52b..284435b 100644
--- a/chrome/browser/sync/notifier/communicator/login.h
+++ b/chrome/browser/sync/notifier/communicator/login.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_LOGIN_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_LOGIN_H_
+
#include <string>
#include "chrome/browser/sync/notifier/base/time.h"
@@ -27,6 +28,7 @@ class Task;
} // namespace talk_base
namespace notifier {
+
class AutoReconnect;
class ConnectionOptions;
class LoginFailure;
@@ -36,12 +38,12 @@ struct ServerInformation;
class SingleLoginAttempt;
class Timer;
-// Does the login, keeps it alive (with refreshing cookies
-// and reattempting login when disconnected), figures out
-// what actions to take on the various errors that may occur.
+// Does the login, keeps it alive (with refreshing cookies and reattempting
+// login when disconnected), figures out what actions to take on the various
+// errors that may occur.
class Login : public sigslot::has_slots<> {
public:
- // network_status and firewall may be NULL
+ // network_status and firewall may be NULL.
Login(talk_base::Task* parent,
const buzz::XmppClientSettings& user_settings,
const ConnectionOptions& options,
@@ -57,8 +59,8 @@ class Login : public sigslot::has_slots<> {
enum ConnectionState {
STATE_CLOSED,
- // Same as the closed state but indicates that a countdown is happening
- // for auto-retrying the connection.
+ // Same as the closed state but indicates that a countdown is happening for
+ // auto-retrying the connection.
STATE_RETRYING,
STATE_OPENING,
STATE_OPENED,
@@ -73,29 +75,27 @@ class Login : public sigslot::has_slots<> {
void UseCurrentConnection();
buzz::XmppClient* xmpp_client();
- // Start the auto-reconnect. It may not do the auto-reconnect
- // if auto-reconnect is turned off.
+ // Start the auto-reconnect. It may not do the auto-reconnect if
+ // auto-reconnect is turned off.
void DoAutoReconnect();
const LoginSettings& login_settings() const {
return *(login_settings_.get());
}
- // Returns the best guess at the host responsible for
- // the account (which we use to determine if it is
- // a dasher account or not).
+ // Returns the best guess at the host responsible for the account (which we
+ // use to determine if it is a dasher account or not).
//
- // After login this may return a more accurate answer,
- // which accounts for open sign-up accounts.
+ // After login this may return a more accurate answer, which accounts for
+ // open sign-up accounts.
const std::string& google_host() const;
- // Analogous to google_host but for the user account.
- // ("fred" in "fred@gmail.com")
+ // Analogous to google_host but for the user account ("fred" in
+ // "fred@gmail.com").
const std::string& google_user() const;
- // Returns the proxy that is being used to connect (or
- // the default proxy information if all attempted
- // connections failed).
+ // Returns the proxy that is being used to connect (or the default proxy
+ // information if all attempted connections failed).
//
// Do not call until StartConnection has been called.
const talk_base::ProxyInfo& proxy() const;
@@ -150,6 +150,7 @@ class Login : public sigslot::has_slots<> {
DISALLOW_COPY_AND_ASSIGN(Login);
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_LOGIN_H_
diff --git a/chrome/browser/sync/notifier/communicator/login_failure.cc b/chrome/browser/sync/notifier/communicator/login_failure.cc
index 6f29d87..80d2f74 100644
--- a/chrome/browser/sync/notifier/communicator/login_failure.cc
+++ b/chrome/browser/sync/notifier/communicator/login_failure.cc
@@ -42,4 +42,5 @@ const buzz::CaptchaChallenge& LoginFailure::captcha() const {
xmpp_error_ == buzz::XmppEngine::ERROR_MISSING_USERNAME);
return *captcha_.get();
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/login_failure.h b/chrome/browser/sync/notifier/communicator/login_failure.h
index cbddc00..1f2a9a6 100644
--- a/chrome/browser/sync/notifier/communicator/login_failure.h
+++ b/chrome/browser/sync/notifier/communicator/login_failure.h
@@ -17,11 +17,11 @@ namespace notifier {
class LoginFailure {
public:
enum LoginError {
- // Check the xmpp_error for more information
+ // Check the xmpp_error for more information.
XMPP_ERROR,
- // If the certificate has expired, it usually means that the
- // computer's clock isn't set correctly.
+ // If the certificate has expired, it usually means that the computer's
+ // clock isn't set correctly.
CERTIFICATE_EXPIRED_ERROR,
// Apparently, there is a proxy that needs authentication information.
@@ -37,12 +37,12 @@ class LoginFailure {
int subcode,
const buzz::CaptchaChallenge& captcha);
- // Used as the first level of error information
+ // Used as the first level of error information.
LoginError error() const {
return error_;
}
- // Returns the XmppEngine only. Valid if and only if error() == XMPP_ERROR
+ // Returns the XmppEngine only. Valid if and only if error() == XMPP_ERROR.
//
// Handler should mimic logic from PhoneWindow::ShowConnectionError
// (except that the DiagnoseConnectionError has already been done).
@@ -65,5 +65,7 @@ class LoginFailure {
DISALLOW_COPY_AND_ASSIGN(LoginFailure);
};
+
} // namespace notifier
+
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_LOGIN_FAILURE_H_
diff --git a/chrome/browser/sync/notifier/communicator/login_settings.cc b/chrome/browser/sync/notifier/communicator/login_settings.cc
index 2983dd8..bf450bc 100644
--- a/chrome/browser/sync/notifier/communicator/login_settings.cc
+++ b/chrome/browser/sync/notifier/communicator/login_settings.cc
@@ -30,7 +30,7 @@ LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings,
server_count_(server_count),
user_settings_(new buzz::XmppClientSettings(user_settings)),
connection_options_(new ConnectionOptions(options)) {
- // Note: firewall may be NULL
+ // Note: firewall may be NULL.
ASSERT(server_list != 0);
ASSERT(server_count > 0);
for (int i = 0; i < server_count_; ++i) {
@@ -38,9 +38,8 @@ LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings,
}
}
-// defined so that the destructors are executed here (and
-// the corresponding classes don't need to be included in
-// the header file)
+// Defined so that the destructors are executed here (and the corresponding
+// classes don't need to be included in the header file).
LoginSettings::~LoginSettings() {
}
@@ -54,4 +53,5 @@ void LoginSettings::set_server_override(
void LoginSettings::clear_server_override() {
server_override_.reset();
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/mailbox.cc b/chrome/browser/sync/notifier/communicator/mailbox.cc
index 22b6690..ebb32a8 100644
--- a/chrome/browser/sync/notifier/communicator/mailbox.cc
+++ b/chrome/browser/sync/notifier/communicator/mailbox.cc
@@ -21,9 +21,9 @@
namespace notifier {
-// Labels are a list of strings seperated by a '|' character.
-// The '|' character is escaped with a backslash ('\\') and the
-// backslash is also escaped with a backslash.
+// Labels are a list of strings seperated by a '|' character. The '|' character
+// is escaped with a backslash ('\\') and the backslash is also escaped with a
+// backslash.
static void ParseLabelSet(const std::string& text,
MessageThread::StringSet* labels) {
const char* input_cur = text.c_str();
@@ -43,7 +43,7 @@ static void ParseLabelSet(const std::string& text,
}
if (*input_cur == '\\') {
- // skip a character in the input and break if we are at the end
+ // Skip a character in the input and break if we are at the end.
input_cur++;
if (input_cur >= input_end)
break;
@@ -98,7 +98,7 @@ void MessageThread::Clear() {
MessageThread& MessageThread::operator=(const MessageThread& r) {
if (&r != this) {
Clear();
- // Copy everything
+ // Copy everything.
r.AssertValid();
thread_id_ = r.thread_id_;
date64_ = r.date64_;
@@ -130,7 +130,7 @@ MessageThread* MessageThread::CreateFromXML(
return info;
}
-// Init from a chunk of XML
+// Init from a chunk of XML.
bool MessageThread::InitFromXml(const buzz::XmlElement* src) {
labels_ = new StringSet;
senders_ = new MailSenderList;
@@ -196,7 +196,7 @@ bool MessageThread::unread() const {
}
#ifdef _DEBUG
-// non-debug version is inline and empty
+// Non-debug version is inline and empty.
void MessageThread::AssertValid() const {
assert(thread_id_ != 0);
assert(senders_ != NULL);
@@ -207,8 +207,6 @@ void MessageThread::AssertValid() const {
}
#endif
-
-
MailBox* MailBox::CreateFromXML(const buzz::XmlElement* src) {
MailBox* mail_box = new MailBox();
if (!mail_box || !mail_box->InitFromXml(src)) {
@@ -218,9 +216,8 @@ MailBox* MailBox::CreateFromXML(const buzz::XmlElement* src) {
return mail_box;
}
-// Init from a chunk of XML
-bool MailBox::InitFromXml(const buzz::XmlElement* src)
-{
+// Init from a chunk of XML.
+bool MailBox::InitFromXml(const buzz::XmlElement* src) {
if (src->Name() != buzz::kQnMailBox)
return false;
@@ -253,7 +250,7 @@ bool MailBox::InitFromXml(const buzz::XmlElement* src)
const size_t kMaxShortnameLength = 12;
-// Tip: If you extend this list of chars, do not include '-'
+// Tip: If you extend this list of chars, do not include '-'.
const char name_delim[] = " ,.:;\'\"()[]{}<>*@";
class SenderFormatter {
@@ -297,11 +294,10 @@ class SenderFormatter {
}
private:
- // Attempt to shorten to the first word in a person's name
- // We could revisit and do better at international punctuation,
- // but this is what cricket did, and it should be removed
- // soon when gmail does the notification instead of us
- // forming it on the client.
+ // Attempt to shorten to the first word in a person's name We could revisit
+ // and do better at international punctuation, but this is what cricket did,
+ // and it should be removed soon when gmail does the notification instead of
+ // us forming it on the client.
static void ShortenName(std::string* name) {
size_t start = name->find_first_not_of(name_delim);
if (start != std::string::npos && start > 0) {
@@ -330,10 +326,10 @@ class SenderFormatter {
}
name_ = sender_.name();
- // Handle the case of no name or a name looks like an email address.
- // When mail is sent to "Quality@example.com" <quality-team@example.com>,
- // we shouldn't show "Quality@example.com" as the name.
- // Instead use the email address (without the @...)
+ // Handle the case of no name or a name looks like an email address. When
+ // mail is sent to "Quality@example.com" <quality-team@example.com>, we
+ // shouldn't show "Quality@example.com" as the name. Instead, use the email
+ // address (without the @...)
if (name_.empty() || name_.find_first_of("@") != std::string::npos) {
name_ = sender_.address();
size_t at_index = name_.find_first_of("@");
@@ -413,20 +409,19 @@ class SenderFormatterList {
// Add all unread messages.
if (any_unread) {
- // It should be rare, but there may be cases when all of the
- // senders appear to have read the message.
+ // It should be rare, but there may be cases when all of the senders
+ // appear to have read the message.
first_unread_index_ = is_first_unread() ? 0 : senders_.size();
for (size_t i = 0; i < sender_list.size(); ++i) {
if (!sender_list[i].unread()) {
continue;
}
- // Don't add the originator if it is already at the
- // start of the "unread" list.
+ // Don't add the originator if it is already at the start of the
+ // "unread" list.
if (sender_list[i].originator() && is_first_unread()) {
continue;
}
- senders_.push_back(new SenderFormatter(sender_list[i],
- me_address));
+ senders_.push_back(new SenderFormatter(sender_list[i], me_address));
}
}
}
@@ -449,9 +444,8 @@ class SenderFormatterList {
}
int length = 1;
- // Add as many senders as we can in the given space.
- // Computes the visible length at each iteration,
- // but does not construct the actual html.
+ // Add as many senders as we can in the given space. Computes the visible
+ // length at each iteration, but does not construct the actual html.
while (length < space && AddNextSender()) {
int new_length = ConstructHtml(is_first_unread(), NULL);
// Remove names to avoid truncating
@@ -476,7 +470,7 @@ class SenderFormatterList {
}
}
- // Now construct the actual html
+ // Now construct the actual html.
std::string html_list;
length = ConstructHtml(is_first_unread(), &html_list);
if (length > space) {
@@ -488,17 +482,16 @@ class SenderFormatterList {
private:
int ComputeSpacePerSender(int space) const {
- // Why the "- 2"? To allow for the " .. " which may occur
- // after the names, and no matter what always allow at least
- // 2 characters per sender.
+ // Why the "- 2"? To allow for the " .. " which may occur after the names,
+ // and no matter what always allow at least 2 characters per sender.
return talk_base::_max<int>(space / visible_count() - 2, 2);
}
- // Finds the next sender that should be added to the "from" list
- // and sets it to visible.
+ // Finds the next sender that should be added to the "from" list and sets it
+ // to visible.
//
- // This method may be called until it returns false or
- // until RemoveLastAddedSender is called.
+ // This method may be called until it returns false or until
+ // RemoveLastAddedSender is called.
bool AddNextSender() {
// The progression is:
// 1. Add the person who started the thread, which is the first message.
@@ -508,14 +501,14 @@ class SenderFormatterList {
// (unless it has already been added).
// If there is no message (i.e. at index -1), return false.
//
- // Typically, this method is called until it returns false or
- // all of the space available is used.
+ // Typically, this method is called until it returns false or all of the
+ // space available is used.
switch (state_) {
case INITIAL_STATE:
state_ = FIRST_MESSAGE;
index_ = 0;
- // If the server behaves odd and doesn't send us any senders,
- // do something graceful.
+ // If the server behaves odd and doesn't send us any senders, do
+ // something graceful.
if (senders_.size() == 0) {
return false;
}
@@ -527,7 +520,7 @@ class SenderFormatterList {
index_ = first_unread_index_;
break;
}
- // fall through
+ // Fall through.
case FIRST_UNREAD_MESSAGE:
state_ = LAST_MESSAGE;
index_ = senders_.size() - 1;
@@ -569,13 +562,13 @@ class SenderFormatterList {
// Constructs the html of the SenderList and returns the length of the
// visible text.
//
- // The algorithm simply walks down the list of Senders, appending
- // the html for each visible sender, and adding ellipsis or commas
- // in between, whichever is appropriate.
+ // The algorithm simply walks down the list of Senders, appending the html
+ // for each visible sender, and adding ellipsis or commas in between,
+ // whichever is appropriate.
//
- // html Filled with html. Maybe NULL if the html doesn't
- // need to be constructed yet (useful for simply
- // determining the length of the visible text).
+ // html Filled with html. Maybe NULL if the html doesn't need to be
+ // constructed yet (useful for simply determining the length of the
+ // visible text).
//
// returns The approximate visible length of the html.
int ConstructHtml(bool first_is_unread,
@@ -586,7 +579,7 @@ class SenderFormatterList {
int length = 0;
- // The first is always visible
+ // The first is always visible.
const SenderFormatter* sender = senders_[0];
const std::string& originator_name = sender->name();
length += originator_name.length();
@@ -600,18 +593,17 @@ class SenderFormatterList {
sender = senders_[i];
if (sender->visible()) {
- // Handle the separator
+ // Handle the separator.
between = elided ? "&nbsp;" : kNormalSeparator;
- // Ignore the , for length because it is so narrow,
- // so in both cases above the space is the only things
- // that counts for spaces.
+ // Ignore the , for length because it is so narrow, so in both cases
+ // above the space is the only things that counts for spaces.
length++;
- // Handle the name
+ // Handle the name.
const std::string name = sender->name();
length += name.size();
- // Construct the html
+ // Construct the html.
if (html) {
html->append(between);
html->append(FormatName(name, sender->is_unread()));
@@ -619,7 +611,7 @@ class SenderFormatterList {
elided = false;
} else if (!elided) {
between = kEllidedSeparator;
- length += 2; // ".." is narrow
+ length += 2; // ".." is narrow.
if (html) {
html->append(between);
}
@@ -679,4 +671,5 @@ std::string GetSenderHtml(const MailSenderList& sender_list,
html_list.append(count_html);
return html_list;
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/mailbox.h b/chrome/browser/sync/notifier/communicator/mailbox.h
index 009de73..feadc86 100644
--- a/chrome/browser/sync/notifier/communicator/mailbox.h
+++ b/chrome/browser/sync/notifier/communicator/mailbox.h
@@ -26,7 +26,7 @@ class MailAddress {
}
const std::string& name() const { return name_; }
const std::string& address() const { return address_; }
- std::string safe_name() const; // will return *something*
+ std::string safe_name() const; // Will return *something*.
private:
std::string name_;
std::string address_;
@@ -71,20 +71,19 @@ class MessageThread {
~MessageThread();
// Try to parse the XML to create a MessageThreadInfo. If NULL is returned
- // then we either ran out of memory or there was an error in parsing the
- // XML
+ // then we either ran out of memory or there was an error in parsing the XML.
static MessageThread* CreateFromXML(const buzz::XmlElement* src);
MessageThread& operator=(const MessageThread& r);
- // SameThreadAs : name is self evident
+ // SameThreadAs : name is self evident.
bool SameThreadAs(const MessageThread& r) {
AssertValid();
r.AssertValid();
return (thread_id_ == r.thread_id_);
}
- // SameAs : true if thread has same id and messages
+ // SameAs : true if thread has same id and messages.
// Assumes that messages don't disappear from threads.
bool SameAs(const MessageThread& r) {
AssertValid();
@@ -161,6 +160,7 @@ std::string GetSenderHtml(const MailSenderList& sender_list,
int message_count,
const std::string& me_address,
int space);
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_MAILBOX_H_
diff --git a/chrome/browser/sync/notifier/communicator/mailbox_unittest.cc b/chrome/browser/sync/notifier/communicator/mailbox_unittest.cc
index a705033..5c08ce1 100644
--- a/chrome/browser/sync/notifier/communicator/mailbox_unittest.cc
+++ b/chrome/browser/sync/notifier/communicator/mailbox_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/sync/notifier/communicator/mailbox.h"
namespace notifier {
+
TEST_NOTIFIER_F(MailBoxTest);
TEST_F(MailBoxTest, SingleSenderHtml) {
@@ -114,4 +115,5 @@ TEST_F(MailBoxTest, SenderWithThreeSendersShowing) {
"ted&nbsp;..&nbsp;<b>Bob</b>&nbsp;..&nbsp;<b>Person1</b>&nbsp;(6)",
sender_html.c_str());
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/product_info.h b/chrome/browser/sync/notifier/communicator/product_info.h
index 1da60b0..04e3c46 100644
--- a/chrome/browser/sync/notifier/communicator/product_info.h
+++ b/chrome/browser/sync/notifier/communicator/product_info.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_PRODUCT_INFO_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_PRODUCT_INFO_H_
+
#include <string>
namespace notifier {
diff --git a/chrome/browser/sync/notifier/communicator/single_login_attempt.cc b/chrome/browser/sync/notifier/communicator/single_login_attempt.cc
index 68fe272..fe25e8c 100644
--- a/chrome/browser/sync/notifier/communicator/single_login_attempt.cc
+++ b/chrome/browser/sync/notifier/communicator/single_login_attempt.cc
@@ -26,6 +26,7 @@
#include "talk/xmpp/xmppclientsettings.h"
namespace notifier {
+
static void FillProxyInfo(const buzz::XmppClientSettings& xcs,
talk_base::ProxyInfo* proxy) {
ASSERT(proxy != NULL);
@@ -88,8 +89,8 @@ SingleLoginAttempt::SingleLoginAttempt(talk_base::Task* parent,
}
SingleLoginAttempt::~SingleLoginAttempt() {
- // If this assertion goes off, it means that "Stop()" didn't get
- // called like it should have been.
+ // If this assertion goes off, it means that "Stop()" didn't get called like
+ // it should have been.
ASSERT(client_ == NULL);
}
@@ -106,9 +107,9 @@ int SingleLoginAttempt::ProcessStart() {
ASSERT(GetState() == talk_base::Task::STATE_START);
connection_generator_->StartGenerating();
- // After being started, this class is callback driven and does
- // signaling from those callbacks (with checks to see if it is
- // done if it may be called back from something that isn't a child task).
+ // After being started, this class is callback driven and does signaling from
+ // those callbacks (with checks to see if it is done if it may be called back
+ // from something that isn't a child task).
return talk_base::Task::STATE_BLOCKED;
}
@@ -116,10 +117,9 @@ void SingleLoginAttempt::Stop() {
ClearClient();
talk_base::Task::Stop();
- // No more signals should happen after being stopped.
- // (This is needed because some of these signals
- // happen due to other components doing signaling which
- // may continue running even though this task is stopped.)
+ // No more signals should happen after being stopped. This is needed because
+ // some of these signals happen due to other components doing signaling which
+ // may continue running even though this task is stopped.
SignalUnexpectedDisconnect.disconnect_all();
SignalRedirect.disconnect_all();
SignalLoginFailure.disconnect_all();
@@ -151,10 +151,10 @@ void SingleLoginAttempt::OnAttemptedAllConnections(
LOG(INFO) << "Connection failed with error " << code_;
- // We were connected and we had a problem
+ // We were connected and we had a problem.
if (successful_connection_ && auto_reconnect()) {
SignalNeedAutoReconnect();
- // expect to be deleted at this point
+ // Expect to be deleted at this point.
return;
}
@@ -180,23 +180,23 @@ void SingleLoginAttempt::DoLogin(
}
buzz::XmppClientSettings client_settings;
- // set the user settings portion
+ // Set the user settings portion.
*static_cast<buzz::XmppClientSettings*>(&client_settings) =
login_settings_->user_settings();
- // fill in the rest of the client settings
+ // Fill in the rest of the client settings.
connection_settings.FillXmppClientSettings(&client_settings);
client_ = new buzz::XmppClient(this);
SignalLogInput.repeat(client_->SignalLogInput);
SignalLogOutput.repeat(client_->SignalLogOutput);
- // listen for connection progress
+ // Listen for connection progress.
client_->SignalStateChange.connect(this,
&SingleLoginAttempt::OnClientStateChange);
- // transition to "start"
+ // Transition to "start".
OnClientStateChange(buzz::XmppEngine::STATE_START);
- // start connecting
+ // Start connecting.
client_->Connect(client_settings, login_settings_->lang(),
CreateSocket(client_settings),
CreatePreXmppAuth(client_settings));
@@ -204,16 +204,15 @@ void SingleLoginAttempt::DoLogin(
}
void SingleLoginAttempt::OnAuthenticationError() {
- // We can check this flag later if all connection options fail
+ // We can check this flag later if all connection options fail.
need_authentication_ = true;
}
void SingleLoginAttempt::OnCertificateExpired() {
- // We can check this flag later if all connection options fail
+ // We can check this flag later if all connection options fail.
certificate_expired_ = true;
}
-
buzz::AsyncSocket* SingleLoginAttempt::CreateSocket(
const buzz::XmppClientSettings& xcs) {
bool allow_unverified_certs =
@@ -234,7 +233,7 @@ buzz::PreXmppAuth* SingleLoginAttempt::CreatePreXmppAuth(
if (login_settings_->no_gaia_auth())
return NULL;
- // For GMail, use Gaia preauthentication over HTTP
+ // For GMail, use Gaia preauthentication over HTTP.
buzz::GaiaAuth* auth = new buzz::GaiaAuth(GetUserAgentString(),
GetProductSignature());
auth->SignalAuthenticationError.connect(
@@ -256,26 +255,26 @@ buzz::PreXmppAuth* SingleLoginAttempt::CreatePreXmppAuth(
}
void SingleLoginAttempt::OnFreshAuthCookie(const std::string& auth_cookie) {
- // Remember this is a fresh cookie
+ // Remember this is a fresh cookie.
cookie_refreshed_ = true;
- // TODO(sync): do the cookie logic (part of which is in the #if 0 below)
+ // TODO(sync): do the cookie logic (part of which is in the #if 0 below).
- // The following code is what PhoneWindow does for the equivalent method
+ // The following code is what PhoneWindow does for the equivalent method.
#if 0
// Save cookie
AccountInfo current(account_history_.current());
current.set_auth_cookie(auth_cookie);
account_history_.set_current(current);
- // Calc next time to refresh cookie, between 5 and 10 days
- // The cookie has 14 days of life; this gives at least 4 days of retries
- // before the current cookie expires, maximizing the chance of
- // having a valid cookie next time the connection servers go down.
+ // Calc next time to refresh cookie, between 5 and 10 days. The cookie has
+ // 14 days of life; this gives at least 4 days of retries before the current
+ // cookie expires, maximizing the chance of having a valid cookie next time
+ // the connection servers go down.
FTULL now;
// NOTE: The following line is win32. Address this when implementing this
- // code (doing "the cookie logic")
+ // code (doing "the cookie logic").
GetSystemTimeAsFileTime(&(now.ft));
ULONGLONG five_days = (ULONGLONG)10000 * 1000 * 60 * 60 * 24 * 5; // 5 days
ULONGLONG random = (ULONGLONG)10000 * // get to 100 ns units
@@ -351,12 +350,11 @@ void SingleLoginAttempt::OnHttpTestDone(talk_base::SignalThread* thread) {
return;
}
- // Otherwise lets transmute the error into ERROR_SOCKET, and put
- // the subcode as an indicator of what we think the problem
- // might be.
+ // Otherwise lets transmute the error into ERROR_SOCKET, and put the subcode
+ // as an indicator of what we think the problem might be.
#if 0
- // TODO(sync): determine if notifier has an analogous situation
+ // TODO(sync): determine if notifier has an analogous situation.
//
// We weren't able to do an HTTP GET of www.google.com:80
@@ -365,14 +363,13 @@ void SingleLoginAttempt::OnHttpTestDone(talk_base::SignalThread* thread) {
GAutoupdater::Version version_installed(GetProductVersion().c_str());
if (version_logged_in < version_installed) {
//
- // Google Talk has been updated and can no longer connect
- // to the Google Talk Service. Your firewall is probably
- // not allowing the new version of Google Talk to connect
- // to the internet. Please adjust your firewall settings
- // to allow the new version of Google Talk to connect to
- // the internet.
+ // Google Talk has been updated and can no longer connect to the Google
+ // Talk Service. Your firewall is probably not allowing the new version of
+ // Google Talk to connect to the internet. Please adjust your firewall
+ // settings to allow the new version of Google Talk to connect to the
+ // internet.
//
- // We'll use the "error=1" to help figure this out for now
+ // We'll use the "error=1" to help figure this out for now.
//
LoginFailure failure(LoginFailure::XMPP_ERROR,
buzz::XmppEngine::ERROR_SOCKET,
@@ -387,9 +384,8 @@ void SingleLoginAttempt::OnHttpTestDone(talk_base::SignalThread* thread) {
//
//
- // Google Talk is unable to use your internet connection. Either your
- // network isn't configured or Google Talk is being blocked by
- // a local firewall.
+ // Google Talk is unable to use your internet connection. Either your network
+ // isn't configured or Google Talk is being blocked by a local firewall.
//
// We'll use the "error=0" to help figure this out for now
//
@@ -410,7 +406,7 @@ void SingleLoginAttempt::OnClientStateChange(buzz::XmppEngine::State state) {
case buzz::XmppEngine::STATE_NONE:
case buzz::XmppEngine::STATE_START:
case buzz::XmppEngine::STATE_OPENING:
- // do nothing
+ // Do nothing.
break;
case buzz::XmppEngine::STATE_OPEN:
successful_connection_ = true;
@@ -456,7 +452,7 @@ void SingleLoginAttempt::OnClientStateChangeClosed(
SignalLogoff();
return;
} else if (previous_state == buzz::XmppEngine::STATE_OPEN) {
- // Handler should attempt reconnect
+ // Handler should attempt reconnect.
SignalUnexpectedDisconnect();
return;
} else {
@@ -469,12 +465,12 @@ void SingleLoginAttempt::HandleConnectionPasswordError(
const buzz::CaptchaChallenge& captcha_challenge) {
LOG(LS_VERBOSE) << "SingleLoginAttempt::HandleConnectionPasswordError";
- // Clear the auth cookie
+ // Clear the auth cookie.
std::string current_auth_cookie =
login_settings_->user_settings().auth_cookie();
login_settings_->modifiable_user_settings()->set_auth_cookie("");
- // If there was an auth cookie and it was the same as the last
- // auth cookie, then it is a stale cookie. Retry login.
+ // If there was an auth cookie and it was the same as the last auth cookie,
+ // then it is a stale cookie. Retry login.
if (!current_auth_cookie.empty() && !cookie_refreshed_) {
UseCurrentConnection();
return;
@@ -492,13 +488,13 @@ void SingleLoginAttempt::HandleConnectionError(
const buzz::CaptchaChallenge& captcha_challenge) {
LOG_F(LS_VERBOSE) << "(" << code << ", " << subcode << ")";
- // Save off the error code information, so we can use it
- // to tell the user what went wrong if all else fails
+ // Save off the error code information, so we can use it to tell the user
+ // what went wrong if all else fails.
code_ = code;
subcode_ = subcode;
if ((code_ == buzz::XmppEngine::ERROR_UNAUTHORIZED) ||
(code_ == buzz::XmppEngine::ERROR_MISSING_USERNAME)) {
- // There was a problem with credentials (username/password)
+ // There was a problem with credentials (username/password).
HandleConnectionPasswordError(captcha_challenge);
return;
}
@@ -506,7 +502,7 @@ void SingleLoginAttempt::HandleConnectionError(
// Unexpected disconnect,
// Unreachable host,
// Or internal server binding error -
- // All these are temporary problems, so continue reconnecting
+ // All these are temporary problems, so continue reconnecting.
// GaiaAuth signals this directly via SignalCertificateExpired, but
// SChannelAdapter propagates the error through SocketWindow as a socket
@@ -518,7 +514,7 @@ void SingleLoginAttempt::HandleConnectionError(
login_settings_->modifiable_user_settings()->set_resource("");
- // Look for stream::error server redirection stanza "see-other-host"
+ // Look for stream::error server redirection stanza "see-other-host".
if (stream_error) {
const buzz::XmlElement* other =
stream_error->FirstNamed(buzz::QN_XSTREAM_SEE_OTHER_HOST);
@@ -526,8 +522,8 @@ void SingleLoginAttempt::HandleConnectionError(
const buzz::XmlElement* text =
stream_error->FirstNamed(buzz::QN_XSTREAM_TEXT);
if (text) {
- // Yep, its a "stream:error" with "see-other-host" text, let's
- // parse out the server:port, and then reconnect with that.
+ // Yep, its a "stream:error" with "see-other-host" text, let's parse
+ // out the server:port, and then reconnect with that.
const std::string& redirect = text->BodyText();
unsigned int colon = redirect.find(":");
int redirect_port = kDefaultXmppPort;
@@ -540,12 +536,12 @@ void SingleLoginAttempt::HandleConnectionError(
std::istringstream ist(port_text);
ist >> redirect_port;
}
- // we never allow a redirect to port 0
+ // We never allow a redirect to port 0.
if (redirect_port == 0) {
redirect_port = kDefaultXmppPort;
}
SignalRedirect(redirect_server, redirect_port);
- // may be deleted at this point
+ // May be deleted at this point.
return;
}
}
@@ -556,7 +552,8 @@ void SingleLoginAttempt::HandleConnectionError(
return;
}
- // Iterate to the next possible connection (still trying to connect)
+ // Iterate to the next possible connection (still trying to connect).
UseNextConnection();
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/single_login_attempt.h b/chrome/browser/sync/notifier/communicator/single_login_attempt.h
index ec265ea..735a781 100644
--- a/chrome/browser/sync/notifier/communicator/single_login_attempt.h
+++ b/chrome/browser/sync/notifier/communicator/single_login_attempt.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_
+
#include <string>
#include "chrome/browser/sync/notifier/communicator/login.h"
@@ -29,21 +30,21 @@ class Task;
}
namespace notifier {
+
class ConnectionSettings;
class LoginFailure;
class LoginSettings;
struct ServerInformation;
class XmppConnectionGenerator;
-// Handles all of the aspects of a single login attempt
-// (across multiple ip addresses) and maintainence. By containing
-// this within one class, when another login attempt is made,
-// this class will be disposed and all of the signalling for the
-// previous login attempt will be cleaned up immediately.
+// Handles all of the aspects of a single login attempt (across multiple ip
+// addresses) and maintainence. By containing this within one class, when
+// another login attempt is made, this class will be disposed and all of the
+// signalling for the previous login attempt will be cleaned up immediately.
//
-// This is a task to allow for cleaning this up when a signal
-// is being fired. Technically, delete this during the firing of
-// a signal could work but it is fragile.
+// This is a task to allow for cleaning this up when a signal is being fired.
+// Technically, delete this during the firing of a signal could work but it is
+// fragile.
class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
public:
SingleLoginAttempt(talk_base::Task* parent,
@@ -58,18 +59,17 @@ class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
return client_;
}
- // Returns the proxy that is being used to connect (or
- // the default proxy information if all attempted
- // connections failed).
+ // Returns the proxy that is being used to connect (or the default proxy
+ // information if all attempted connections failed).
const talk_base::ProxyInfo& proxy() const;
- // Typically handled by creating a new SingleLoginAttempt
- // and doing StartConnection
+ // Typically handled by creating a new SingleLoginAttempt and doing
+ // StartConnection.
sigslot::signal0<> SignalUnexpectedDisconnect;
- // Typically handled by setting storing the redirect for 5 seconds,
- // and setting it into LoginSettings, then creating a new SingleLoginAttempt,
- // and doing StartConnection.
+ // Typically handled by storing the redirect for 5 seconds, and setting it
+ // into LoginSettings, then creating a new SingleLoginAttempt, and doing
+ // StartConnection.
//
// SignalRedirect(const std::string& redirect_server, int redirect_port);
sigslot::signal2<const std::string&, int> SignalRedirect;
@@ -82,8 +82,8 @@ class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
// See the LoginFailure for how to handle this.
sigslot::signal1<const LoginFailure&> SignalLoginFailure;
- // Sent when there is a graceful log-off (state goes to closed
- // with no error)
+ // Sent when there is a graceful log-off (state goes to closed with no
+ // error).
sigslot::signal0<> SignalLogoff;
sigslot::repeater2<const char*, int> SignalLogInput;
@@ -97,7 +97,7 @@ class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
buzz::AsyncSocket* CreateSocket(const buzz::XmppClientSettings& xcs);
buzz::PreXmppAuth* CreatePreXmppAuth(const buzz::XmppClientSettings& xcs);
- // cleans up any xmpp client state to get ready for a new one
+ // Cleans up any xmpp client state to get ready for a new one.
void ClearClient();
void HandleConnectionError(
@@ -134,6 +134,7 @@ class SingleLoginAttempt : public talk_base::Task, public sigslot::has_slots<> {
DISALLOW_COPY_AND_ASSIGN(SingleLoginAttempt);
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_SINGLE_LOGIN_ATTEMPT_H_
diff --git a/chrome/browser/sync/notifier/communicator/talk_auth_task.cc b/chrome/browser/sync/notifier/communicator/talk_auth_task.cc
index a69609c7..f085b16 100644
--- a/chrome/browser/sync/notifier/communicator/talk_auth_task.cc
+++ b/chrome/browser/sync/notifier/communicator/talk_auth_task.cc
@@ -70,4 +70,5 @@ std::string TalkAuthTask::GetAuthenticatedUrl(
std::string TalkAuthTask::GetSID() const {
return auth_->GetSID();
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/talk_auth_task.h b/chrome/browser/sync/notifier/communicator/talk_auth_task.h
index 2f690a37..da00f2a 100644
--- a/chrome/browser/sync/notifier/communicator/talk_auth_task.h
+++ b/chrome/browser/sync/notifier/communicator/talk_auth_task.h
@@ -14,9 +14,10 @@ class GaiaAuth;
}
namespace notifier {
+
class Login;
-// Create an authenticated talk url from an unauthenticated url
+// Create an authenticated talk url from an unauthenticated url.
class TalkAuthTask : public talk_base::Task, public sigslot::has_slots<> {
public:
TalkAuthTask(talk_base::Task* parent,
@@ -26,8 +27,8 @@ class TalkAuthTask : public talk_base::Task, public sigslot::has_slots<> {
// An abort method which doesn't take any parameters.
// (talk_base::Task::Abort() has a default parameter.)
//
- // The primary purpose of this method is to allow a
- // signal to be hooked up to abort this task.
+ // The primary purpose of this method is to allow a signal to be hooked up to
+ // abort this task.
void Abort() {
talk_base::Task::Abort();
}
@@ -43,7 +44,7 @@ class TalkAuthTask : public talk_base::Task, public sigslot::has_slots<> {
bool HadError() const;
- // TODO(sync): add captcha support
+ // TODO(sync): add captcha support.
protected:
virtual int ProcessStart();
@@ -57,6 +58,7 @@ class TalkAuthTask : public talk_base::Task, public sigslot::has_slots<> {
std::string url_;
DISALLOW_COPY_AND_ASSIGN(TalkAuthTask);
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_TALK_AUTH_TASK_H_
diff --git a/chrome/browser/sync/notifier/communicator/xml_parse_helpers.cc b/chrome/browser/sync/notifier/communicator/xml_parse_helpers.cc
index b05f439..e4d27cf 100644
--- a/chrome/browser/sync/notifier/communicator/xml_parse_helpers.cc
+++ b/chrome/browser/sync/notifier/communicator/xml_parse_helpers.cc
@@ -29,12 +29,12 @@ buzz::XmlElement* ReadXmlFromStream(talk_base::StreamInterface* stream) {
while(true) {
size_t read = 0;
- // Read a chunk
+ // Read a chunk.
result = stream->Read(buf, kBufferSize, &read, NULL);
if (result != talk_base::SR_SUCCESS)
break;
- // Pass it to the parser
+ // Pass it to the parser.
parser.Parse(buf, read, false);
}
@@ -91,11 +91,11 @@ void WriteXmlToStream(talk_base::StreamInterface* stream,
const buzz::XmlElement* xml) {
// Save it all to a string and then write that string out to disk.
//
- // This is probably really inefficient in multiple ways. We probably
- // have an entire string copy of the XML in memory twice -- once in the
- // stream and once in the string. There is probably a way to get the data
- // directly out of the stream but I don't have the time to decode the stream
- // classes right now.
+ // This is probably really inefficient in multiple ways. We probably have an
+ // entire string copy of the XML in memory twice -- once in the stream and
+ // once in the string. There is probably a way to get the data directly out
+ // of the stream but I don't have the time to decode the stream classes right
+ // now.
std::ostringstream s;
buzz::XmlPrinter::PrintXml(&s, xml);
std::string output_string = s.str();
@@ -135,9 +135,7 @@ bool SetStringAttr(buzz::XmlElement* element, const buzz::QName& attribute,
return true;
}
-
-// XmlStream
-
+// XmlStream.
XmlStream::XmlStream()
: state_(talk_base::SS_OPEN),
builder_(new buzz::XmlBuilder()),
diff --git a/chrome/browser/sync/notifier/communicator/xml_parse_helpers.h b/chrome/browser/sync/notifier/communicator/xml_parse_helpers.h
index 0c918bd..ae5ed35 100644
--- a/chrome/browser/sync/notifier/communicator/xml_parse_helpers.h
+++ b/chrome/browser/sync/notifier/communicator/xml_parse_helpers.h
@@ -19,6 +19,7 @@ class QName;
}
namespace notifier {
+
buzz::XmlElement* ReadXmlFromStream(talk_base::StreamInterface* stream);
bool ParseInt64Attr(const buzz::XmlElement* element,
const buzz::QName& attribute, int64* result);
diff --git a/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.cc b/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.cc
index f3a5f4c..871f1f7 100644
--- a/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.cc
+++ b/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// XmppConnectionGenerator does the following algorithm:
// proxy = ResolveProxyInformation(connection_options)
// for server in server_list
@@ -68,7 +68,7 @@ const talk_base::ProxyInfo& XmppConnectionGenerator::proxy() const {
return settings->proxy();
}
-// Starts resolving proxy information
+// Starts resolving proxy information.
void XmppConnectionGenerator::StartGenerating() {
LOG(LS_VERBOSE) << "XmppConnectionGenerator::StartGenerating";
@@ -108,24 +108,23 @@ void XmppConnectionGenerator::OnProxyDetect(
ASSERT(proxy_detect);
settings_list_->SetProxy(proxy_detect->proxy());
- // Start iterating through the connections (which
- // are generated on demand).
+ // Start iterating through the connections (which are generated on demand).
UseNextConnection();
}
void XmppConnectionGenerator::UseNextConnection() {
- // Trying to connect
+ // Trying to connect.
- // Iterate to the next possible connection
+ // Iterate to the next possible connection.
settings_index_++;
if (settings_index_ < settings_list_->GetCount()) {
- // We have more connection settings in the settings_list_ to try, kick
- // off the next one.
+ // We have more connection settings in the settings_list_ to try, kick off
+ // the next one.
UseCurrentConnection();
return;
}
- // Iterate to the next possible server
+ // Iterate to the next possible server.
server_index_++;
if (server_index_ < server_count_) {
AsyncDNSLookup* dns_lookup = new AsyncDNSLookup(
@@ -139,7 +138,7 @@ void XmppConnectionGenerator::UseNextConnection() {
return;
}
- // All out of possibilities
+ // All out of possibilities.
HandleExhaustedConnections();
}
@@ -147,7 +146,7 @@ void XmppConnectionGenerator::OnServerDNSResolved(
AsyncDNSLookup* dns_lookup) {
LOG(LS_VERBOSE) << "XmppConnectionGenerator::OnServerDNSResolved";
- // Print logging info
+ // Print logging info.
LOG(LS_VERBOSE) << " server: " <<
server_list_[server_index_].server.ToString() <<
" error: " << dns_lookup->error();
@@ -165,7 +164,7 @@ void XmppConnectionGenerator::OnServerDNSResolved(
<< talk_base::SocketAddress::IPToString(dns_lookup->ip_list()[i]);
}
- // Build the ip list
+ // Build the ip list.
assert(settings_list_.get());
settings_index_ = -1;
settings_list_->ClearPermutations();
@@ -179,7 +178,7 @@ void XmppConnectionGenerator::OnServerDNSResolved(
UseNextConnection();
}
-static const char * const PROTO_NAMES[cricket::PROTO_LAST+1] = {
+static const char* const PROTO_NAMES[cricket::PROTO_LAST + 1] = {
"udp", "tcp", "ssltcp"
};
@@ -207,4 +206,5 @@ void XmppConnectionGenerator::HandleExhaustedConnections() {
<< ", " << first_dns_error_ << ")";
SignalExhaustedSettings(successfully_resolved_dns_, first_dns_error_);
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h b/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h
index 03a7a8f..e0bdd50 100644
--- a/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h
+++ b/chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_XMPP_CONNECTION_GENERATOR_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_XMPP_CONNECTION_GENERATOR_H_
+
#include <vector>
#include "talk/base/scoped_ptr.h"
@@ -18,6 +19,7 @@ class Task;
}
namespace notifier {
+
class AsyncDNSLookup;
class ConnectionOptions;
class ConnectionSettings;
@@ -28,14 +30,15 @@ struct ServerInformation {
bool special_port_magic;
};
-// Resolves dns names and iterates through the various ip address
-// and transport combinations.
+// Resolves dns names and iterates through the various ip address and transport
+// combinations.
class XmppConnectionGenerator : public sigslot::has_slots<> {
public:
- // parent is the parent for any tasks needed during this operation
- // proxy_only indicates if true connections are only attempted using the proxy
- // server_list is the list of connections to attempt in priority order
- // server_count is the number of items in the server list
+ // parent is the parent for any tasks needed during this operation.
+ // proxy_only indicates if true connections are only attempted using the
+ // proxy.
+ // server_list is the list of connections to attempt in priority order.
+ // server_count is the number of items in the server list.
XmppConnectionGenerator(talk_base::Task* parent,
const ConnectionOptions* options,
bool proxy_only,
@@ -43,8 +46,8 @@ class XmppConnectionGenerator : public sigslot::has_slots<> {
int server_count);
~XmppConnectionGenerator();
- // Only call this once. Create a new XmppConnectionGenerator and
- // delete the current one if the process needs to start again.
+ // Only call this once. Create a new XmppConnectionGenerator and delete the
+ // current one if the process needs to start again.
void StartGenerating();
void UseNextConnection();
@@ -64,10 +67,10 @@ class XmppConnectionGenerator : public sigslot::has_slots<> {
void HandleExhaustedConnections();
talk_base::scoped_ptr<ConnectionSettingsList> settings_list_;
- int settings_index_; // the setting that is currently being used
+ int settings_index_; // The setting that is currently being used.
talk_base::scoped_array<ServerInformation> server_list_;
int server_count_;
- int server_index_; // the server that is current being used
+ int server_index_; // The server that is current being used.
bool proxy_only_;
bool successfully_resolved_dns_;
int first_dns_error_;
@@ -76,6 +79,7 @@ class XmppConnectionGenerator : public sigslot::has_slots<> {
talk_base::Task* parent_;
DISALLOW_COPY_AND_ASSIGN(XmppConnectionGenerator);
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_XMPP_CONNECTION_GENERATOR_H_
diff --git a/chrome/browser/sync/notifier/communicator/xmpp_log.cc b/chrome/browser/sync/notifier/communicator/xmpp_log.cc
index 30b0036..4d30bea 100644
--- a/chrome/browser/sync/notifier/communicator/xmpp_log.cc
+++ b/chrome/browser/sync/notifier/communicator/xmpp_log.cc
@@ -17,7 +17,7 @@
namespace notifier {
static bool IsAuthTag(const char* str, size_t len) {
- // Beware that str is not NULL terminated
+ // Beware that str is not NULL terminated.
if (str[0] == '<' &&
str[1] == 'a' &&
str[2] == 'u' &&
@@ -32,7 +32,7 @@ static bool IsAuthTag(const char* str, size_t len) {
}
static bool IsChatText(const char* str, size_t len) {
- // Beware that str is not NULL terminated
+ // Beware that str is not NULL terminated.
if (str[0] == '<' &&
str[1] == 'm' &&
str[2] == 'e' &&
@@ -106,6 +106,7 @@ void XmppLog::XmppPrint(bool output) {
buffer->erase(buffer->begin(), buffer->begin() + start);
}
}
+
} // namespace notifier
#endif // if LOGGING
diff --git a/chrome/browser/sync/notifier/communicator/xmpp_log.h b/chrome/browser/sync/notifier/communicator/xmpp_log.h
index a6d12bd..cb4439d 100644
--- a/chrome/browser/sync/notifier/communicator/xmpp_log.h
+++ b/chrome/browser/sync/notifier/communicator/xmpp_log.h
@@ -38,6 +38,7 @@ class XmppLog : public sigslot::has_slots<> {
bool censor_password_;
DISALLOW_COPY_AND_ASSIGN(XmppLog);
};
+
} // namespace notifier
#endif // if LOGGING
diff --git a/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.cc b/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.cc
index 9bd65db..fbdf600 100644
--- a/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.cc
+++ b/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.cc
@@ -40,8 +40,8 @@ XmppSocketAdapter::XmppSocketAdapter(const buzz::XmppClientSettings& xcs,
XmppSocketAdapter::~XmppSocketAdapter() {
FreeState();
- // Clean up any previous socket - cannot delete socket on close because
- // close happens during the child socket's stack callback.
+ // Clean up any previous socket - cannot delete socket on close because close
+ // happens during the child socket's stack callback.
if (socket_) {
delete socket_;
socket_ = NULL;
@@ -51,7 +51,7 @@ XmppSocketAdapter::~XmppSocketAdapter() {
bool XmppSocketAdapter::FreeState() {
int code = 0;
- // Clean up the socket
+ // Clean up the socket.
if (socket_ && !(state_ == STATE_CLOSED || state_ == STATE_CLOSING)) {
code = socket_->Close();
}
@@ -76,16 +76,16 @@ bool XmppSocketAdapter::Connect(const talk_base::SocketAddress& addr) {
LOG(LS_INFO) << "XmppSocketAdapter::Connect(" << addr.ToString() << ")";
- // Clean up any previous socket - cannot delete socket on close because
- // close happens during the child socket's stack callback.
+ // Clean up any previous socket - cannot delete socket on close because close
+ // happens during the child socket's stack callback.
if (socket_) {
delete socket_;
socket_ = NULL;
}
talk_base::AsyncSocket* socket =
- talk_base::Thread::Current()->socketserver()
- ->CreateAsyncSocket(SOCK_STREAM);
+ talk_base::Thread::Current()->socketserver()->CreateAsyncSocket(
+ SOCK_STREAM);
if (!socket) {
SetWSAError(WSA_NOT_ENOUGH_MEMORY);
return false;
@@ -93,7 +93,7 @@ bool XmppSocketAdapter::Connect(const talk_base::SocketAddress& addr) {
if (firewall_) {
// TODO(sync): Change this to make WSAAsyncSockets support current thread
- // socket server
+ // socket server.
talk_base::FirewallSocketServer* fw =
static_cast<talk_base::FirewallSocketServer*>(
talk_base::Thread::Current()->socketserver());
@@ -106,20 +106,19 @@ bool XmppSocketAdapter::Connect(const talk_base::SocketAddress& addr) {
proxy_socket = new talk_base::AsyncSocksProxySocket(
socket, proxy_.address, proxy_.username, proxy_.password);
} else {
- // Note: we are trying unknown proxies as HTTPS currently
+ // Note: we are trying unknown proxies as HTTPS currently.
proxy_socket = new talk_base::AsyncHttpsProxySocket(socket,
- GetUserAgentString(), proxy_.address,
- proxy_.username, proxy_.password);
+ GetUserAgentString(), proxy_.address, proxy_.username,
+ proxy_.password);
}
if (!proxy_socket) {
SetWSAError(WSA_NOT_ENOUGH_MEMORY);
delete socket;
return false;
}
- socket = proxy_socket; // for our purposes the proxy is now the socket
+ socket = proxy_socket; // For our purposes the proxy is now the socket.
}
-// #if defined(PRODUCTION)
if (protocol_ == cricket::PROTO_SSLTCP) {
talk_base::AsyncSocket *fake_ssl_socket =
new talk_base::AsyncSSLSocket(socket);
@@ -128,37 +127,26 @@ bool XmppSocketAdapter::Connect(const talk_base::SocketAddress& addr) {
delete socket;
return false;
}
- socket = fake_ssl_socket; // for our purposes the SSL socket is the socket
+ socket = fake_ssl_socket; // For our purposes the SSL socket is the socket.
}
-// #endif // PRODUCTION
#if defined(FEATURE_ENABLE_SSL)
talk_base::SSLAdapter* ssl = talk_base::SSLAdapter::Create(socket);
socket = ssl;
#endif
-// #if !defined(PRODUCTION)
-// if (protocol_ == cricket::PROTO_SSLTCP) {
-// ssl->set_ignore_bad_cert(true);
-// ssl->StartSSL(addr.hostname().c_str(), true);
-// }
-// #endif // PRODUCTION
-
socket->SignalReadEvent.connect(this, &XmppSocketAdapter::OnReadEvent);
socket->SignalWriteEvent.connect(this, &XmppSocketAdapter::OnWriteEvent);
socket->SignalConnectEvent.connect(this, &XmppSocketAdapter::OnConnectEvent);
socket->SignalCloseEvent.connect(this, &XmppSocketAdapter::OnCloseEvent);
- // The linux implementation of socket::Connect
- // returns an error when the connect didn't complete
- // yet. This can be distinguished from a failure
- // because socket::IsBlocking is true. Perhaps,
- // the linux implementation should be made to
- // behave like the windows version which doesn't do this,
- // but it seems to be a pattern with these methods
- // that they return an error if the operation didn't
- // complete in a sync fashion and one has to check IsBlocking
- // to tell if was a "real" error.
+ // The linux implementation of socket::Connect returns an error when the
+ // connect didn't complete yet. This can be distinguished from a failure
+ // because socket::IsBlocking is true. Perhaps, the linux implementation
+ // should be made to behave like the windows version which doesn't do this,
+ // but it seems to be a pattern with these methods that they return an error
+ // if the operation didn't complete in a sync fashion and one has to check
+ // IsBlocking to tell if was a "real" error.
if (socket->Connect(addr) == SOCKET_ERROR && !socket->IsBlocking()) {
SetWSAError(socket->GetError());
delete socket;
@@ -210,8 +198,8 @@ bool XmppSocketAdapter::Write(const char* data, size_t len) {
size_t sent = 0;
- // try an immediate write when there is no buffer
- // and we aren't in SSL mode or opening the connection
+ // Try an immediate write when there is no buffer and we aren't in SSL mode
+ // or opening the connection.
if (write_buffer_length_ == 0 && IsOpen()) {
int result = socket_->Send(data, len);
if (result < 0) {
@@ -225,27 +213,26 @@ bool XmppSocketAdapter::Write(const char* data, size_t len) {
sent = static_cast<size_t>(result);
}
- // Buffer what we didn't send
+ // Buffer what we didn't send.
if (sent < len) {
QueueWriteData(data + sent, len - sent);
}
- // Service the socket right away to push the written data out in SSL mode
+ // Service the socket right away to push the written data out in SSL mode.
return HandleWritable();
}
bool XmppSocketAdapter::Close() {
if (state_ == STATE_CLOSING) {
- return false; // avoid recursion, but not unexpected
+ return false; // Avoid recursion, but not unexpected.
}
if (state_ == STATE_CLOSED) {
- // in theory should not be trying to re-InternalClose.
+ // In theory should not be trying to re-InternalClose.
SetError(ERROR_WRONGSTATE);
return false;
}
- // todo: deal with flushing close
- // (flush, don't do reads, clean ssl)
+ // TODO(sync): deal with flushing close (flush, don't do reads, clean ssl).
// If we've gotten to the point where we really do have a socket underneath
// then close it. It should call us back to tell us it is closed, and
@@ -316,7 +303,7 @@ void XmppSocketAdapter::OnCloseEvent(talk_base::AsyncSocket *socket,
LOG(LS_INFO) << "XmppSocketAdapter::OnCloseEvent(" << error << ")";
SetWSAError(error);
if (error == SOCKET_EACCES) {
- SignalAuthenticationError(); // proxy needs authentication
+ SignalAuthenticationError(); // Proxy needs authentication.
}
NotifyClose();
}
@@ -350,7 +337,7 @@ bool XmppSocketAdapter::StartTls(const std::string& verify_host_name) {
#endif // defined(FEATURE_ENABLE_SSL)
void XmppSocketAdapter::QueueWriteData(const char* data, size_t len) {
- // expand buffer if needed
+ // Expand buffer if needed.
if (write_buffer_length_ + len > write_buffer_capacity_) {
size_t new_capacity = 1024;
while (new_capacity < write_buffer_length_ + len) {
@@ -364,7 +351,7 @@ void XmppSocketAdapter::QueueWriteData(const char* data, size_t len) {
write_buffer_capacity_ = new_capacity;
}
- // copy data into the end of buffer
+ // Copy data into the end of buffer.
memcpy(write_buffer_ + write_buffer_length_, data, len);
write_buffer_length_ += len;
}
@@ -386,11 +373,11 @@ void XmppSocketAdapter::FlushWriteQueue(Error* error, int* wsa_error) {
flushed += static_cast<size_t>(sent);
}
- // remove flushed memory
+ // Remove flushed memory.
write_buffer_length_ -= flushed;
memmove(write_buffer_, write_buffer_ + flushed, write_buffer_length_);
- // when everything is flushed, deallocate the buffer if it's gotten big
+ // When everything is flushed, deallocate the buffer if it's gotten big.
if (write_buffer_length_ == 0) {
if (write_buffer_capacity_ > 8192) {
delete[] write_buffer_;
@@ -434,4 +421,5 @@ bool XmppSocketAdapter::HandleWritable() {
}
return true;
}
+
} // namespace notifier
diff --git a/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h b/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h
index 7e42988..af44246 100644
--- a/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h
+++ b/chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h
@@ -4,6 +4,7 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_XMPP_SOCKET_ADAPTER_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_XMPP_SOCKET_ADAPTER_H_
+
#include <string>
#include "talk/base/asyncsocket.h"
@@ -12,7 +13,7 @@
#include "talk/xmpp/xmppengine.h"
#ifndef _WIN32
-// Additional errors used by us from Win32 headers
+// Additional errors used by us from Win32 headers.
#define SEC_E_CERT_EXPIRED static_cast<int>(0x80090328L)
#define WSA_NOT_ENOUGH_MEMORY ENOMEM
#endif
@@ -48,7 +49,7 @@ class XmppSocketAdapter : public buzz::AsyncSocket,
sigslot::signal0<> SignalAuthenticationError;
private:
- // return false if the socket is closed
+ // Return false if the socket is closed.
bool HandleReadable();
bool HandleWritable();
@@ -80,6 +81,7 @@ class XmppSocketAdapter : public buzz::AsyncSocket,
void SetWSAError(int error);
DISALLOW_COPY_AND_ASSIGN(XmppSocketAdapter);
};
+
} // namespace notifier
#endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_XMPP_SOCKET_ADAPTER_H_
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc
index 3bc6550..dfcdf7a 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc
@@ -29,14 +29,13 @@ GaiaServer buzz::g_gaia_server;
// GaiaAuth::WorkerThread
///////////////////////////////////////////////////////////////////////////////
-// GaiaAuth is NOT invoked during SASL authenticatioin, but
-// it is invoked even before XMPP login begins. As a PreXmppAuth
-// object, it is driven by XmppClient before the XMPP socket is
-// opened. The job of GaiaAuth is to goes out using HTTPS
-// POST to grab cookies from GAIA.
-
-// It is used by XmppClient.
-// It grabs a SaslAuthenticator which knows how to play the cookie login.
+// GaiaAuth is NOT invoked during SASL authentication, but it is invoked even
+// before XMPP login begins. As a PreXmppAuth object, it is driven by
+// XmppClient before the XMPP socket is opened. The job of GaiaAuth is to goes
+// out using HTTPS POST to grab cookies from GAIA.
+//
+// It is used by XmppClient. It grabs a SaslAuthenticator which knows how to
+// play the cookie login.
class GaiaAuth::WorkerThread : public talk_base::SignalThread {
public:
@@ -82,7 +81,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
error_ = false;
} else {
talk_base::PhysicalSocketServer physical;
- talk_base::SocketServer * ss = &physical;
+ talk_base::SocketServer* ss = &physical;
if (firewall_) {
ss = new talk_base::FirewallSocketServer(ss, firewall_);
}
@@ -108,7 +107,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
g_gaia_server);
ss->Wait(kGaiaAuthTimeoutMs, true);
- error_code_ = monitor.error(); // save off the error code
+ error_code_ = monitor.error(); // Save off the error code.
if (!monitor.done()) {
LOG(INFO) << "GaiaAuth request timed out";
@@ -136,7 +135,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
captcha_challenge_ = buzz::CaptchaChallenge(captcha_token,
captcha_url);
}
- // We had no "error" - we were just unauthorized
+ // We had no "error" - we were just unauthorized.
error_ = false;
error_code_ = 0;
goto Cleanup;
@@ -159,7 +158,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
GaiaRequestAuthToken(&http, sid_, lsid_, service_, g_gaia_server);
ss->Wait(kGaiaAuthTimeoutMs, true);
- error_code_ = monitor.error(); // save off the error code
+ error_code_ = monitor.error(); // Save off the error code.
if (!monitor.done()) {
LOG(INFO) << "GaiaAuth request timed out";
@@ -182,7 +181,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
}
}
- // done authenticating
+ // Done authenticating.
Cleanup:
done_ = true;
@@ -236,8 +235,8 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
///////////////////////////////////////////////////////////////////////////////
GaiaAuth::GaiaAuth(const std::string &user_agent, const std::string &sig)
- : agent_(user_agent), signature_(sig),
- firewall_(0), worker_(NULL), done_(false) {
+ : agent_(user_agent), signature_(sig), firewall_(0), worker_(NULL),
+ done_(false) {
}
GaiaAuth::~GaiaAuth() {
@@ -257,15 +256,15 @@ void GaiaAuth::StartPreXmppAuth(const buzz::Jid& jid,
void GaiaAuth::StartTokenAuth(const buzz::Jid& jid,
const talk_base::CryptString& pass,
const std::string& service) {
- InternalStartGaiaAuth(jid, talk_base::SocketAddress(),
- pass, "", service, false);
+ InternalStartGaiaAuth(jid, talk_base::SocketAddress(), pass, "", service,
+ false);
}
void GaiaAuth::StartAuth(const buzz::Jid& jid,
const talk_base::CryptString& pass,
const std::string & service) {
- InternalStartGaiaAuth(jid, talk_base::SocketAddress(),
- pass, "", service, true);
+ InternalStartGaiaAuth(jid, talk_base::SocketAddress(), pass, "", service,
+ true);
}
void GaiaAuth::StartAuthFromSid(const buzz::Jid& jid,
@@ -281,9 +280,8 @@ void GaiaAuth::InternalStartGaiaAuth(const buzz::Jid& jid,
const std::string& token,
const std::string& service,
bool obtain_auth) {
- worker_ = new WorkerThread(jid.Str(), pass, token,
- service, agent_, signature_,
- obtain_auth, token_service_);
+ worker_ = new WorkerThread(jid.Str(), pass, token, service, agent_,
+ signature_, obtain_auth, token_service_);
worker_->set_proxy(proxy_);
worker_->set_firewall(firewall_);
worker_->set_captcha_answer(captcha_answer_);
@@ -315,36 +313,35 @@ std::string GaiaAuth::ChooseBestSaslMechanism(
std::vector<std::string>::const_iterator it;
- // a token is the weakest auth - 15s, service-limited, so prefer it.
+ // A token is the weakest auth - 15s, service-limited, so prefer it.
it = std::find(mechanisms.begin(), mechanisms.end(), "X-GOOGLE-TOKEN");
if (it != mechanisms.end())
return "X-GOOGLE-TOKEN";
- // a cookie is the next weakest - 14 days
+ // A cookie is the next weakest - 14 days.
it = std::find(mechanisms.begin(), mechanisms.end(), "X-GOOGLE-COOKIE");
if (it != mechanisms.end())
return "X-GOOGLE-COOKIE";
- // never pass @google.com passwords without encryption!!
+ // Never pass @google.com passwords without encryption!!
if (!encrypted &&
buzz::Jid(worker_->GetUsername()).domain() == "google.com") {
return "";
}
- // as a last resort, use plain authentication
+ // As a last resort, use plain authentication.
if (buzz::Jid(worker_->GetUsername()).domain() != "google.com") {
it = std::find(mechanisms.begin(), mechanisms.end(), "PLAIN");
if (it != mechanisms.end())
return "PLAIN";
}
- // No good mechanism found
+ // No good mechanism found.
return "";
}
buzz::SaslMechanism* GaiaAuth::CreateSaslMechanism(
const std::string& mechanism) {
-
if (!done_) {
return NULL;
}
@@ -370,7 +367,7 @@ buzz::SaslMechanism* GaiaAuth::CreateSaslMechanism(
worker_->GetPassword());
}
- // oh well - none of the above
+ // Oh well - none of the above.
return NULL;
}
@@ -380,10 +377,10 @@ std::string GaiaAuth::CreateAuthenticatedUrl(
return "";
std::string url;
- // Note that http_prefix always ends with a "/"
+ // Note that http_prefix always ends with a "/".
url += g_gaia_server.http_prefix()
+ "accounts/TokenAuth?auth="
- + worker_->GetToken(); // Do not URL encode - GAIA doesn't like that
+ + worker_->GetToken(); // Do not URL encode - GAIA doesn't like that.
url += "&service=" + service;
url += "&continue=" + UrlEncodeString(continue_url);
url += "&source=" + signature_;
@@ -439,4 +436,5 @@ buzz::CaptchaChallenge GaiaAuth::GetCaptchaChallenge() {
}
return worker_->GetCaptchaChallenge();
}
+
} // namespace buzz
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h
index 8919bbc..e2f3a6e 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Gaia auth code for XMPP notifier support. This should be merged with
-// the other gaia auth file when we have time.
+// Gaia auth code for XMPP notifier support. This should be merged with the
+// other gaia auth file when we have time.
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAAUTH_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAAUTH_H_
@@ -43,7 +43,7 @@ class GaiaAuth : public PreXmppAuth, public sigslot::has_slots<> {
captcha_answer_ = captcha_answer;
}
- // From inside XMPP login, this is called
+ // From inside XMPP login, this is called.
virtual void StartPreXmppAuth(const buzz::Jid& jid,
const talk_base::SocketAddress& server,
const talk_base::CryptString& pass,
@@ -53,12 +53,12 @@ class GaiaAuth : public PreXmppAuth, public sigslot::has_slots<> {
const talk_base::CryptString& pass,
const std::string& service);
- // This is used when calling GetAuth()
+ // This is used when calling GetAuth().
void StartAuth(const buzz::Jid& jid,
const talk_base::CryptString& pass,
const std::string& service);
- // This is used when bootstrapping from a download page
+ // This is used when bootstrapping from a download page.
void StartAuthFromSid(const buzz::Jid& jid,
const std::string& sid,
const std::string& service);
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc
index 3e0683c..95ca023 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc
@@ -16,10 +16,10 @@
namespace {
-std::string GetValueForKey(const std::string & key, const std::string & nvp) {
+std::string GetValueForKey(const std::string& key, const std::string& nvp) {
size_t start_of_line = 0;
size_t end_of_line = 0;
- for (;;) { // for each line
+ for (;;) { // For each line.
start_of_line = nvp.find_first_not_of("\r\n", end_of_line);
if (start_of_line == std::string::npos)
break;
@@ -41,7 +41,7 @@ std::string GetValueForKey(const std::string & key, const std::string & nvp) {
return "";
}
-} // anonymous namespace
+} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -58,14 +58,14 @@ bool GaiaServer::SetServer(const char* url) {
hostname_ = parsed.server();
port_ = parsed.port();
use_ssl_ = parsed.secure();
- return true; // parsed.valid();
+ return true;
}
bool GaiaServer::SetDebugServer(const char* server) {
const char* colon = strchr(server, ':');
if (colon) {
hostname_ = std::string(server, colon - server);
- port_ = atoi(colon+1);
+ port_ = atoi(colon + 1);
use_ssl_ = false;
return true;
}
@@ -90,10 +90,10 @@ bool GaiaRequestSid(talk_base::HttpClient* client,
buzz::Jid jid(username);
std::string usable_name = username;
if (jid.domain() == buzz::STR_DEFAULT_DOMAIN) {
- // The default domain (default.talk.google.com) is not usable
- // for Gaia auth. But both gmail.com and googlemain.com will
- // work, because the gaia server doesn't check to make sure the
- // appropriate one is being used. So we just slam on gmail.com
+ // The default domain (default.talk.google.com) is not usable for Gaia
+ // auth. But both gmail.com and googlemain.com will work, because the gaia
+ // server doesn't check to make sure the appropriate one is being used. So
+ // we just slam on gmail.com
usable_name = jid.node() + "@" + buzz::STR_GMAIL_COM;
}
@@ -138,8 +138,8 @@ GaiaResponse GaiaParseSidResponse(const talk_base::HttpClient& client,
std::string* auth) {
uint32 status_code = client.response().scode;
const talk_base::MemoryStream* stream =
- static_cast<const talk_base::MemoryStream*>(
- client.response().document.get());
+ static_cast<const talk_base::MemoryStream*>(
+ client.response().document.get());
size_t length;
stream->GetPosition(&length);
std::string response;
@@ -156,8 +156,8 @@ GaiaResponse GaiaParseSidResponse(const talk_base::HttpClient& client,
std::string image_url = GetValueForKey("CaptchaUrl", response);
if (!image_url.empty()) {
// We should activate this "full url code" once we have a better ways
- // to crack the URL for later download. Right now we are too
- // dependent on what Gaia returns.
+ // to crack the URL for later download. Right now we are too dependent
+ // on what Gaia returns.
#if 0
if (image_url.find("http://") != 0 &&
image_url.find("https://") != 0) {
@@ -202,15 +202,15 @@ bool GaiaRequestAuthToken(talk_base::HttpClient* client,
post_data += "SID=" + UrlEncodeString(sid);
post_data += "&LSID=" + UrlEncodeString(lsid);
post_data += "&service=" + service;
- post_data += "&Session=true"; // creates two week cookie
+ post_data += "&Session=true"; // Creates two week cookie.
client->reset();
client->set_server(talk_base::SocketAddress(gaia_server.hostname(),
- gaia_server.port(), false));
+ gaia_server.port(), false));
client->request().verb = talk_base::HV_POST;
client->request().path = "/accounts/IssueAuthToken";
client->request().setContent("application/x-www-form-urlencoded",
- new talk_base::MemoryStream(post_data.data(), post_data.size()));
+ new talk_base::MemoryStream(post_data.data(), post_data.size()));
client->response().document.reset(new talk_base::MemoryStream);
client->start();
return true;
@@ -223,8 +223,8 @@ GaiaResponse GaiaParseAuthTokenResponse(const talk_base::HttpClient& client,
}
const talk_base::MemoryStream* stream =
- static_cast<const talk_base::MemoryStream*>(
- client.response().document.get());
+ static_cast<const talk_base::MemoryStream*>(
+ client.response().document.get());
size_t length;
stream->GetPosition(&length);
while ((length > 0) && isspace(stream->GetBuffer()[length-1]))
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h
index e0303d0..933bc97 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h
@@ -34,7 +34,7 @@ class GaiaServer {
public:
GaiaServer();
- bool SetServer(const char* url); // protocol://server:port
+ bool SetServer(const char* url); // protocol://server:port
bool SetDebugServer(const char* server); // server:port
const std::string& hostname() const { return hostname_; }
diff --git a/chrome/browser/sync/notifier/gaia_auth/inet_aton.h b/chrome/browser/sync/notifier/gaia_auth/inet_aton.h
index a10d6cf..6a5aee5 100644
--- a/chrome/browser/sync/notifier/gaia_auth/inet_aton.h
+++ b/chrome/browser/sync/notifier/gaia_auth/inet_aton.h
@@ -8,7 +8,7 @@
#define CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_INET_ATON_H_
#ifdef WIN32
-int inet_aton(const char * cp, struct in_addr* inp);
+int inet_aton(const char* cp, struct in_addr* inp);
#endif
#endif // CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_INET_ATON_H_
diff --git a/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h b/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h
index 3e223b9..3c0941e 100644
--- a/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h
+++ b/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h
@@ -16,70 +16,67 @@
namespace sigslot {
- template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater0 : public signal0<mt_policy>,
- public has_slots<mt_policy> {
- public:
- typedef signal0<mt_policy> base_type;
- typedef repeater0<mt_policy> this_type;
-
- repeater0() { }
- explicit repeater0(const this_type& s) : base_type(s) { }
-
- void reemit() { signal0<mt_policy>::emit(); }
- void repeat(base_type &s) { s.connect(this, &this_type::reemit); }
- };
-
- template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater1 : public signal1<arg1_type, mt_policy>,
- public has_slots<mt_policy>
- {
- public:
- typedef signal1<arg1_type, mt_policy> base_type;
- typedef repeater1<arg1_type, mt_policy> this_type;
-
- repeater1() { }
- repeater1(const this_type& s) : base_type(s) { }
-
- void reemit(arg1_type a1) { signal1<arg1_type, mt_policy>::emit(a1); }
- void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
- };
-
- template<class arg1_type, class arg2_type,
- class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater2 : public signal2<arg1_type, arg2_type, mt_policy>,
- public has_slots<mt_policy>
- {
- public:
- typedef signal2<arg1_type, arg2_type, mt_policy> base_type;
- typedef repeater2<arg1_type, arg2_type, mt_policy> this_type;
-
- repeater2() { }
- repeater2(const this_type& s) : base_type(s) { }
-
- void reemit(arg1_type a1, arg2_type a2) {
- signal2<arg1_type, arg2_type, mt_policy>::emit(a1, a2);
- }
- void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
- };
-
- template<class arg1_type, class arg2_type, class arg3_type,
- class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater3 : public signal3<arg1_type, arg2_type, arg3_type, mt_policy>,
- public has_slots<mt_policy>
- {
- public:
- typedef signal3<arg1_type, arg2_type, arg3_type, mt_policy> base_type;
- typedef repeater3<arg1_type, arg2_type, arg3_type, mt_policy> this_type;
-
- repeater3() { }
- repeater3(const this_type& s) : base_type(s) { }
-
- void reemit(arg1_type a1, arg2_type a2, arg3_type a3) {
- signal3<arg1_type, arg2_type, arg3_type, mt_policy>::emit(a1, a2, a3);
- }
- void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
- };
+template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater0 : public signal0<mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal0<mt_policy> base_type;
+ typedef repeater0<mt_policy> this_type;
+
+ repeater0() { }
+ explicit repeater0(const this_type& s) : base_type(s) { }
+
+ void reemit() { signal0<mt_policy>::emit(); }
+ void repeat(base_type &s) { s.connect(this, &this_type::reemit); }
+};
+
+template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater1 : public signal1<arg1_type, mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal1<arg1_type, mt_policy> base_type;
+ typedef repeater1<arg1_type, mt_policy> this_type;
+
+ repeater1() { }
+ repeater1(const this_type& s) : base_type(s) { }
+
+ void reemit(arg1_type a1) { signal1<arg1_type, mt_policy>::emit(a1); }
+ void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
+};
+
+template<class arg1_type, class arg2_type,
+ class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater2 : public signal2<arg1_type, arg2_type, mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal2<arg1_type, arg2_type, mt_policy> base_type;
+ typedef repeater2<arg1_type, arg2_type, mt_policy> this_type;
+
+ repeater2() { }
+ repeater2(const this_type& s) : base_type(s) { }
+
+ void reemit(arg1_type a1, arg2_type a2) {
+ signal2<arg1_type, arg2_type, mt_policy>::emit(a1, a2);
+ }
+ void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
+};
+
+template<class arg1_type, class arg2_type, class arg3_type,
+ class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater3 : public signal3<arg1_type, arg2_type, arg3_type, mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal3<arg1_type, arg2_type, arg3_type, mt_policy> base_type;
+ typedef repeater3<arg1_type, arg2_type, arg3_type, mt_policy> this_type;
+
+ repeater3() { }
+ repeater3(const this_type& s) : base_type(s) { }
+
+ void reemit(arg1_type a1, arg2_type a2, arg3_type a3) {
+ signal3<arg1_type, arg2_type, arg3_type, mt_policy>::emit(a1, a2, a3);
+ }
+ void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
+};
} // namespace sigslot
diff --git a/chrome/browser/sync/notifier/gaia_auth/win32window.cc b/chrome/browser/sync/notifier/gaia_auth/win32window.cc
index f1eb8bf..25ea0a3 100644
--- a/chrome/browser/sync/notifier/gaia_auth/win32window.cc
+++ b/chrome/browser/sync/notifier/gaia_auth/win32window.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// Originally from libjingle. Minor alterations to compile it in Chrome.
#include "talk/base/common.h"
diff --git a/chrome/browser/sync/notifier/listener/listen_task.h b/chrome/browser/sync/notifier/listener/listen_task.h
index ab1da3e..bd29d29 100644
--- a/chrome/browser/sync/notifier/listener/listen_task.h
+++ b/chrome/browser/sync/notifier/listener/listen_task.h
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// This class listens for notifications from the talk service, and signals when
// they arrive. It checks all incoming stanza's to see if they look like
// notifications, and filters out those which are not valid.
diff --git a/chrome/browser/sync/notifier/listener/mediator_thread.h b/chrome/browser/sync/notifier/listener/mediator_thread.h
index 7626b41..1e6d89a 100644
--- a/chrome/browser/sync/notifier/listener/mediator_thread.h
+++ b/chrome/browser/sync/notifier/listener/mediator_thread.h
@@ -1,7 +1,6 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
//
// These methods should post messages to a queue which a different thread will
// later come back and read from.
diff --git a/chrome/browser/sync/notifier/listener/mediator_thread_impl.cc b/chrome/browser/sync/notifier/listener/mediator_thread_impl.cc
index 04a536d..473b7be 100644
--- a/chrome/browser/sync/notifier/listener/mediator_thread_impl.cc
+++ b/chrome/browser/sync/notifier/listener/mediator_thread_impl.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
#include "chrome/browser/sync/notifier/listener/mediator_thread_impl.h"
#include "base/logging.h"
@@ -40,17 +39,16 @@ void MediatorThreadImpl::Start() {
void MediatorThreadImpl::Run() {
NameCurrentThreadForDebugging("SyncEngine_MediatorThread");
- // For win32, this sets up the win32socketserver.
- // Note that it needs to dispatch windows messages
- // since that is what the win32 socket server uses.
+ // For win32, this sets up the win32socketserver. Note that it needs to
+ // dispatch windows messages since that is what the win32 socket server uses.
#ifdef WIN32
scoped_ptr<talk_base::SocketServer> socket_server(
- new talk_base::Win32SocketServer(this));
+ new talk_base::Win32SocketServer(this));
talk_base::SocketServer* old_socket_server = socketserver();
set_socketserver(socket_server.get());
- // Since we just changed the socket server,
- // ensure that any queued up messages are processed.
+ // Since we just changed the socket server, ensure that any queued up
+ // messages are processed.
socket_server->WakeUp();
::MSG message;
while (::GetMessage(&message, NULL, 0, 0)) {
@@ -135,14 +133,14 @@ void MediatorThreadImpl::DoLogin(LoginData* login_data) {
notifier::ServerInformation server_list[2];
int server_list_count = 2;
- // The default servers know how to serve over port 443 (that's the magic)
+ // The default servers know how to serve over port 443 (that's the magic).
server_list[0].server = talk_base::SocketAddress("talk.google.com",
notifier::kDefaultXmppPort,
- true); // Use DNS
+ true); // Use DNS.
server_list[0].special_port_magic = true;
server_list[1].server = talk_base::SocketAddress("talkx.l.google.com",
notifier::kDefaultXmppPort,
- true); // Use DNS
+ true); // Use DNS.
server_list[1].special_port_magic = true;
// Autodetect proxy is on by default.
@@ -194,8 +192,8 @@ void MediatorThreadImpl::OnOutputDebug(const char* msg, int length) {
void MediatorThreadImpl::DoDisconnect() {
LOG(INFO) << "P2P: Thread logging out of talk network.";
login_.reset();
- // Delete the old pump while on the thread to ensure that
- // everything is cleaned-up in a predicatable manner.
+ // Delete the old pump while on the thread to ensure that everything is
+ // cleaned-up in a predicatable manner.
pump_.reset();
}
@@ -247,8 +245,8 @@ void MediatorThreadImpl::OnClientStateChangeMessage(
case notifier::Login::STATE_RETRYING:
case notifier::Login::STATE_OPENING:
LOG(INFO) << "P2P: Thread trying to connect.";
- // Maybe first time logon, maybe intermediate network disruption
- // Assume the server went down, and lost our subscription for updates.
+ // Maybe first time logon, maybe intermediate network disruption. Assume
+ // the server went down, and lost our subscription for updates.
SignalStateChange(MSG_SUBSCRIPTION_FAILURE);
break;
case notifier::Login::STATE_OPENED:
diff --git a/chrome/browser/sync/notifier/listener/mediator_thread_impl.h b/chrome/browser/sync/notifier/listener/mediator_thread_impl.h
index 684952c..ecd7533 100644
--- a/chrome/browser/sync/notifier/listener/mediator_thread_impl.h
+++ b/chrome/browser/sync/notifier/listener/mediator_thread_impl.h
@@ -1,21 +1,21 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-// This object runs on a thread and knows how to interpret messages sent by
-// the talk mediator. The mediator posts messages to a queue which the thread
-// polls (in a super class).
+//
+// This object runs on a thread and knows how to interpret messages sent by the
+// talk mediator. The mediator posts messages to a queue which the thread polls
+// (in a super class).
//
// Example usage:
-// MediatorThread m = new MediatorThreadImpl(pass in stuff);
-// m.start(); // Start the thread
-// // Once the thread is started, you can do server stuff
-// m.Login(loginInformation);
-// // events happen, the mediator finds out through its pump
-// // more messages are dispatched to the thread
-// // eventually we want to log out
-// m.Logout();
-// delete m; // Also stops the thread
+//
+// MediatorThread m = new MediatorThreadImpl(pass in stuff);
+// m.start(); // Start the thread
+// // Once the thread is started, you can do server stuff.
+// m.Login(loginInformation);
+// // Events happen, the mediator finds out through its pump more messages
+// // are dispatched to the thread eventually we want to log out.
+// m.Logout();
+// delete m; // Also stops the thread.
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_
@@ -50,9 +50,8 @@ enum MEDIATOR_CMD {
CMD_SUBSCRIBE_FOR_UPDATES
};
-// Used to pass authentication information from the mediator to the thread
+// Used to pass authentication information from the mediator to the thread.
// Use new to allocate it on the heap, the thread will delete it for you.
-
struct LoginData : public talk_base::MessageData {
explicit LoginData(const buzz::XmppClientSettings& settings)
: user_settings(settings) {
@@ -71,7 +70,7 @@ class MediatorThreadImpl
MediatorThreadImpl();
virtual ~MediatorThreadImpl();
- // Start the thread
+ // Start the thread.
virtual void Start();
virtual void Run();
diff --git a/chrome/browser/sync/notifier/listener/send_update_task.cc b/chrome/browser/sync/notifier/listener/send_update_task.cc
index 79fffed..45c54fd 100644
--- a/chrome/browser/sync/notifier/listener/send_update_task.cc
+++ b/chrome/browser/sync/notifier/listener/send_update_task.cc
@@ -74,9 +74,8 @@ buzz::XmlElement* SendUpdateTask::NewUpdateMessage() {
// </Id>
// </set>
// </iq>
- buzz::XmlElement* stanza = MakeIq(buzz::STR_GET, GetClient()->jid().BareJid(),
- task_id());
-
+ buzz::XmlElement* stanza =
+ MakeIq(buzz::STR_GET, GetClient()->jid().BareJid(), task_id());
buzz::XmlElement* notifier_set = new buzz::XmlElement(kQnNotifierSet, true);
stanza->AddElement(notifier_set);
diff --git a/chrome/browser/sync/notifier/listener/send_update_task.h b/chrome/browser/sync/notifier/listener/send_update_task.h
index 056703e..de4a518 100644
--- a/chrome/browser/sync/notifier/listener/send_update_task.h
+++ b/chrome/browser/sync/notifier/listener/send_update_task.h
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// Methods for sending the update stanza to notify peers via xmpp.
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_SEND_UPDATE_TASK_H_
@@ -17,7 +17,7 @@ class SendUpdateTask : public buzz::XmppTask {
explicit SendUpdateTask(Task* parent);
virtual ~SendUpdateTask();
- // Overridden from buzz::XmppTask
+ // Overridden from buzz::XmppTask.
virtual int ProcessStart();
virtual int ProcessResponse();
virtual bool HandleStanza(const buzz::XmlElement* stanza);
diff --git a/chrome/browser/sync/notifier/listener/subscribe_task.cc b/chrome/browser/sync/notifier/listener/subscribe_task.cc
index 8d8a3ea..1a663041 100644
--- a/chrome/browser/sync/notifier/listener/subscribe_task.cc
+++ b/chrome/browser/sync/notifier/listener/subscribe_task.cc
@@ -61,8 +61,9 @@ int SubscribeTask::ProcessResponse() {
buzz::XmlElement* SubscribeTask::NewSubscriptionMessage() {
static const buzz::QName kQnNotifierGetAll(true, "google:notifier", "getAll");
- static const buzz::QName kQnNotifierClientActive(true, buzz::STR_EMPTY,
- "ClientActive");
+ static const buzz::QName kQnNotifierClientActive(true,
+ buzz::STR_EMPTY,
+ "ClientActive");
static const buzz::QName kQnBool(true, buzz::STR_EMPTY, "bool");
static const std::string kTrueString("true");
diff --git a/chrome/browser/sync/notifier/listener/subscribe_task.h b/chrome/browser/sync/notifier/listener/subscribe_task.h
index 4b96f38..793694e 100644
--- a/chrome/browser/sync/notifier/listener/subscribe_task.h
+++ b/chrome/browser/sync/notifier/listener/subscribe_task.h
@@ -1,10 +1,10 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-// This class handles subscribing to talk notifications. It does the getAll
-// iq stanza which establishes the endpoint and directs future notifications to
-// be pushed.
+//
+// This class handles subscribing to talk notifications. It does the getAll iq
+// stanza which establishes the endpoint and directs future notifications to be
+// pushed.
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_SUBSCRIBE_TASK_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_SUBSCRIBE_TASK_H_
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator.h b/chrome/browser/sync/notifier/listener/talk_mediator.h
index c651c10..18a87b6 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator.h
+++ b/chrome/browser/sync/notifier/listener/talk_mediator.h
@@ -1,18 +1,19 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// Interface to the code which handles talk logic. Used to initialize SSL
-// before the underlying talk login occurs
+// before the underlying talk login occurs.
+//
// Example usage:
//
-// TalkMediator mediator();
-// mediator.SetCredentials("email", "pass", false);
-// mediator.WatchAuthWatcher(auth_watcher_);
-// AuthWatcher eventually sends AUTH_SUCCEEDED which triggers:
-// mediator.Login();
-// ...
-// mediator.Logout();
+// TalkMediator mediator();
+// mediator.SetCredentials("email", "pass", false);
+// mediator.WatchAuthWatcher(auth_watcher_);
+// AuthWatcher eventually sends AUTH_SUCCEEDED which triggers:
+// mediator.Login();
+// ...
+// mediator.Logout();
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_TALK_MEDIATOR_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_LISTENER_TALK_MEDIATOR_H_
@@ -20,6 +21,7 @@
#include <string>
namespace browser_sync {
+
class AuthWatcher;
class SyncerThread;
@@ -34,7 +36,7 @@ struct TalkMediatorEvent {
TALKMEDIATOR_DESTROYED,
};
- // Required by EventChannel
+ // Required by EventChannel.
typedef TalkMediatorEvent EventType;
static inline bool IsChannelShutdownEvent(const TalkMediatorEvent& event) {
@@ -58,8 +60,8 @@ class TalkMediator {
virtual bool Login() = 0;
virtual bool Logout() = 0;
- // Method for the owner of this object to notify peers that an update
- // has occurred.
+ // Method for the owner of this object to notify peers that an update has
+ // occurred.
virtual bool SendNotification() = 0;
// Channel by which talk mediator events are signaled.
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc b/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
index 9d83d67..8cffc9f 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
@@ -109,7 +109,7 @@ void TalkMediatorImpl::AuthWatcherEventHandler(
}
break;
default:
- // Do nothing
+ // Do nothing.
break;
}
}
@@ -127,7 +127,7 @@ bool TalkMediatorImpl::Login() {
}
bool TalkMediatorImpl::DoLogin() {
- // Connect to the mediator thread and start it processing messages.
+ // Connect to the mediator thread and start processing messages.
if (!state_.connected) {
mediator_thread_->SignalStateChange.connect(
this,
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_impl.h b/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
index 33bb94a..33cff04 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// This class is the interface between talk code and the client code proper
// It will manage all aspects of the connection and call back into the client
// when it needs attention (for instance if updates are available for syncing).
@@ -21,6 +21,7 @@
class EventListenerHookup;
namespace browser_sync {
+
class AuthWatcher;
struct AuthWatcherEvent;
class SyncerThread;
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc b/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
index 6d26cdb..680e7e0 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
@@ -5,12 +5,11 @@
#include <string>
#include "base/logging.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
#include "chrome/browser/sync/notifier/listener/mediator_thread_mock.h"
#include "chrome/browser/sync/notifier/listener/talk_mediator_impl.h"
#include "chrome/browser/sync/util/event_sys-inl.h"
#include "talk/xmpp/xmppengine.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace browser_sync {
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc
index 59da679..3735fff 100644
--- a/chrome/browser/sync/syncable/directory_backing_store.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store.cc
@@ -30,16 +30,16 @@ using std::string;
namespace syncable {
-// This just has to be big enough to hold an UPDATE or
-// INSERT statement that modifies all the columns in the entry table.
+// This just has to be big enough to hold an UPDATE or INSERT statement that
+// modifies all the columns in the entry table.
static const string::size_type kUpdateStatementBufferSize = 2048;
// Increment this version whenever updating DB tables.
static const int32 kCurrentDBVersion = 67;
// TODO(sync): remove
-static void PathNameMatch16(sqlite3_context *context, int argc,
- sqlite3_value **argv) {
+static void PathNameMatch16(sqlite3_context* context, int argc,
+ sqlite3_value** argv) {
const PathString pathspec(reinterpret_cast<const PathChar*>
(sqlite3_value_text16(argv[0])), sqlite3_value_bytes16(argv[0]) / 2);
@@ -60,8 +60,8 @@ static void PathNameMatch16(sqlite3_context *context, int argc,
// Sqlite allows setting of the escape character in an ESCAPE clause and
// this character is passed in as a third character to the like function.
// See: http://www.sqlite.org/lang_expr.html
-static void PathNameMatch16WithEscape(sqlite3_context *context,
- int argc, sqlite3_value **argv) {
+static void PathNameMatch16WithEscape(sqlite3_context* context,
+ int argc, sqlite3_value** argv) {
// Never seen this called, but just in case.
LOG(FATAL) << "PathNameMatch16WithEscape() not implemented";
}
@@ -76,8 +76,8 @@ static void RegisterPathNameCollate(sqlite3* dbhandle) {
NULL, &ComparePathNames16));
}
-// Replace the LIKE operator with our own implementation that
-// does file spec matching like "*.txt".
+// Replace the LIKE operator with our own implementation that does file spec
+// matching like "*.txt".
static void RegisterPathNameMatch(sqlite3* dbhandle) {
// We only register this on Windows. We use the normal sqlite
// matching function on mac/linux.
@@ -106,6 +106,7 @@ static inline bool IsSqliteErrorOurFault(int result) {
}
namespace {
+
// This small helper class reduces the amount of code in the table upgrade code
// below and also CHECKs as soon as there's an issue.
class StatementExecutor {
diff --git a/chrome/browser/sync/syncable/directory_event.h b/chrome/browser/sync/syncable/directory_event.h
index 638ce6a..fd25c88 100644
--- a/chrome/browser/sync/syncable/directory_event.h
+++ b/chrome/browser/sync/syncable/directory_event.h
@@ -7,10 +7,10 @@
namespace syncable {
-// This kind of Event is emitted when the state of a Directory object
-// changes somehow, such as the directory being opened or closed.
-// Don't confuse it with a DirectoryChangeEvent, which is what happens
-// when one or more of the Entry contents of a Directory have been updated.
+// This kind of Event is emitted when the state of a Directory object changes
+// somehow, such as the directory being opened or closed. Don't confuse it with
+// a DirectoryChangeEvent, which is what happens when one or more of the Entry
+// contents of a Directory have been updated.
enum DirectoryEvent {
DIRECTORY_CLOSED,
DIRECTORY_DESTROYED,
diff --git a/chrome/browser/sync/syncable/directory_manager.cc b/chrome/browser/sync/syncable/directory_manager.cc
index ce02117..0c0c899 100644
--- a/chrome/browser/sync/syncable/directory_manager.cc
+++ b/chrome/browser/sync/syncable/directory_manager.cc
@@ -98,8 +98,8 @@ DirOpenResult DirectoryManager::OpenImpl(const PathString& name,
return result;
}
-// Marks a directory as closed. It might take a while until all the
-// file handles and resources are freed by other threads.
+// Marks a directory as closed. It might take a while until all the file
+// handles and resources are freed by other threads.
void DirectoryManager::Close(const PathString& name) {
// Erase from mounted and opened directory lists.
pthread_mutex_lock(&mutex_);
@@ -121,8 +121,8 @@ void DirectoryManager::Close(const PathString& name) {
managed_directory_ = NULL;
}
-// Marks all directories as closed. It might take a while until all the
-// file handles and resources are freed by other threads.
+// Marks all directories as closed. It might take a while until all the file
+// handles and resources are freed by other threads.
void DirectoryManager::CloseAllDirectories() {
if (managed_directory_)
Close(managed_directory_->name());
diff --git a/chrome/browser/sync/syncable/directory_manager.h b/chrome/browser/sync/syncable/directory_manager.h
index f937539..197b46b 100644
--- a/chrome/browser/sync/syncable/directory_manager.h
+++ b/chrome/browser/sync/syncable/directory_manager.h
@@ -117,7 +117,7 @@ class ScopedDirLookup {
Directory* dir_;
bool good_;
- // Ensure that the programmer checks good before using the ScopedDirLookup
+ // Ensure that the programmer checks good before using the ScopedDirLookup.
// This member should can be removed if it ever shows up in profiling
bool good_checked_;
DirectoryManager* const dirman_;
diff --git a/chrome/browser/sync/syncable/syncable-inl.h b/chrome/browser/sync/syncable/syncable-inl.h
index 81723bf..99b7723 100644
--- a/chrome/browser/sync/syncable/syncable-inl.h
+++ b/chrome/browser/sync/syncable/syncable-inl.h
@@ -25,6 +25,7 @@ struct IdRowTraits {
GetColumn(statement, 0, id);
}
};
+
} // namespace syncable
#endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_INL_H_
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index b997a5b..23a7a2f 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -253,7 +253,7 @@ Directory::~Directory() {
BOOL PathNameMatch(const PathString& pathname, const PathString& pathspec) {
#ifdef OS_WINDOWS
- // NB If we go Vista only this is easier:
+ // Note that if we go Vista only this is easier:
// http://msdn2.microsoft.com/en-us/library/ms628611.aspx
// PathMatchSpec strips spaces from the start of pathspec, so we compare those
@@ -264,8 +264,8 @@ BOOL PathNameMatch(const PathString& pathname, const PathString& pathspec) {
while (*pathname_ptr == ' ' && *pathspec_ptr == ' ')
++pathname_ptr, ++pathspec_ptr;
- // if we have more inital spaces in the pathspec than in the pathname then the
- // result from PathMatchSpec will be erronous
+ // If we have more inital spaces in the pathspec than in the pathname then the
+ // result from PathMatchSpec will be erronous.
if (*pathspec_ptr == ' ')
return FALSE;
@@ -281,7 +281,7 @@ BOOL PathNameMatch(const PathString& pathname, const PathString& pathspec) {
return ::PathMatchSpec(pathname_ptr, pathspec_ptr);
}
- // We need to subst ';' with ':' in both, name and spec
+ // We need to subst ';' with ':' in both, name and spec.
PathString name_subst(pathname_ptr);
PathString spec_subst(pathspec_ptr);
@@ -436,8 +436,8 @@ EntryKernel* Directory::GetChildWithName(const Id& parent_id,
return GetChildWithNameImpl(parent_id, dbname, lock);
}
-// Will return child entry even when the folder is not
-// opened. This is used by syncer to apply update when folder is closed.
+// Will return child entry even when the folder is not opened. This is used by
+// syncer to apply update when folder is closed.
EntryKernel* Directory::GetChildWithDBName(const Id& parent_id,
const PathString& name) {
ScopedKernelLock lock(this);
@@ -1418,7 +1418,7 @@ MutableEntry::MutableEntry(WriteTransaction* trans, Create,
void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
- const PathString& name) {
+ const PathString& name) {
kernel_ = new EntryKernel;
ZeroFields(kernel_, BEGIN_FIELDS);
kernel_->ref(ID) = trans->directory_->NextId();
@@ -1597,8 +1597,8 @@ bool MutableEntry::Put(IndexedBitField field, bool value) {
return true;
}
-// Avoids temporary collision in index when renaming a bookmark
-// to another folder.
+// Avoids temporary collision in index when renaming a bookmark to another
+// folder.
bool MutableEntry::PutParentIdAndName(const Id& parent_id,
const Name& name) {
DCHECK(kernel_);
@@ -1624,9 +1624,9 @@ void MutableEntry::UnlinkFromOrder() {
Id old_previous = Get(PREV_ID);
Id old_next = Get(NEXT_ID);
- // Self-looping signifies that this item is not in the order. If
- // we were to set these to 0, we could get into trouble because
- // this node might look like the first node in the ordering.
+ // Self-looping signifies that this item is not in the order. If we were to
+ // set these to 0, we could get into trouble because this node might look
+ // like the first node in the ordering.
Put(NEXT_ID, Get(ID));
Put(PREV_ID, Get(ID));
@@ -1749,9 +1749,9 @@ ExtendedAttribute::ExtendedAttribute(BaseTransaction* trans, GetByHandle,
}
bool ExtendedAttribute::Init(BaseTransaction* trans,
- Directory::Kernel* const kernel,
- ScopedKernelLock* lock,
- const ExtendedAttributeKey& key) {
+ Directory::Kernel* const kernel,
+ ScopedKernelLock* lock,
+ const ExtendedAttributeKey& key) {
i_ = kernel->extended_attributes->find(key);
good_ = kernel->extended_attributes->end() != i_;
return good_;
@@ -1840,7 +1840,7 @@ static PathString FixBasenameInCollision(const PathString s) {
void DBName::MakeNoncollidingForEntry(BaseTransaction* trans,
const Id& parent_id,
- Entry *e) {
+ Entry* e) {
const PathString& desired_name = *this;
CHECK(!desired_name.empty());
PathString::size_type first_dot = desired_name.find_first_of(PSTR('.'));
@@ -1850,13 +1850,13 @@ void DBName::MakeNoncollidingForEntry(BaseTransaction* trans,
PathString dotextension = desired_name.substr(first_dot);
CHECK(basename + dotextension == desired_name);
for (;;) {
- // check for collision
+ // Check for collision.
PathString testname = basename + dotextension;
Entry same_path_entry(trans, GET_BY_PARENTID_AND_DBNAME,
parent_id, testname);
if (!same_path_entry.good() || (e && same_path_entry.Get(ID) == e->Get(ID)))
break;
- // there was a collision, so fix the name
+ // There was a collision, so fix the name.
basename = FixBasenameInCollision(basename);
}
// Set our value to the new value. This invalidates desired_name.
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index d2e8353..8a7a123 100644
--- a/chrome/browser/sync/syncable/syncable.h
+++ b/chrome/browser/sync/syncable/syncable.h
@@ -248,16 +248,16 @@ enum CreateNewUpdateItem {
typedef std::set<PathString> AttributeKeySet;
// DBName is a PathString with additional transformation methods that are
-// useful when trying to derive a unique and legal database name from
-// an unsanitized sync name.
+// useful when trying to derive a unique and legal database name from an
+// unsanitized sync name.
class DBName : public PathString {
public:
explicit DBName(const PathString& database_name)
: PathString(database_name) { }
- // TODO(ncarter): Remove these codepaths to maintain alternate titles
- // which are OS legal filenames, Chrome doesn't depend on this like some
- // other browsers do.
+ // TODO(ncarter): Remove these codepaths to maintain alternate titles which
+ // are OS legal filenames, Chrome doesn't depend on this like some other
+ // browsers do.
void MakeOSLegal() {
PathString new_value = MakePathComponentOSLegal(*this);
if (!new_value.empty())
@@ -269,7 +269,7 @@ class DBName : public PathString {
// to compute a name for an entry which has yet to be created.
void MakeNoncollidingForEntry(BaseTransaction* trans,
const Id& parent_id,
- Entry *e);
+ Entry* e);
};
// SyncName encapsulates a canonical server name. In general, when we need to
@@ -325,8 +325,8 @@ class SyncName {
value_.append(PSTR(" "));
non_unique_value_ = value_;
}
- // TODO(ncarter): Handle server's other requirement: truncation to
- // 256 bytes in Unicode NFC.
+ // TODO(ncarter): Handle server's other requirement: truncation to 256
+ // bytes in Unicode NFC.
}
const PathString& value() const { return value_; }
@@ -522,7 +522,7 @@ class Entry {
public:
// After constructing, you must check good() to test whether the Get
- // succeed.
+ // succeeded.
Entry(BaseTransaction* trans, GetByHandle, int64 handle);
Entry(BaseTransaction* trans, GetById, const Id& id);
Entry(BaseTransaction* trans, GetByTag, const PathString& tag);
@@ -590,8 +590,8 @@ class Entry {
}
inline PathString GetSyncNameValue() const {
DCHECK(kernel_);
- // This should always be equal to GetName().sync_name().value(), but
- // maybe faster.
+ // This should always be equal to GetName().sync_name().value(), but may be
+ // faster.
return kernel_->ref(UNSANITIZED_NAME).empty() ? kernel_->ref(NAME) :
kernel_->ref(UNSANITIZED_NAME);
}
@@ -681,8 +681,8 @@ class MutableEntry : public Entry {
}
bool Put(IndexedBitField field, bool value);
- // Avoids temporary collision in index when renaming a bookmark
- // into another folder.
+ // Avoids temporary collision in index when renaming a bookmark into another
+ // folder.
bool PutParentIdAndName(const Id& parent_id, const Name& name);
// Sets the position of this item, and updates the entry kernels of the
@@ -722,7 +722,6 @@ class MutableEntry : public Entry {
bool PutImpl(StringField field, const PathString& value);
-
// Adjusts the successor and predecessor entries so that they no longer
// refer to this entry.
void UnlinkFromOrder();
@@ -772,7 +771,7 @@ struct DirectoryChangeEvent {
// Channel is closing.
SHUTDOWN
} todo;
- // These members are only valid for CALCULATE_CHANGES
+ // These members are only valid for CALCULATE_CHANGES.
const OriginalEntries* originals;
BaseTransaction* trans;
WriterTag writer;
@@ -817,8 +816,8 @@ struct ThreadNode {
ThreadNode* next;
ThreadNode* prev;
- // True when this node is in a linked list. Only accessed from
- // owner thread so no locking necessary.
+ // True when this node is in a linked list. Only accessed from owner thread
+ // so no locking necessary.
bool in_list;
WriteTransaction* current_write_trans;
PThreadCondVar condvar; // Mutex is the kernel's transaction mutex.
@@ -1029,9 +1028,9 @@ class Directory {
// Returns the child meta handles for given parent id.
void GetChildHandles(BaseTransaction*, const Id& parent_id,
- const PathString& path_spec, ChildHandles* result);
+ const PathString& path_spec, ChildHandles* result);
void GetChildHandles(BaseTransaction*, const Id& parent_id,
- ChildHandles* result);
+ ChildHandles* result);
void GetChildHandlesImpl(BaseTransaction* trans, const Id& parent_id,
PathMatcher* matcher, ChildHandles* result);
@@ -1071,7 +1070,7 @@ class Directory {
void GetExtendedAttributesList(BaseTransaction* trans, int64 metahandle,
AttributeKeySet* result);
// Flags all extended attributes for deletion on the next SaveChanges.
- void DeleteAllExtendedAttributes(WriteTransaction*trans, int64 metahandle);
+ void DeleteAllExtendedAttributes(WriteTransaction* trans, int64 metahandle);
// Get the channel for post save notification, used by the syncer.
inline Channel* channel() const {
@@ -1177,7 +1176,7 @@ class Directory {
// other buffered IO. Violating this rule will result in deadlock.
pthread_mutex_t mutex;
MetahandlesIndex* metahandles_index; // Entries indexed by metahandle
- IdsIndex* ids_index; // Entries indexed by id
+ IdsIndex* ids_index; // Entries indexed by id
ParentIdAndNamesIndex* parent_id_and_names_index;
// So we don't have to create an EntryKernel every time we want to
// look something up in an index. Needle in haystack metaphore.
@@ -1255,8 +1254,8 @@ class BaseTransaction {
enum TransactionClass { READ, WRITE };
protected:
- explicit BaseTransaction(Directory* directory, const char* name,
- const char* source_file, int line);
+ BaseTransaction(Directory* directory, const char* name,
+ const char* source_file, int line);
// The members below are optionally called by descendants.
void Lock(ThreadCounts* const thread_counts, ThreadNode* thread_node,
@@ -1265,10 +1264,9 @@ class BaseTransaction {
void UnlockAndLog(ThreadCounts* const thread_counts, OriginalEntries*);
void Init(ThreadCounts* const thread_counts, TransactionClass tclass);
ThreadNode* MakeThreadNode();
- public:
+ public:
inline Directory* directory() const { return directory_; }
-
inline Id root_id() const { return Id(); }
protected:
@@ -1413,7 +1411,6 @@ std::ostream& operator <<(std::ostream&, const syncable::Blob&);
browser_sync::FastDump& operator <<
(browser_sync::FastDump&, const syncable::Blob&);
-
std::ostream& operator <<(std::ostream&, const syncable::ThreadNode&);
#endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
diff --git a/chrome/browser/sync/syncable/syncable_id.cc b/chrome/browser/sync/syncable/syncable_id.cc
index 04d5afc..3c53ad1 100644
--- a/chrome/browser/sync/syncable/syncable_id.cc
+++ b/chrome/browser/sync/syncable/syncable_id.cc
@@ -69,4 +69,5 @@ Id Id::CreateFromClientString(const string& local_id) {
id.s_ = string("c") + local_id;
return id;
}
+
} // namespace syncable
diff --git a/chrome/browser/sync/syncable/syncable_id.h b/chrome/browser/sync/syncable/syncable_id.h
index 5f2a28e..a5f9aea 100644
--- a/chrome/browser/sync/syncable/syncable_id.h
+++ b/chrome/browser/sync/syncable/syncable_id.h
@@ -34,9 +34,9 @@ browser_sync::FastDump& operator <<
namespace syncable {
// For historical reasons, 3 concepts got everloaded into the Id:
-// 1. A unique, opaque identifier for the object.
-// 2. Flag specifing whether server know about this object.
-// 3. Flag for root.
+// 1. A unique, opaque identifier for the object.
+// 2. Flag specifing whether server know about this object.
+// 3. Flag for root.
//
// We originally wrapped an integer for this information, but now we use a
// string. It will have one of three forms:
@@ -53,8 +53,8 @@ class Id {
friend class MockConnectionManager;
friend class SyncableIdTest;
public:
- // This constructor will be handy even when we move away from
- // int64s, just for unit tests.
+ // This constructor will be handy even when we move away from int64s, just
+ // for unit tests.
inline Id() : s_("r") { }
inline Id(const Id& that) {
Copy(that);
diff --git a/chrome/browser/sync/syncable/syncable_unittest.cc b/chrome/browser/sync/syncable/syncable_unittest.cc
index 63bc153..592c103 100644
--- a/chrome/browser/sync/syncable/syncable_unittest.cc
+++ b/chrome/browser/sync/syncable/syncable_unittest.cc
@@ -51,9 +51,9 @@ using std::string;
namespace syncable {
-// A lot of these tests were written expecting to be able to read and
-// write object data on entries. However, the design has changed.
-void PutDataAsExtendedAttribute(WriteTransaction *wtrans,
+// A lot of these tests were written expecting to be able to read and write
+// object data on entries. However, the design has changed.
+void PutDataAsExtendedAttribute(WriteTransaction* wtrans,
MutableEntry* e,
const char* bytes,
size_t bytes_length) {
@@ -63,7 +63,7 @@ void PutDataAsExtendedAttribute(WriteTransaction *wtrans,
attr.mutable_value()->swap(bytes_blob);
}
-void ExpectDataFromExtendedAttributeEquals(BaseTransaction *trans,
+void ExpectDataFromExtendedAttributeEquals(BaseTransaction* trans,
Entry* e,
const char* bytes,
size_t bytes_length) {
@@ -193,7 +193,7 @@ class SyncableDirectoryTest : public testing::Test {
protected:
static const PathString kFilePath;
static const PathString kName;
- static const PathChar *kSqlite3File;
+ static const PathChar* kSqlite3File;
static const Id kId;
// SetUp() is called before each test case is run.
@@ -232,9 +232,9 @@ class SyncableDirectoryTest : public testing::Test {
me.Put(IS_UNSYNCED, true);
}
- void ValidateEntry(BaseTransaction *trans, int64 id, bool check_name,
+ void ValidateEntry(BaseTransaction* trans, int64 id, bool check_name,
PathString name, int64 base_version, int64 server_version, bool is_del);
- void CreateAndCheck(WriteTransaction *trans, int64 parent_id, int64 id,
+ void CreateAndCheck(WriteTransaction* trans, int64 parent_id, int64 id,
PathString name, PathString server_name, int64 version,
bool set_server_fields, bool is_dir, bool add_to_lru, int64 *meta_handle);
};
@@ -762,7 +762,7 @@ TEST_F(SyncableDirectoryTest, TestSaveChangesFailure) {
}
-void SyncableDirectoryTest::ValidateEntry(BaseTransaction *trans, int64 id,
+void SyncableDirectoryTest::ValidateEntry(BaseTransaction* trans, int64 id,
bool check_name, PathString name, int64 base_version, int64 server_version,
bool is_del) {
Entry e(trans, GET_BY_ID, TestIdFactory::FromNumber(id));
@@ -1058,17 +1058,17 @@ TEST(SyncableDirectory, StressTransactions) {
PathRemove(dirman.GetSyncDataDatabasePath());
}
-static PathString UTF8ToPathStringQuick(const char *str) {
+static PathString UTF8ToPathStringQuick(const char* str) {
PathString ret;
CHECK(browser_sync::UTF8ToPathString(str, strlen(str), &ret));
return ret;
}
-// returns number of chars used. max possible is 4
+// Returns number of chars used. Max possible is 4.
// This algorithm was coded from the table at
// http://en.wikipedia.org/w/index.php?title=UTF-8&oldid=153391259
-// there are no endian issues.
-static int UTF32ToUTF8(uint32 incode, unsigned char *out) {
+// There are no endian issues.
+static int UTF32ToUTF8(uint32 incode, unsigned char* out) {
if (incode <= 0x7f) {
out[0] = incode;
return 1;
@@ -1492,7 +1492,7 @@ TEST(Syncable, PathNameMatch) {
EXPECT_TRUE(PathNameMatch(PSTR(" bob"), PSTR(" bob")));
EXPECT_FALSE(PathNameMatch(PSTR("bob"), PSTR(" bob")));
EXPECT_FALSE(PathNameMatch(PSTR(" bob"), PSTR("bob")));
- // Combo test
+ // Combo test.
EXPECT_TRUE(PathNameMatch(PSTR(" b;ob"), PSTR(" b;o*")));
EXPECT_TRUE(PathNameMatch(PSTR(" b;ob"), PSTR(" b;ob")));
EXPECT_FALSE(PathNameMatch(PSTR("b;ob"), PSTR(" b;ob")));
diff --git a/chrome/browser/sync/util/character_set_converters-win32.cc b/chrome/browser/sync/util/character_set_converters-win32.cc
index 79e9281..ce1b882 100644
--- a/chrome/browser/sync/util/character_set_converters-win32.cc
+++ b/chrome/browser/sync/util/character_set_converters-win32.cc
@@ -12,7 +12,7 @@ using std::string;
namespace browser_sync {
-// Converts input_string to UTF8 and appends the result into to output_string
+// Converts input_string to UTF8 and appends the result into to output_string.
void AppendPathStringToUTF8(const PathChar* wide, int size,
string* output_string) {
CHECK(output_string);
diff --git a/chrome/browser/sync/util/compat-file.h b/chrome/browser/sync/util/compat-file.h
index 273e3cb..5b9adf0 100644
--- a/chrome/browser/sync/util/compat-file.h
+++ b/chrome/browser/sync/util/compat-file.h
@@ -3,7 +3,7 @@
// found in the LICENSE file.
//
// File compatability routines. Useful to delete database files with.
-//
+
#ifndef CHROME_BROWSER_SYNC_UTIL_COMPAT_FILE_H_
#define CHROME_BROWSER_SYNC_UTIL_COMPAT_FILE_H_
diff --git a/chrome/browser/sync/util/compat-pthread.h b/chrome/browser/sync/util/compat-pthread.h
index e5817af..ee08691 100644
--- a/chrome/browser/sync/util/compat-pthread.h
+++ b/chrome/browser/sync/util/compat-pthread.h
@@ -20,7 +20,7 @@ inline ThreadId GetCurrentThreadId() {
#if (!defined(OS_WINDOWS) && !defined(OS_MACOSX))
// TODO(timsteele): What the heck is this?
-inline int sem_post_multiple(sem_t * sem, int number) {
+inline int sem_post_multiple(sem_t* sem, int number) {
int i;
int r = 0;
for (i = 0; i < number; i++) {
diff --git a/chrome/browser/sync/util/crypto_helpers.cc b/chrome/browser/sync/util/crypto_helpers.cc
index c84bfaf..f65301b 100644
--- a/chrome/browser/sync/util/crypto_helpers.cc
+++ b/chrome/browser/sync/util/crypto_helpers.cc
@@ -56,7 +56,5 @@ void GetRandomBytes(char* output, int output_length) {
string Generate128BitRandomHexString() {
int64 chunk1 = static_cast<int64>(base::RandUint64());
int64 chunk2 = static_cast<int64>(base::RandUint64());
-
- return StringPrintf("%016" PRId64 "x%016" PRId64 "x",
- chunk1, chunk2);
+ return StringPrintf("%016" PRId64 "x%016" PRId64 "x", chunk1, chunk2);
}
diff --git a/chrome/browser/sync/util/event_sys-inl.h b/chrome/browser/sync/util/event_sys-inl.h
index c361528..062357d 100644
--- a/chrome/browser/sync/util/event_sys-inl.h
+++ b/chrome/browser/sync/util/event_sys-inl.h
@@ -250,7 +250,7 @@ public EventListener<typename EventTraits::EventType> {
deleted_ = &deleted;
static_cast<Derived*>(this)->Callback(event);
if (deleted) // The callback (legally) deleted this.
- return; // The only safe thing to do.
+ return; // The only safe thing to do.
deleted_ = NULL;
if (EventTraits::IsChannelShutdownEvent(event)) {
channel_->RemoveListener(this);
diff --git a/chrome/browser/sync/util/event_sys_unittest.cc b/chrome/browser/sync/util/event_sys_unittest.cc
index 5e521b1..fa8d2ae 100644
--- a/chrome/browser/sync/util/event_sys_unittest.cc
+++ b/chrome/browser/sync/util/event_sys_unittest.cc
@@ -159,15 +159,15 @@ class ThreadTester : public EventListener<TestEvent> {
struct ThreadInfo {
pthread_t thread;
- bool *completed;
+ bool* completed;
};
struct ThreadArgs {
ThreadTester* self;
- pthread_cond_t *thread_running_cond;
- pthread_mutex_t *thread_running_mutex;
- bool *thread_running;
- bool *completed;
+ pthread_cond_t* thread_running_cond;
+ pthread_mutex_t* thread_running_mutex;
+ bool* thread_running;
+ bool* completed;
};
pthread_t Go() {
diff --git a/chrome/browser/sync/util/highres_timer-linux.cc b/chrome/browser/sync/util/highres_timer-linux.cc
index 8fed343..77350f9 100644
--- a/chrome/browser/sync/util/highres_timer-linux.cc
+++ b/chrome/browser/sync/util/highres_timer-linux.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// High resolution timer functions for use in Linux.
#include "chrome/browser/sync/util/highres_timer.h"
@@ -25,5 +25,5 @@ uint64 HighresTimer::GetElapsedSec() const {
// Scale to ms and round to nearest ms - rounding is important because
// otherwise the truncation error may accumulate e.g. in sums.
return (uint64(end_time - start_ticks_) + MICROS_IN_HALF_SECOND) /
- MICROS_IN_SECOND;
+ MICROS_IN_SECOND;
}
diff --git a/chrome/browser/sync/util/highres_timer_unittest.cc b/chrome/browser/sync/util/highres_timer_unittest.cc
index 5723e7f8..838f56e 100644
--- a/chrome/browser/sync/util/highres_timer_unittest.cc
+++ b/chrome/browser/sync/util/highres_timer_unittest.cc
@@ -14,12 +14,12 @@
TEST(HighresTimer, DISABLED_MillisecondClock) {
HighresTimer timer;
- // note: this could fail if we context switch between initializing the timer
+ // Note: this could fail if we context switch between initializing the timer
// and here. Very unlikely however.
EXPECT_EQ(0, timer.GetElapsedMs());
timer.Start();
uint64 half_ms = HighresTimer::GetTimerFrequency() / 2000;
- // busy wait for half a millisecond
+ // Busy wait for half a millisecond.
while (timer.start_ticks() + half_ms > HighresTimer::GetCurrentTicks()) {
// Nothing
}
diff --git a/chrome/browser/sync/util/path_helpers-linux.cc b/chrome/browser/sync/util/path_helpers-linux.cc
index 4f4543d..2448f09 100644
--- a/chrome/browser/sync/util/path_helpers-linux.cc
+++ b/chrome/browser/sync/util/path_helpers-linux.cc
@@ -26,13 +26,13 @@ string LastPathSegment(const string& path) {
}
if (string::npos == final_slash)
return str;
- str.erase(0, final_slash+1);
+ str.erase(0, final_slash + 1);
return str;
}
PathString GetFullPath(const PathString& path) {
// TODO(sync): Not sure what the base of the relative path should be on
- // linux.
+ // linux.
return path;
}
@@ -44,7 +44,7 @@ PathString AppendSlash(const PathString& path) {
}
PathString LowercasePath(const PathString& path) {
- gchar *ret = g_utf8_strdown(path.c_str(), -1);
+ gchar* ret = g_utf8_strdown(path.c_str(), -1);
PathString retstr(ret);
g_free(ret);
return retstr;
diff --git a/chrome/browser/sync/util/path_helpers-posix.cc b/chrome/browser/sync/util/path_helpers-posix.cc
index c03c017..e8f7fd3 100644
--- a/chrome/browser/sync/util/path_helpers-posix.cc
+++ b/chrome/browser/sync/util/path_helpers-posix.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include <pwd.h>
-
#include <string.h>
#include "chrome/browser/sync/util/path_helpers.h"
@@ -39,8 +38,8 @@ string get_cache_dir() {
return cache_dir_;
}
-// On Posix, PathStrings are UTF-8, not UTF-16 as they are on Windows.
-// Thus, this function is different from the Windows version.
+// On Posix, PathStrings are UTF-8, not UTF-16 as they are on Windows. Thus,
+// this function is different from the Windows version.
PathString TruncatePathString(const PathString& original, int length) {
if (original.size() <= length)
return original;
@@ -57,11 +56,11 @@ PathString TruncatePathString(const PathString& original, int length) {
for (; last_char != ret.rend(); ++last_char) {
if (0 == (*last_char & 0x80)) {
- // got malformed UTF-8; bail
+ // Got malformed UTF-8; bail.
return ret;
}
if (0 == (*last_char & 0x40)) {
- // got another trailing byte
+ // Got another trailing byte.
continue;
}
break;
@@ -86,7 +85,7 @@ PathString TruncatePathString(const PathString& original, int length) {
return ret;
}
-// Convert /s to :s .
+// Convert /s to :s.
PathString MakePathComponentOSLegal(const PathString& component) {
if (PathString::npos == component.find("/"))
return PSTR("");
diff --git a/chrome/browser/sync/util/path_helpers.cc b/chrome/browser/sync/util/path_helpers.cc
index cafcfca..e0a20ef 100644
--- a/chrome/browser/sync/util/path_helpers.cc
+++ b/chrome/browser/sync/util/path_helpers.cc
@@ -68,8 +68,8 @@ PathString ExpandTilde(const PathString& path) {
return path;
}
-// Returns a string with length or fewer elements, careful to
-// not truncate a string mid-surrogate pair.
+// Returns a string with length or fewer elements, careful to not truncate a
+// string mid-surrogate pair.
PathString TruncatePathString(const PathString& original, int length) {
if (original.size() <= static_cast<size_t>(length))
return original;
@@ -122,13 +122,13 @@ PathString MakePathComponentOSLegal(const PathString& component) {
mutable_component.resize(mutable_component.size() - 1, L' ');
// Remove a bunch of forbidden names. windows only seems to mind if
- // a forbidden name matches our name exactly (e.g. "prn") or if the
- // name is the forbidden name, followed by a dot, followed by anything
+ // a forbidden name matches our name exactly (e.g. "prn") or if the name is
+ // the forbidden name, followed by a dot, followed by anything
// (e.g., "prn.anything.foo.bar")
- // From this point out, we break mutable_component into two strings, and
- // use them this way: we save anything after and including the first dot
- // (usually the extension) and only mess with stuff before the first dot.
+ // From this point out, we break mutable_component into two strings, and use
+ // them this way: we save anything after and including the first dot (usually
+ // the extension) and only mess with stuff before the first dot.
PathString::size_type first_dot = mutable_component.find_first_of(L'.');
if (PathString::npos == first_dot)
first_dot = mutable_component.size();
diff --git a/chrome/browser/sync/util/path_helpers.h b/chrome/browser/sync/util/path_helpers.h
index d8b4663..c6f55b7 100644
--- a/chrome/browser/sync/util/path_helpers.h
+++ b/chrome/browser/sync/util/path_helpers.h
@@ -89,8 +89,8 @@ inline PathString StripSuffixPathString(const PathString& str,
return ret;
}
-// Returns a string with length or fewer elements, careful to
-// not truncate a string mid-surrogate pair.
+// Returns a string with length or fewer elements, careful to not truncate a
+// string mid-surrogate pair.
PathString TruncatePathString(const PathString& original, int length);
// Makes a path component legal for your OS, but doesn't handle collisions
diff --git a/chrome/browser/sync/util/pthread_helpers.cc b/chrome/browser/sync/util/pthread_helpers.cc
index 663fc66..e0acd3e 100644
--- a/chrome/browser/sync/util/pthread_helpers.cc
+++ b/chrome/browser/sync/util/pthread_helpers.cc
@@ -60,7 +60,7 @@ void* ThreadMainProc(void* parameter) {
} // namespace
-#endif
+#endif // OS_WINDOWS
thread_handle CreatePThread(void *(*start) (void *), void* parameter) {
#ifdef OS_WINDOWS
@@ -75,7 +75,7 @@ thread_handle CreatePThread(void *(*start) (void *), void* parameter) {
if (0 != pthread_create(&pthread, NULL, ThreadMainProc, param.get()))
return NULL;
- // ownership has passed to the new thread
+ // Ownership has passed to the new thread.
param.release();
const HANDLE thread_handle = pthread_getw32threadhandle_np(pthread);
@@ -98,7 +98,7 @@ thread_handle CreatePThread(void *(*start) (void *), void* parameter) {
} else {
return 0;
}
-#endif
+#endif // OS_WINDOWS
}
struct timespec GetPThreadAbsoluteTime(uint32 ms) {
@@ -130,7 +130,7 @@ struct timespec GetPThreadAbsoluteTime(uint32 ms) {
deadline.tv_sec += ms / 1000;
deadline.tv_nsec = (ms % 1000) * 1000000;
return deadline;
-#endif
+#endif // OS_WINDOWS
}
void NameCurrentThreadForDebugging(char* name) {
diff --git a/chrome/browser/sync/util/query_helpers.cc b/chrome/browser/sync/util/query_helpers.cc
index e640a6c..59adcb9 100644
--- a/chrome/browser/sync/util/query_helpers.cc
+++ b/chrome/browser/sync/util/query_helpers.cc
@@ -76,7 +76,7 @@ int SqliteOpen(PathString filename, sqlite3** db) {
attrs = attrs | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
SetFileAttributes(filename.c_str(), attrs);
}
-#endif
+#endif // OS_WINDOWS
// Be patient as we set pragmas.
sqlite3_busy_timeout(*db, numeric_limits<int>::max());
#ifndef DISABLE_SQLITE_FULL_FSYNC
@@ -106,7 +106,7 @@ sqlite3_stmt* BindArg(sqlite3_stmt* statement, const PathChar* s, int index) {
SQLITE_TRANSIENT));
return statement;
}
-#endif
+#endif // !PATHSTRING_IS_STD_STRING
sqlite3_stmt* BindArg(sqlite3_stmt* statement, const string& s, int index) {
if (NULL == statement)
@@ -179,7 +179,6 @@ sqlite3_stmt* BindArg(sqlite3_stmt* statement, SqliteNullType, int index) {
return statement;
}
-
#if !PATHSTRING_IS_STD_STRING
void GetColumn(sqlite3_stmt* statement, int index, PathString* value) {
if (sqlite3_column_type(statement, index) == SQLITE_NULL) {
@@ -190,7 +189,7 @@ void GetColumn(sqlite3_stmt* statement, int index, PathString* value) {
sqlite3_column_bytes16(statement, index) / sizeof(PathChar));
}
}
-#endif
+#endif // !PATHSTRING_IS_STD_STRING
void GetColumn(sqlite3_stmt* statement, int index, string* value) {
if (sqlite3_column_type(statement, index) == SQLITE_NULL) {
@@ -229,7 +228,7 @@ void GetColumn(sqlite3_stmt* statement, int index, std::vector<uint8>* value) {
}
}
-bool DoesTableExist(sqlite3 *dbhandle, const string &table_name) {
+bool DoesTableExist(sqlite3* dbhandle, const string& table_name) {
ScopedStatement count_query
(PrepareQuery(dbhandle,
"SELECT count(*) from sqlite_master where name = ?",
diff --git a/chrome/browser/sync/util/user_settings-posix.cc b/chrome/browser/sync/util/user_settings-posix.cc
index 091e7e3..736d2d1 100644
--- a/chrome/browser/sync/util/user_settings-posix.cc
+++ b/chrome/browser/sync/util/user_settings-posix.cc
@@ -1,8 +1,8 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE entry.
-
-// Implement the storage of service tokens in memory
+//
+// Implement the storage of service tokens in memory.
#include "chrome/browser/sync/util/user_settings.h"
diff --git a/chrome/browser/sync/util/user_settings-win32.cc b/chrome/browser/sync/util/user_settings-win32.cc
index dac7f21..9895651 100644
--- a/chrome/browser/sync/util/user_settings-win32.cc
+++ b/chrome/browser/sync/util/user_settings-win32.cc
@@ -17,7 +17,7 @@ namespace browser_sync {
bool UserSettings::GetLastUser(string* username) {
ScopedDBHandle dbhandle(this);
ScopedStatement query(PrepareQuery(dbhandle.get(),
- "SELECT email FROM cookies"));
+ "SELECT email FROM cookies"));
if (SQLITE_ROW == sqlite3_step(query.get())) {
GetColumn(query.get(), 0, username);
return true;
@@ -64,4 +64,3 @@ bool UserSettings::GetLastUserAndServiceToken(const string& service_name,
}
} // namespace browser_sync
-
diff --git a/chrome/browser/sync/util/user_settings.cc b/chrome/browser/sync/util/user_settings.cc
index 573365a..8408b92 100644
--- a/chrome/browser/sync/util/user_settings.cc
+++ b/chrome/browser/sync/util/user_settings.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE entry.
-
+//
// This class isn't pretty. It's just a step better than globals, which is what
// these were previously.
@@ -11,8 +11,8 @@
#include <windows.h>
#endif
-#include <string>
#include <limits>
+#include <string>
#include <vector>
#include "base/file_util.h"
@@ -51,9 +51,9 @@ string UserSettings::email() const {
}
static void MakeSigninsTable(sqlite3* const dbhandle) {
- // Multiple email addresses can map to the same Google Account.
- // This table keeps a map of sign-in email addresses to primary
- // Google Account email addresses.
+ // Multiple email addresses can map to the same Google Account. This table
+ // keeps a map of sign-in email addresses to primary Google Account email
+ // addresses.
ExecOrDie(dbhandle, "CREATE TABLE signins"
" (signin, primary_email, "
" PRIMARY KEY(signin, primary_email) ON CONFLICT REPLACE)");
@@ -73,9 +73,9 @@ void UserSettings::MigrateOldVersionsAsNeeded(sqlite3* const handle,
return;
case 10:
{
- // Scrape the 'shares' table to find the syncable DB. 'shares'
- // had a pair of string columns that mapped the username to the filename
- // of the sync data sqlite3 file. Version 11 switched to a constant
+ // Scrape the 'shares' table to find the syncable DB. 'shares' had a
+ // pair of string columns that mapped the username to the filename of
+ // the sync data sqlite3 file. Version 11 switched to a constant
// filename, so here we read the string, copy the file to the new name,
// delete the old one, and then drop the unused shares table.
ScopedStatement share_query(PrepareQuery(handle,
@@ -106,8 +106,8 @@ static void MakeCookiesTable(sqlite3* const dbhandle) {
// will be as many rows as there are auth tokens per sign in.
// The service_token column will store encrypted values.
ExecOrDie(dbhandle, "CREATE TABLE cookies"
- " (email, service_name, service_token, "
- " PRIMARY KEY(email, service_name) ON CONFLICT REPLACE)");
+ " (email, service_name, service_token, "
+ " PRIMARY KEY(email, service_name) ON CONFLICT REPLACE)");
}
static void MakeSigninTypesTable(sqlite3* const dbhandle) {
@@ -119,8 +119,8 @@ static void MakeSigninTypesTable(sqlite3* const dbhandle) {
}
static void MakeClientIDTable(sqlite3* const dbhandle) {
- // Stores a single client ID value that can be used as the client id,
- // if there's not another such ID provided on the install.
+ // Stores a single client ID value that can be used as the client id, if
+ // there's not another such ID provided on the install.
ExecOrDie(dbhandle, "CREATE TABLE client_id (id) ");
ExecOrDie(dbhandle, "INSERT INTO client_id values ( ? )",
Generate128BitRandomHexString());
@@ -139,16 +139,17 @@ bool UserSettings::Init(const PathString& settings_path) {
int sqlite_result = Exec(dbhandle.get(), "BEGIN EXCLUSIVE TRANSACTION");
CHECK(SQLITE_DONE == sqlite_result);
ScopedStatement table_query(PrepareQuery(dbhandle.get(),
- "select count(*) from sqlite_master where type = 'table'"
- " and name = 'db_version'"));
+ "select count(*) from sqlite_master where type = 'table'"
+ " and name = 'db_version'"));
int query_result = sqlite3_step(table_query.get());
CHECK(SQLITE_ROW == query_result);
int table_count = 0;
GetColumn(table_query.get(), 0, &table_count);
table_query.reset(NULL);
if (table_count > 0) {
- ScopedStatement version_query(PrepareQuery(dbhandle.get(),
- "SELECT version FROM db_version"));
+ ScopedStatement
+ version_query(PrepareQuery(dbhandle.get(),
+ "SELECT version FROM db_version"));
query_result = sqlite3_step(version_query.get());
CHECK(SQLITE_ROW == query_result);
const int version = sqlite3_column_int(version_query.get(), 0);
@@ -188,7 +189,6 @@ bool UserSettings::Init(const PathString& settings_path) {
return true;
}
-
UserSettings::~UserSettings() {
if (dbhandle_)
sqlite3_close(dbhandle_);
diff --git a/chrome/browser/sync/util/user_settings.h b/chrome/browser/sync/util/user_settings.h
index 45116a5..f8f1ee4 100644
--- a/chrome/browser/sync/util/user_settings.h
+++ b/chrome/browser/sync/util/user_settings.h
@@ -36,8 +36,8 @@ class UserSettings {
void SwitchUser(const std::string& email);
// Saves the email address and the named service token for the given user.
- // Call this multiple times with the same email parameter to save
- // multiple service tokens.
+ // Call this multiple times with the same email parameter to save multiple
+ // service tokens.
void SetAuthTokenForService(const std::string& email,
const std::string& service_name,
const std::string& long_lived_service_token);
@@ -47,8 +47,8 @@ class UserSettings {
// Returns the user name whose credentials have been persisted.
bool GetLastUser(std::string* username);
- // Returns the user name whose credentials have been persisted as well as
- // a service token for the named service
+ // Returns the user name whose credentials have been persisted as well as a
+ // service token for the named service
bool GetLastUserAndServiceToken(const std::string& service_name,
std::string* username,
std::string* service_token);
@@ -68,12 +68,11 @@ class UserSettings {
// is used as both input and output.
bool GetEmailForSignin(std::string* signin);
-
std::string email() const;
- // Get a unique ID suitable for use as the client ID. This ID
- // has the lifetime of the user settings database. You may use this ID if
- // your operating environment does not provide its own unique client ID.
+ // Get a unique ID suitable for use as the client ID. This ID has the
+ // lifetime of the user settings database. You may use this ID if your
+ // operating environment does not provide its own unique client ID.
std::string GetClientId();
protected:
diff --git a/chrome/browser/sync/util/user_settings_unittest.cc b/chrome/browser/sync/util/user_settings_unittest.cc
index 56c761d..02f1757 100644
--- a/chrome/browser/sync/util/user_settings_unittest.cc
+++ b/chrome/browser/sync/util/user_settings_unittest.cc
@@ -60,9 +60,9 @@ class UserSettingsTest : public testing::Test {
TEST_F(UserSettingsTest, MigrateFromV10ToV11) {
SetUpVersion10Databases();
{
- // Create a UserSettings, which should trigger migration code.
- // We do this inside a scoped block so it closes itself and we can poke
- // around to see what happened later.
+ // Create a UserSettings, which should trigger migration code. We do this
+ // inside a scoped block so it closes itself and we can poke around to see
+ // what happened later.
UserSettings settings;
settings.Init(kV10UserSettingsDB);
}
diff --git a/chrome/test/sync/engine/mock_gaia_authenticator.cc b/chrome/test/sync/engine/mock_gaia_authenticator.cc
index 3891e572..db188f8 100644
--- a/chrome/test/sync/engine/mock_gaia_authenticator.cc
+++ b/chrome/test/sync/engine/mock_gaia_authenticator.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// Use MockGaiaAuthenticator to test your application by faking a login session.
// This mock object should be initialized with the response you expect it to
// return, and then can be used in exactly the same way as the real
@@ -104,4 +104,5 @@ bool MockGaiaAuthenticator::Authenticate(const char* email,
void MockGaiaAuthenticator::ResetCredentials() {
current_user_ = "";
}
+
} // namespace browser_sync
diff --git a/chrome/test/sync/engine/mock_gaia_authenticator.h b/chrome/test/sync/engine/mock_gaia_authenticator.h
index c65e366..1968200 100644
--- a/chrome/test/sync/engine/mock_gaia_authenticator.h
+++ b/chrome/test/sync/engine/mock_gaia_authenticator.h
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// Use MockGaiaAuthenticator to test your application by faking a login session.
// This mock object should be initialized with the response you expect it to
// return for multiple users, and then can be used in exactly the same way
@@ -140,6 +140,7 @@ class MockGaiaAuthenticator {
std::map<std::string, MockUser> mock_credentials_;
std::string current_user_;
};
+
} // namespace browser_sync
#endif // CHROME_TEST_SYNC_ENGINE_MOCK_GAIA_AUTHENTICATOR_H_
diff --git a/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc b/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc
index ec458d0..76c08aa 100644
--- a/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc
+++ b/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+//
// Unit tests for MockGaiaAuthenticator.
#include "base/basictypes.h"
@@ -154,4 +154,5 @@ TEST(MockGaiaAuthenticatorTest, TestSavedCredentials) {
ASSERT_STREQ(mock_gaia_auth.sid().c_str(), "");
ASSERT_STREQ(mock_gaia_auth.lsid().c_str(), "");
}
+
} // namespace
diff --git a/chrome/test/sync/engine/mock_server_connection.cc b/chrome/test/sync/engine/mock_server_connection.cc
index a97d520..bd3d90f 100644
--- a/chrome/test/sync/engine/mock_server_connection.cc
+++ b/chrome/test/sync/engine/mock_server_connection.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
//
// Mock ServerConnectionManager class for use in client regression tests.
-//
#include "chrome/test/sync/engine/mock_server_connection.h"
@@ -264,8 +263,8 @@ void MockConnectionManager::ProcessCommit(ClientToServerMessage* csm,
ASSERT_LT(entry.name().length(), 256ul) << " name probably too long. True "
"server name checking not implemented";
if (entry.version() == 0) {
- // relys on our new item string id format. (string representation of a
- // negative number)
+ // Relies on our new item string id format. (string representation of a
+ // negative number).
committed_ids_.push_back(syncable::Id::CreateFromClientString(id));
} else {
committed_ids_.push_back(syncable::Id::CreateFromServerId(id));
@@ -280,17 +279,17 @@ void MockConnectionManager::ProcessCommit(ClientToServerMessage* csm,
er->set_response_type(CommitResponse::SUCCESS);
er->set_version(entry.version() + 1);
if (!commit_time_rename_prepended_string_.empty()) {
- // Commit time rename sent down from the server
+ // Commit time rename sent down from the server.
er->set_name(commit_time_rename_prepended_string_ + entry.name());
}
string parent_id = entry.parent_id_string();
- // Remap id's we've already assigned
+ // Remap id's we've already assigned.
if (changed_ids.end() != changed_ids.find(parent_id)) {
parent_id = changed_ids[parent_id];
er->set_parent_id_string(parent_id);
}
if (entry.has_version() && 0 != entry.version()) {
- er->set_id_string(id); // allows verification
+ er->set_id_string(id); // Allows verification.
} else {
string new_id = StringPrintf("mock_server:%d", next_new_id_++);
changed_ids[id] = new_id;
diff --git a/chrome/test/sync/engine/mock_server_connection.h b/chrome/test/sync/engine/mock_server_connection.h
index ac7228c..e5573e0 100644
--- a/chrome/test/sync/engine/mock_server_connection.h
+++ b/chrome/test/sync/engine/mock_server_connection.h
@@ -3,7 +3,6 @@
// found in the LICENSE file.
//
// Mock ServerConnectionManager class for use in client unit tests.
-//
#ifndef CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_
#define CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_
@@ -26,8 +25,7 @@ namespace browser_sync {
struct HttpResponse;
}
-class MockConnectionManager
- : public browser_sync::ServerConnectionManager {
+class MockConnectionManager : public browser_sync::ServerConnectionManager {
public:
// A callback function type. These can be set to be called when server
// activity would normally take place. This aids simulation of race
@@ -48,9 +46,8 @@ class MockConnectionManager
// Control of commit response.
void SetMidCommitCallbackFunction(TestCallbackFunction callback);
- // Set this if you want commit to perform commit time rename.
- // Will request that the client renames all commited entries,
- // prepending this string.
+ // Set this if you want commit to perform commit time rename. Will request
+ // that the client renames all commited entries, prepending this string.
void SetCommitTimeRename(string prepend);
// Control of get updates response. All updates set will only be returned
@@ -98,7 +95,7 @@ class MockConnectionManager
PathString* xattr_key,
syncable::Blob* xattr_value,
int xattr_count);
- // Prepare to add checksums
+ // Prepare to add checksums.
void SetLastUpdateDeleted();
void SetLastUpdateSingletonTag(const string& tag);
void SetLastUpdateOriginatorFields(const string& client_id,
@@ -109,7 +106,7 @@ class MockConnectionManager
void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; }
- // Simple inspectors
+ // Simple inspectors.
bool client_stuck() const { return client_stuck_; }
sync_pb::ClientCommand* GetNextClientCommand();
@@ -150,9 +147,9 @@ class MockConnectionManager
// Determine if one entry in a commit should be rejected with a conflict.
bool ShouldConflictThisCommit();
- // Generate a numeric position_in_parent value. We use a global
- // counter that only decreases; this simulates new objects always
- // being added to the front of the ordering.
+ // Generate a numeric position_in_parent value. We use a global counter
+ // that only decreases; this simulates new objects always being added to the
+ // front of the ordering.
int64 GeneratePositionInParent() {
return next_position_in_parent_--;
}
@@ -176,7 +173,7 @@ class MockConnectionManager
bool client_stuck_;
string commit_time_rename_prepended_string_;
- // fail on the next call to PostBufferToPath()
+ // Fail on the next call to PostBufferToPath().
bool fail_next_postbuffer_;
// Our directory.
diff --git a/chrome/test/sync/engine/test_directory_setter_upper.cc b/chrome/test/sync/engine/test_directory_setter_upper.cc
index df089b1..4608ddc 100644
--- a/chrome/test/sync/engine/test_directory_setter_upper.cc
+++ b/chrome/test/sync/engine/test_directory_setter_upper.cc
@@ -34,8 +34,8 @@ void TestDirectorySetterUpper::TearDown() {
return;
{
- // A small scope so we don't have the dir open when we close it and
- // reset the DirectoryManager below.
+ // A small scope so we don't have the dir open when we close it and reset
+ // the DirectoryManager below.
ScopedDirLookup dir(manager(), name());
CHECK(dir.good()) << "Bad directory during tear down check";
RunInvariantCheck(dir);
diff --git a/chrome/test/sync/engine/test_directory_setter_upper.h b/chrome/test/sync/engine/test_directory_setter_upper.h
index 2877e23..0cac7e1 100644
--- a/chrome/test/sync/engine/test_directory_setter_upper.h
+++ b/chrome/test/sync/engine/test_directory_setter_upper.h
@@ -50,10 +50,9 @@ class TestDirectorySetterUpper {
// Clears any existing database backing files that might exist on disk.
void SetUp();
- // Undo everything done by SetUp(): close the directory and delete
- // the backing files. Before closing the directory, this will run the
- // directory invariant checks and perform the SaveChanges action on
- // the directory.
+ // Undo everything done by SetUp(): close the directory and delete the
+ // backing files. Before closing the directory, this will run the directory
+ // invariant checks and perform the SaveChanges action on the directory.
void TearDown();
syncable::DirectoryManager* manager() const { return manager_.get(); }