Skip to content

Commit

Permalink
Better constify string constants in extensions/
Browse files Browse the repository at this point in the history
Review-Url: https://codereview.chromium.org/2415313002
Cr-Commit-Position: refs/heads/master@{#425392}
  • Loading branch information
leizleiz authored and Commit bot committed Oct 14, 2016
1 parent e871b54 commit 041f756
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion extensions/browser/api/cast_channel/cast_auth_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace api {
namespace cast_channel {
namespace {

const char* const kParseErrorPrefix = "Failed to parse auth message: ";
const char kParseErrorPrefix[] = "Failed to parse auth message: ";

// The maximum number of days a cert can live for.
const int kMaxSelfSignedCertLifetimeInDays = 4;
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/api/cast_channel/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using proto::SocketEvent;

namespace {

const char* kInternalNamespacePrefix = "com.google.cast";
const char kInternalNamespacePrefix[] = "com.google.cast";

proto::ChallengeReplyErrorType ChallegeReplyErrorToProto(
AuthResult::ErrorType error_type) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/api/hid/hid_apitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using testing::_;
#if defined(OS_MACOSX)
const uint64_t kTestDeviceIds[] = {1, 2, 3, 4, 5};
#else
const char* kTestDeviceIds[] = {"A", "B", "C", "D", "E"};
const char* const kTestDeviceIds[] = {"A", "B", "C", "D", "E"};
#endif

// These report descriptors define two devices with 8-byte input, output and
Expand Down
4 changes: 2 additions & 2 deletions extensions/browser/extension_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class UserGestureForTests {
UserGestureForTests();
friend struct base::DefaultSingletonTraits<UserGestureForTests>;

base::Lock lock_; // for protecting access to count_
base::Lock lock_; // for protecting access to |count_|
int count_;
};

Expand Down Expand Up @@ -220,7 +220,7 @@ void ExtensionFunction::ResponseValueObject::SetFunctionError(
bool ExtensionFunction::ignore_all_did_respond_for_testing_do_not_use = false;

// static
const char* ExtensionFunction::kUnknownErrorDoNotUse = "Unknown error.";
const char ExtensionFunction::kUnknownErrorDoNotUse[] = "Unknown error.";

// static
void ExtensionFunctionDeleteTraits::Destruct(const ExtensionFunction* x) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/extension_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class ExtensionFunction
// aren't already set.
// TODO(devlin): Remove this if/when all functions are updated to return real
// errors.
static const char* kUnknownErrorDoNotUse;
static const char kUnknownErrorDoNotUse[];

// Called before Run() in order to perform a common verification check so that
// APIs subclassing this don't have to roll their own RunSafe() variants.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using guest_view::TestGuestViewManager;
using guest_view::TestGuestViewManagerFactory;

// The test extension id is set by the key value in the manifest.
const char* kExtensionId = "oickdpebdnfbgkcaoklfcdhjniefkcji";
const char kExtensionId[] = "oickdpebdnfbgkcaoklfcdhjniefkcji";

// Counts the number of URL requests made for a given URL.
class URLRequestCounter {
Expand Down
4 changes: 2 additions & 2 deletions extensions/browser/script_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace extensions {

namespace {

const char* kRendererDestroyed = "The tab was closed.";
const char* kFrameRemoved = "The frame was removed.";
const char kRendererDestroyed[] = "The tab was closed.";
const char kFrameRemoved[] = "The frame was removed.";

// A handler for a single injection request. On creation this will send the
// injection request to the renderer, and it will be destroyed after either the
Expand Down
4 changes: 2 additions & 2 deletions extensions/browser/warning_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class MockObserver : public WarningService::Observer {

typedef ExtensionsTest WarningServiceTest;

const char* ext1_id = "extension1";
const char* ext2_id = "extension2";
const char ext1_id[] = "extension1";
const char ext2_id[] = "extension2";
const Warning::WarningType warning_1 = Warning::kNetworkDelay;
const Warning::WarningType warning_2 = Warning::kNetworkConflict;

Expand Down
5 changes: 1 addition & 4 deletions extensions/common/extension_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ namespace extensions {

namespace {

const char* kChildKinds[] = {
"functions",
"events"
};
const char* const kChildKinds[] = {"functions", "events"};

std::unique_ptr<base::DictionaryValue> LoadSchemaDictionary(
const std::string& name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

namespace {

const char* kValidImportPath =
const char kValidImportPath[] =
"_modules/abcdefghijklmnopabcdefghijklmnop/foo/bar.html";
const char* kValidImportPathID = "abcdefghijklmnopabcdefghijklmnop";
const char* kValidImportPathRelative = "foo/bar.html";
const char* kInvalidImportPath = "_modules/abc/foo.html";
const char* kImportId1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const char* kImportId2 = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
const char* kNoImport = "cccccccccccccccccccccccccccccccc";
const char kValidImportPathID[] = "abcdefghijklmnopabcdefghijklmnop";
const char kValidImportPathRelative[] = "foo/bar.html";
const char kInvalidImportPath[] = "_modules/abc/foo.html";
const char kImportId1[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const char kImportId2[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
const char kNoImport[] = "cccccccccccccccccccccccccccccccc";

} // namespace

Expand Down
6 changes: 3 additions & 3 deletions extensions/common/permissions/usb_device_permission_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

namespace {

const char* kProductIdKey = "productId";
const char* kVendorIdKey = "vendorId";
const char* kInterfaceIdKey = "interfaceId";
const char kProductIdKey[] = "productId";
const char kVendorIdKey[] = "vendorId";
const char kInterfaceIdKey[] = "interfaceId";

} // namespace

Expand Down
11 changes: 4 additions & 7 deletions extensions/common/url_pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ namespace {

// TODO(aa): What about more obscure schemes like data: and javascript: ?
// Note: keep this array in sync with kValidSchemeMasks.
const char* kValidSchemes[] = {
url::kHttpScheme,
url::kHttpsScheme,
url::kFileScheme,
url::kFtpScheme,
content::kChromeUIScheme,
extensions::kExtensionScheme,
const char* const kValidSchemes[] = {
url::kHttpScheme, url::kHttpsScheme,
url::kFileScheme, url::kFtpScheme,
content::kChromeUIScheme, extensions::kExtensionScheme,
url::kFileSystemScheme,
};

Expand Down
8 changes: 4 additions & 4 deletions extensions/renderer/module_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ using namespace v8_helpers;

namespace {

const char* kModuleSystem = "module_system";
const char* kModuleName = "module_name";
const char* kModuleField = "module_field";
const char* kModulesField = "modules";
const char kModuleSystem[] = "module_system";
const char kModuleName[] = "module_name";
const char kModuleField[] = "module_field";
const char kModulesField[] = "modules";

// Logs an error for the calling context in preparation for potentially
// crashing the renderer, with some added metadata about the context:
Expand Down
4 changes: 2 additions & 2 deletions extensions/renderer/object_backed_native_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace extensions {

namespace {
// Key for the base::Bound routed function.
const char* kHandlerFunction = "handler_function";
const char* kFeatureName = "feature_name";
const char kHandlerFunction[] = "handler_function";
const char kFeatureName[] = "feature_name";
} // namespace

ObjectBackedNativeHandler::ObjectBackedNativeHandler(ScriptContext* context)
Expand Down

0 comments on commit 041f756

Please sign in to comment.