Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: components/nacl/renderer/plugin/utility.cc

Issue 1631413002: NaCl cleanup: Remove not-very-useful debug logging in the plugin code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/nacl/renderer/plugin/utility.h ('k') | components/nacl/renderer/ppb_nacl_private.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <stdarg.h>
8 #include <stdlib.h>
9 #include <string.h>
10
11 #include "components/nacl/renderer/plugin/utility.h" 7 #include "components/nacl/renderer/plugin/utility.h"
12 #include "ppapi/cpp/module.h" 8 #include "ppapi/cpp/module.h"
13 9
14 namespace plugin { 10 namespace plugin {
15 11
16 int gNaClPluginDebugPrintEnabled = -1;
17
18 /*
19 * Prints formatted message to the log.
20 */
21 int NaClPluginPrintLog(const char *format, ...) {
22 va_list arg;
23 int out_size;
24
25 static const int kStackBufferSize = 512;
26 char stack_buffer[kStackBufferSize];
27
28 // Just log locally to stderr if we can't use the nacl interface.
29 if (!GetNaClInterface()) {
30 va_start(arg, format);
31 int rc = vfprintf(stderr, format, arg);
32 va_end(arg);
33 return rc;
34 }
35
36 va_start(arg, format);
37 out_size = vsnprintf(stack_buffer, kStackBufferSize, format, arg);
38 va_end(arg);
39 if (out_size < kStackBufferSize) {
40 GetNaClInterface()->Vlog(stack_buffer);
41 } else {
42 // Message too large for our stack buffer; we have to allocate memory
43 // instead.
44 char *buffer = static_cast<char*>(malloc(out_size + 1));
45 va_start(arg, format);
46 vsnprintf(buffer, out_size + 1, format, arg);
47 va_end(arg);
48 GetNaClInterface()->Vlog(buffer);
49 free(buffer);
50 }
51 return out_size;
52 }
53
54 /*
55 * Currently looks for presence of NACL_PLUGIN_DEBUG and returns
56 * 0 if absent and 1 if present. In the future we may include notions
57 * of verbosity level.
58 */
59 int NaClPluginDebugPrintCheckEnv() {
60 char* env = getenv("NACL_PLUGIN_DEBUG");
61 return (NULL != env);
62 }
63
64 // We cache the NaCl interface pointer and ensure that its set early on, on the 12 // We cache the NaCl interface pointer and ensure that its set early on, on the
65 // main thread. This allows GetNaClInterface() to be used from non-main threads. 13 // main thread. This allows GetNaClInterface() to be used from non-main threads.
66 static const PPB_NaCl_Private* g_nacl_interface = NULL; 14 static const PPB_NaCl_Private* g_nacl_interface = NULL;
67 15
68 const PPB_NaCl_Private* GetNaClInterface() { 16 const PPB_NaCl_Private* GetNaClInterface() {
69 return g_nacl_interface; 17 return g_nacl_interface;
70 } 18 }
71 19
72 void SetNaClInterface(const PPB_NaCl_Private* nacl_interface) { 20 void SetNaClInterface(const PPB_NaCl_Private* nacl_interface) {
73 g_nacl_interface = nacl_interface; 21 g_nacl_interface = nacl_interface;
74 } 22 }
75 23
76 } // namespace plugin 24 } // namespace plugin
OLDNEW
« no previous file with comments | « components/nacl/renderer/plugin/utility.h ('k') | components/nacl/renderer/ppb_nacl_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698